fix(server-utils): Pass the SQL dialect when summarizing Prisma queries - #23854
Draft
Lms24 wants to merge 2 commits into
Draft
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 📦
|
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 is multi-connector but sanitized every statement as standard SQL. On MySQL/MariaDB a
"..."run is a string literal rather than a quoted identifier, so it survived sanitization — and a literal containingFROM/JOINthen read as a table name indb.query.summary(and, with span streaming, in the span name). The dialect is derived from thedb.system.name/db.systemPrisma already reports, matching what knex does in the base PR.Stacked on #23602 (base branch) and includes the core commit from #23853, because the Prisma integration test expectations updated here (
SELECT "public"→SELECT "public"."User") only hold once that core fix is in. Merge order: #23853 → #23602 → this.Refs #23676