We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原来使用正常,版本为 gorm.io/gorm v1.23.8 gorm.io/driver/postgres v1.3.9 升级后 gorm.io/gorm v1.25.8 gorm.io/driver/postgres v1.5.7
问题一:无法通过map添加数据
error:LastInsertId is not supported by this driver,无法插入数据
以下为测试代码
package gorm import ( "fmt" "gorm.io/driver/postgres" "gorm.io/gorm" "testing" ) func TestRun(t *testing.T) { var source = `host=127.0.0.1 user=postgres password=postgres dbname=ztf_host port=5432 sslmode=disable` //tdb, err := NewGorm(&models.DbConfig{ // DbType: models.DbType(1), // Source: source, //}) tdb, err := gorm.Open(postgres.Open(source), &gorm.Config{}) if err != nil { return } var c int64 //dba := tdb.Table("test").Debug().Where(fmt.Sprintf(`%s =?`, "a"), "111") //dba.Count(&c) var newData = map[string]any{ "a": "222", "id": "1", } err = tdb.Table("test").Debug().Create(&newData).Error fmt.Println(err) fmt.Println(c) }
问题二:gorm如果有求数量操作的话,生成的更新语句错误 此时生成的sql为 update test set a='222' from test where a='111'
package gorm import ( "fmt" "gorm.io/driver/postgres" "gorm.io/gorm" "testing" ) func TestRun(t *testing.T) { var source = `host=127.0.0.1 user=postgres password=postgres dbname=ztf_host port=5432 sslmode=disable` //tdb, err := NewGorm(&models.DbConfig{ // DbType: models.DbType(1), // Source: source, //}) tdb, err := gorm.Open(postgres.Open(source), &gorm.Config{}) if err != nil { return } var c int64 dba := tdb.Table("test").Debug().Where(fmt.Sprintf(`%s =?`, "a"), "111") dba.Count(&c) var newData = map[string]any{ "a": "222", } err =dba.Updates(&newData).Error fmt.Println(err) fmt.Println(c) }
The text was updated successfully, but these errors were encountered:
jinzhu
No branches or pull requests
原来使用正常,版本为
gorm.io/gorm v1.23.8
gorm.io/driver/postgres v1.3.9
升级后
gorm.io/gorm v1.25.8
gorm.io/driver/postgres v1.5.7
问题一:无法通过map添加数据
error:LastInsertId is not supported by this driver,无法插入数据
以下为测试代码
问题二:gorm如果有求数量操作的话,生成的更新语句错误
此时生成的sql为 update test set a='222' from test where a='111'
The text was updated successfully, but these errors were encountered: