Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(contrib/drivers/dm): add WherePri support#4157

Merged
hailaz merged 26 commits intogogf:masterfrom
tiger1103:master
Dec 3, 2025
Merged

feat(contrib/drivers/dm): add WherePri support#4157
hailaz merged 26 commits intogogf:masterfrom
tiger1103:master

Conversation

@tiger1103
Copy link
Contributor

The Dameng database supports the wherepri method.
eg: dao.User.Ctx(ctx).WherePri(id)

gqcn
gqcn previously requested changes Feb 20, 2025
@gqcn gqcn changed the title The Dameng database supports the wherepri method. feat(contrib/drivers/dm): add WherePri support Feb 20, 2025
@gqcn gqcn added the missing unit testing cases Used in PR, the associated unit testing cases should be committed. label Feb 27, 2025
@hailaz hailaz requested a review from Copilot June 5, 2025 07:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 DoFilter to stop stripping double quotes in SQL
  • Adds Test_DB_WherePri and 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) equals 1 to verify that WherePri(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)

@hailaz hailaz self-requested a review June 5, 2025 10:06
@hailaz hailaz mentioned this pull request Jun 5, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@hailaz hailaz merged commit ea95618 into gogf:master Dec 3, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing unit testing cases Used in PR, the associated unit testing cases should be committed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants