Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/drivers/pgsql/pgsql_table_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ FROM pg_attribute a
left join pg_description b ON a.attrelid=b.objoid AND a.attnum = b.objsubid
left join pg_type t ON a.atttypid = t.oid
left join information_schema.columns ic on ic.column_name = a.attname and ic.table_name = c.relname
WHERE c.relname = '%s' and a.attisdropped is false and a.attnum > 0
WHERE c.oid = '%s'::regclass and a.attisdropped is false and a.attnum > 0
ORDER BY a.attnum`
)

Expand Down
8 changes: 4 additions & 4 deletions contrib/drivers/pgsql/pgsql_z_unit_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,8 @@ int_col INT);`
IntCol int64
}
// pgsql converts table names to lowercase
// mark: [c.oid = '%s'::regclass] is not case-sensitive
tableName := "Error_table"
errStr := fmt.Sprintf(`The table "%s" may not exist, or the table contains no fields`, tableName)
_, err := db.Exec(ctx, fmt.Sprintf(createSql, tableName))
gtest.AssertNil(err)
defer dropTable(tableName)
Expand All @@ -351,7 +351,7 @@ int_col INT);`
IntCol: 2,
}
_, err = db.Model(tableName).Data(data).Insert()
t.Assert(err, errStr)
t.AssertNE(err, nil)

// Insert a piece of test data using lowercase
_, err = db.Model(strings.ToLower(tableName)).Data(data).Insert()
Expand All @@ -360,7 +360,7 @@ int_col INT);`
_, err = db.Model(tableName).Where("id", 1).Data(g.Map{
"int_col": 9999,
}).Update()
t.Assert(err, errStr)
t.AssertNE(err, nil)

})
// The inserted field does not exist in the table
Expand All @@ -370,7 +370,7 @@ int_col INT);`
"int_col_22": 11111,
}
_, err = db.Model(tableName).Data(data).Insert()
t.Assert(err, errStr)
t.Assert(err, fmt.Errorf(`input data match no fields in table "%s"`, tableName))

lowerTableName := strings.ToLower(tableName)
_, err = db.Model(lowerTableName).Data(data).Insert()
Expand Down
Loading