Skip to content

fix(contrib/drivers/dm): preserve quoted identifiers - #4828

Merged
gqcn merged 3 commits into
gogf:masterfrom
yuyinw:fix/dm-preserve-quoted-identifiers
Sep 15, 2026
Merged

gqcn merged 3 commits into
gogf:masterfrom
yuyinw:fix/dm-preserve-quoted-identifiers

Conversation

@yuyinw

@yuyinw yuyinw commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes the DM driver SQL filter so it preserves double-quoted identifiers, which are used by DM as identifier delimiters.

Previously, DoFilter removed 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=1
  • go test -run '^$' -count=1

@yuyinw yuyinw changed the title fix: preserve DM quoted identifiers fix(contrib/drivers/dm): preserve quoted identifiers Aug 4, 2026
@yuyinw
yuyinw force-pushed the fix/dm-preserve-quoted-identifiers branch 4 times, most recently from 266684f to 7caccfb Compare August 5, 2026 11:03
@yuyinw
yuyinw force-pushed the fix/dm-preserve-quoted-identifiers branch from 7caccfb to 0dd607e Compare August 5, 2026 11:18
@hailaz
hailaz requested a lite review from Copilot August 19, 2026 10:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in DoFilter.
  • Improve TableFields metadata 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.

Comment thread contrib/drivers/dm/dm_z_unit_init_test.go
Comment thread contrib/drivers/dm/dm_table_fields.go Outdated
Comment thread contrib/drivers/dm/dm_do_filter.go
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 gqcn added the bot-approved Approved by gf-pr-review label Sep 14, 2026
@gqcn
gqcn merged commit 9b00664 into gogf:master Sep 15, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot-approved Approved by gf-pr-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants