Skip to content

Commit

Permalink
bug: first table error
Browse files Browse the repository at this point in the history
  • Loading branch information
nzlov committed Dec 6, 2024
1 parent fabf3ff commit 2109abd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.23.3

require (
gorm.io/driver/mysql v1.5.7
gorm.io/driver/postgres v1.5.10
gorm.io/driver/postgres v1.5.11
gorm.io/driver/sqlite v1.5.6
gorm.io/driver/sqlserver v1.5.4
gorm.io/gen v0.3.26
Expand All @@ -26,13 +26,13 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-sqlite3 v1.14.24 // indirect
github.com/microsoft/go-mssqldb v1.7.2 // indirect
golang.org/x/crypto v0.29.0 // indirect
github.com/microsoft/go-mssqldb v1.8.0 // indirect
golang.org/x/crypto v0.30.0 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.27.0 // indirect
golang.org/x/text v0.20.0 // indirect
golang.org/x/tools v0.27.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/tools v0.28.0 // indirect
gorm.io/datatypes v1.2.4 // indirect
gorm.io/hints v1.1.2 // indirect
gorm.io/plugin/dbresolver v1.5.3 // indirect
Expand Down
13 changes: 11 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ import (
// TEST_DRIVERS: sqlite, mysql, postgres, sqlserver

func TestGORM(t *testing.T) {
user := User{Name: "jinzhu"}
user := User{Name: "jinzhu", Age: 5}
toy := Toy{Name: "jinzhu", OwnerID: "test"}

DB.Create(&user)
DB.Create(&toy)

var result User
if err := DB.First(&result, user.ID).Error; err != nil {
DB = DB.Where("name = ?", "jinzhu")

if err := DB.First(&result, "age = ?", 5).Error; err != nil {
t.Errorf("Failed, got error: %v", err)
}
var ttoy Toy

if err := DB.First(&ttoy, "owner_id = ?", "test").Error; err != nil {
t.Errorf("Failed, got error: %v", err)
}
}

0 comments on commit 2109abd

Please sign in to comment.