feat(contrib/drivers/dm): add WherePri support#4157
Merged
hailaz merged 26 commits intogogf:masterfrom Dec 3, 2025
Merged
Conversation
gqcn
previously requested changes
Feb 20, 2025
WherePri support
Contributor
There was a problem hiding this comment.
Pull Request Overview
Adds primary key support to the Dameng driver’s TableFields method, adjusts SQL filtering logic, and introduces a unit test for the new WherePri feature.
- Queries and populates primary key columns in
TableFields - Modifies
DoFilterto stop stripping double quotes in SQL - Adds
Test_DB_WherePriand fixes an existing test assertion
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| contrib/drivers/dm/dm_z_unit_basic_test.go | Fixed TableFields assertion and added Test_DB_WherePri |
| contrib/drivers/dm/dm_table_fields.go | Added queries to fetch and flag primary key columns in TableFields |
| contrib/drivers/dm/dm_do_filter.go | Updated regex in DoFilter to retain double quotes |
Comments suppressed due to low confidence (3)
contrib/drivers/dm/dm_z_unit_basic_test.go:141
- Add
defer dropTable(tableName)after creating the table to ensure the test cleans up its resources and doesn't affect subsequent tests.
func Test_DB_WherePri(t *testing.T) {
contrib/drivers/dm/dm_z_unit_basic_test.go:149
- Consider adding an assertion that
resOne.Id(or the primary key field) equals1to verify thatWherePri(1)returned the correct record.
t.AssertNQ(resOne, nil)
contrib/drivers/dm/dm_do_filter.go:23
- Removing
"from the regex means quoted identifiers will no longer be unquoted. Confirm this change is intentional, as it may lead to SQL syntax errors or unexpected behavior.
newSql, _ = gregex.ReplaceString(`[\n\t]`, "", sql)
…or TableFields functionality
… single quotes in TableFields function
…and improve test description
hailaz
approved these changes
Dec 3, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…est function naming
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.
The Dameng database supports the wherepri method.
eg:
dao.User.Ctx(ctx).WherePri(id)