Skip to content

fix issue #2782 that orm builder generate incorrect sql in some case#2787

Merged
gqcn merged 3 commits into
gogf:masterfrom
Agzer0:fix/2782
Jul 25, 2023
Merged

fix issue #2782 that orm builder generate incorrect sql in some case#2787
gqcn merged 3 commits into
gogf:masterfrom
Agzer0:fix/2782

Conversation

@Agzer0
Copy link
Copy Markdown
Contributor

@Agzer0 Agzer0 commented Jul 20, 2023

fix issues #2782 : When ORM is constructing multiple SQL conditions, the OmitEmpty option is used. If the first condition is empty conditions and the second condition is the compound condition. At this time, when there is still a third condition, the generated SQL is wrong.

@gqcn
Copy link
Copy Markdown
Member

gqcn commented Jul 20, 2023

@Agzer0 Thanks for your contribution, but please commit associated unit testing case for this update. Please add the unit testing case here: https://github.com/gogf/gf/blob/master/contrib/drivers/mysql/mysql_issue_test.go . There're reference cases already for you.

@gqcn gqcn added the missing unit testing cases Used in PR, the associated unit testing cases should be committed. label Jul 20, 2023
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jul 20, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (4ad508c) 79.15% compared to head (eff41ee) 79.15%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2787   +/-   ##
=======================================
  Coverage   79.15%   79.15%           
=======================================
  Files         632      632           
  Lines       52174    52174           
=======================================
+ Hits        41298    41300    +2     
+ Misses       8830     8828    -2     
  Partials     2046     2046           
Flag Coverage Δ
go-1.15-386 79.17% <100.00%> (-0.01%) ⬇️
go-1.15-amd64 79.16% <100.00%> (-0.04%) ⬇️
go-1.16-386 79.17% <100.00%> (ø)
go-1.16-amd64 79.17% <100.00%> (-0.01%) ⬇️
go-1.17-386 79.17% <100.00%> (+<0.01%) ⬆️
go-1.17-amd64 79.16% <100.00%> (+<0.01%) ⬆️
go-1.18-386 78.78% <100.00%> (-0.01%) ⬇️
go-1.18-amd64 78.78% <100.00%> (?)
go-1.19-386 79.16% <100.00%> (?)
go-1.19-amd64 79.16% <100.00%> (ø)
go-1.20-386 79.14% <100.00%> (?)
go-1.20-amd64 79.13% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
database/gdb/gdb_model_builder.go 97.29% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Agzer0
Copy link
Copy Markdown
Contributor Author

Agzer0 commented Jul 20, 2023

okay, i`ve added testing case

@houseme houseme requested a review from gqcn July 21, 2023 03:00
@gqcn gqcn merged commit 83fa359 into gogf:master Jul 25, 2023
@gqcn gqcn changed the title fix: orm generate sql wrong, issues #2782 fix issue #2782 that orm builder generate incorrect sql in some case Jul 25, 2023
lingcoder added a commit to lingcoder/gf that referenced this pull request Apr 14, 2026
Add 38 issue regression tests ported from MariaDB baseline, bringing
the total from 9 to 47. Tests cover JSON scanning (gogf#1380), ScanList
(gogf#1570), With/WithAll (gogf#1401, gogf#1412, gogf#2119), timestamp comparison
(gogf#1002), case-sensitive columns (gogf#1700), OmitEmpty (gogf#2561, gogf#3204),
FieldsEx soft-time (gogf#3754), Hook+concurrent (gogf#3238), cache Hook
(gogf#3626), Order variations (gogf#3932), ScanAndCount+Hook (gogf#3968), column
comparison with Raw (gogf#3915), AllAndCount/Distinct (gogf#4698), Fields
empty string (gogf#4697), ClearTableFields (gogf#2552), sub-query model
(gogf#2339), Delete guard (gogf#2427), batch duplicate key (gogf#3086), JSON
null/array scan (gogf#4086), sys_config JSON (gogf#3218), Transaction+Save
(gogf#4034), Builder conditions (gogf#2787), WherePrefixNotIn (gogf#2907),
InnerJoinOnField (gogf#2439), and captured SQL quoting (gogf#3649).

MySQL-specific tests (IF(), zerofill, BIGINT UNSIGNED, cross-schema,
lpad/concat_ws, MariaDB regex) are present as skip stubs to maintain
function-name parity.

12 PgSQL-dialect testdata SQL files added for tests that depend on
external schema definitions.

ref gogf#4689
lingcoder added a commit to lingcoder/gf that referenced this pull request Apr 23, 2026
Add 38 issue regression tests ported from MariaDB baseline, bringing
the total from 9 to 47. Tests cover JSON scanning (gogf#1380), ScanList
(gogf#1570), With/WithAll (gogf#1401, gogf#1412, gogf#2119), timestamp comparison
(gogf#1002), case-sensitive columns (gogf#1700), OmitEmpty (gogf#2561, gogf#3204),
FieldsEx soft-time (gogf#3754), Hook+concurrent (gogf#3238), cache Hook
(gogf#3626), Order variations (gogf#3932), ScanAndCount+Hook (gogf#3968), column
comparison with Raw (gogf#3915), AllAndCount/Distinct (gogf#4698), Fields
empty string (gogf#4697), ClearTableFields (gogf#2552), sub-query model
(gogf#2339), Delete guard (gogf#2427), batch duplicate key (gogf#3086), JSON
null/array scan (gogf#4086), sys_config JSON (gogf#3218), Transaction+Save
(gogf#4034), Builder conditions (gogf#2787), WherePrefixNotIn (gogf#2907),
InnerJoinOnField (gogf#2439), and captured SQL quoting (gogf#3649).

MySQL-specific tests (IF(), zerofill, BIGINT UNSIGNED, cross-schema,
lpad/concat_ws, MariaDB regex) are present as skip stubs to maintain
function-name parity.

12 PgSQL-dialect testdata SQL files added for tests that depend on
external schema definitions.

ref gogf#4689
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