Skip to content

Commit cbb7bbe

Browse files
committed
test(pgsql): unskip Test_Issue1412 by using DB column name in with tag
The MySQL version uses \`with:Id=ItemId\` where the left side is a Go field name, which only works because MySQL identifiers are case-insensitive. PgSQL follows SQL standard (double-quoted identifiers are case-sensitive), so the left side must be the actual DB column name (\`id\`). The right side (\`ItemId\`) stays as a Go field name — framework resolves it via case-insensitive struct field matching.
1 parent e791e30 commit cbb7bbe

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

contrib/drivers/pgsql/pgsql_z_unit_issue_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,11 +770,11 @@ func Test_Issue1401(t *testing.T) {
770770

771771
// https://github.com/gogf/gf/issues/1412
772772
func Test_Issue1412(t *testing.T) {
773-
// Framework bug: With() uses Go struct field name ("Id") as the column name in
774-
// WHERE clause instead of the mapped column name ("id"). PgSQL double-quoted identifiers
775-
// are case-sensitive, so WHERE "Id"=0 fails with "column Id does not exist".
776-
// This needs a fix in gdb's With() column-name resolution. TODO: create issue.
777-
t.Skip("Framework bug: With() generates case-sensitive column name on PgSQL — needs core fix")
773+
// PgSQL-adapted: MySQL version uses `with:Id=ItemId` (Go field name on left side),
774+
// which only works because MySQL identifiers are case-insensitive. PgSQL double-quoted
775+
// identifiers are case-sensitive per SQL standard, so the left side must be the actual
776+
// DB column name ("id"). The right side ("ItemId") stays as a Go field name — the
777+
// framework resolves it to the struct field via case-insensitive matching.
778778
var (
779779
table1 = "parcels"
780780
table2 = "items"
@@ -799,7 +799,7 @@ func Test_Issue1412(t *testing.T) {
799799
gmeta.Meta `orm:"table:parcels"`
800800
Id int `json:"id"`
801801
ItemId int `json:"item_id"`
802-
Items Items `json:"items" orm:"with:Id=ItemId"`
802+
Items Items `json:"items" orm:"with:id=ItemId"`
803803
}
804804

805805
entity := &ParcelRsp{}
@@ -822,7 +822,7 @@ func Test_Issue1412(t *testing.T) {
822822
gmeta.Meta `orm:"table:parcels"`
823823
Id int `json:"id"`
824824
ItemId int `json:"item_id"`
825-
Items Items `json:"items" orm:"with:Id=ItemId"`
825+
Items Items `json:"items" orm:"with:id=ItemId"`
826826
}
827827

828828
entity := &ParcelRsp{}

0 commit comments

Comments
 (0)