fix(contrib/drivers/dm): preserve quoted identifiers - #4828
Merged
Merged
Conversation
yuyinw
force-pushed
the
fix/dm-preserve-quoted-identifiers
branch
4 times, most recently
from
August 5, 2026 11:03
266684f to
7caccfb
Compare
yuyinw
force-pushed
the
fix/dm-preserve-quoted-identifiers
branch
from
August 5, 2026 11:18
7caccfb to
0dd607e
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the DM (contrib/drivers/dm) database driver to better support DM’s use of double quotes (") as identifier delimiters, avoiding accidental removal of quoted identifiers and improving metadata lookups for case-sensitive (quoted) table names.
Changes:
- Adjust DM driver quoting behavior by disabling automatic identifier quoting via
GetChars()and preserving double-quoted identifiers inDoFilter. - Improve
TableFieldsmetadata resolution by trying uppercase table names first, then falling back to the original case. - Add focused unit tests covering
DoFilter,GetChars, and the new metadata table-name candidate logic.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| contrib/drivers/dm/dm.go | Changes DM driver quote chars behavior by returning empty chars from GetChars(). |
| contrib/drivers/dm/dm_do_filter.go | Stops stripping " from SQL and refines INDEX quoting to avoid touching quoted/string-literal occurrences. |
| contrib/drivers/dm/dm_do_filter_test.go | Adds unit tests for quoted identifier preservation, selective INDEX quoting, and GetChars(). |
| contrib/drivers/dm/dm_table_fields.go | Adds table-name candidate fallback logic for metadata lookups and reuses chosen candidate for PK queries. |
| contrib/drivers/dm/dm_table_fields_test.go | Adds a unit test for tableNameCandidatesForMetadata. |
| contrib/drivers/dm/dm_z_unit_init_test.go | Updates test DB setup/teardown helpers to handle more table-name variants (including quoted forms). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Build DM metadata table candidates from the de-quoted table name so quoted test tables can be dropped through the same lookup path as unquoted tables. Trim DM identifier quotes before uppercasing schema names for metadata owner filters, and cover the helper with a focused unit test.
gqcn
approved these changes
Sep 15, 2026
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.
Description
This PR fixes the DM driver SQL filter so it preserves double-quoted identifiers, which are used by DM as identifier delimiters.
Previously,
DoFilterremoved all double quotes from SQL, breaking quoted table or column names. The filter now keeps explicit quoted identifiers and preserves the original SQL whitespace while still applying the existing DM-specific function/keyword conversions.The DM metadata lookup now first keeps the existing uppercase lookup behavior, then falls back to the original table-name case so quoted, case-sensitive table names can still resolve their fields. It also trims DM identifier quotes before building metadata table-name and owner-name candidates.
Testing
go test -run 'TestDriverDoFilterPreservesDoubleQuotedIdentifiers|TestDriverDoFilterQuotesOnlyUnquotedIndexKeyword|TestDriverGetCharsDisablesAutomaticIdentifierQuoting|TestTableNameCandidatesForMetadata|TestSchemaNameForMetadata' -count=1go test -run '^$' -count=1