test: add integration suite against real PostgreSQL and MySQL#1
Closed
Puppo wants to merge 2 commits into
Closed
Conversation
Executes queries built by every public API (params, glue, map, quoteIdent, unsafe, nested statements, append, nulls, special chars, injection-as-literal) against live PostgreSQL and MySQL (both mysql and mysql2 drivers), proving the generated SQL is valid and that interpolated values are stored as literals. - docker-compose: add mysql:8.0 service + healthchecks, bump postgres to 17 - package.json: add mysql/mysql2 devDeps and db:up/db:down/test:integration scripts - ci: add MySQL service and integration test step - README: document the integration commands
|
No linked issues found. Please add the corresponding issues in the pull request description. |
Owner
Author
|
Superseded by upstream PR nearform#236. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Docker-backed integration test suite that executes queries built by every public API of
@nearform/sqlagainst real PostgreSQL and MySQL. The existing tests only assert generated strings without ever running them, so regressions in placeholder numbering, identifier quoting, nested-statement offsets, or injection handling could pass CI while breaking real queries.Coverage
11 cases × 3 drivers (pg, mysql2, legacy mysql) = 33 tests, all executed end-to-end:
glue— IN clause + batch insertmap— IN clause (default & object mapper)quoteIdent— dynamic table/column names + escaping the quote char on a live identifierunsafe— literal fragment interpolationSqlStatement— proves$Nplaceholder numbering against a live serverappendChanges
integration/— config + driver adapters (onequery/raw/endinterface) + a single dialect-aware feature suite shared by all three drivers.docker-compose.yml— addmysql:8.0service with healthchecks, bump Postgres to17-alpine.package.json— addmysql/mysql2devDeps anddb:up,db:down,test:integration,test:integration:dockerscripts..github/workflows/ci.yml— add MySQL service + integration test step.README.md— document the new commands.Notes
mysqldriver can't speak MySQL 8's defaultcaching_sha2_password, so the adapter uses a shortmysql2connection to switch the account tomysql_native_passwordfirst — works identically locally and in CI without a containercommandoverride (unsupported by GitHub service containers).--test-concurrency=1because both MySQL drivers share onesqlmapdatabase; the pg suite is isolated in its own DB.Verification
npm test(unit) still passes and needs no DB;npm run lintclean.$Noffset logic → nested-statement pg test failed as intended → reverted.Run locally with
npm run test:integration:docker.