fix(server-utils): Pass the SQL dialect when summarizing Prisma queries - #23854
Open
Lms24 wants to merge 2 commits into
Open
Conversation
`getSqlQuerySummary` matched a quoted table reference with a regex that stopped after the first quoted identifier, so a schema-qualified name lost its table part (`SELECT ... FROM "public"."User"` summarized as `SELECT "public"`) and a JOIN of two tables in the same schema collapsed into two identical targets. The INSERT/UPDATE/DELETE/DDL branches used a different, whitespace-delimited pattern that kept the qualified name but split any quoted identifier containing a space (`INSERT INTO "my table"` summarized as `INSERT "my`). Both branches now build on one identifier pattern that treats each quoted or bare part as a unit and allows dot-qualification. This matters more now that the value is promoted into span names, where two tables that differ only by table part are otherwise indistinguishable. Refs #23676 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Prisma is multi-connector but sanitized every statement as standard SQL. On MySQL and MariaDB a `"..."` run is a string literal rather than a quoted identifier, so it survived sanitization; a literal containing `FROM` or `JOIN` then read as a table name and landed in `db.query.summary` — and, with span streaming, in the span name. Derive the dialect from the `db.system.name` / `db.system` Prisma reports, matching what knex already does. Also updates the Prisma integration test expectations for the schema-qualified table names that the core query-summary fix now keeps intact. Refs #23676 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
size-limit report 📦
|
Lms24
marked this pull request as ready for review
September 1, 2026 16:40
Lms24
requested review from
JPeer264 and
isaacs
and removed request for
a team
September 1, 2026 16:40
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.
Prisma talks to Postgres, MySQL, SQLite and others, but sanitized every statement as standard SQL. In MySQL,
"..."is a string literal, not a quoted identifier, so the value was never replaced with?. If it containedFROMorJOIN, the summary parser then read it as a table name — and with span streaming, that summary is the span name.A MySQL query with an inlined value:
SELECT * FROM User WHERE bio = "x FROM secret_table"db.query.textSELECT * FROM User WHERE bio = "x FROM secret_table"SELECT * FROM User WHERE bio = ?db.query.summarySELECT User secret_tableSELECT UserThe dialect comes from the
db.system.name/db.systemPrisma already reports, same as knex does in the base PR. Postgres is unaffected — there"..."really is an identifier, and its values arrive as'...', which was already being replaced.Also updates the Prisma test expectations to the qualified table names from #23853.
Stacked on #23602, and carries the commit from #23853 because those updated expectations only pass with it. Merge order: #23853 → #23602 → this.
Refs #23676