Skip to content
New issue

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

'table name specified more than once' postgres error #746

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
21 changes: 0 additions & 21 deletions gen.go

This file was deleted.

19 changes: 6 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ go 1.20

require (
gorm.io/driver/mysql v1.5.2
gorm.io/driver/postgres v1.5.2
gorm.io/driver/postgres v1.5.3
gorm.io/driver/sqlite v1.5.3
gorm.io/driver/sqlserver v1.5.1
gorm.io/gen v0.3.25
gorm.io/gorm v1.25.4
)

Expand All @@ -17,19 +16,13 @@ require (
github.com/golang-sql/sqlexp v0.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v5 v5.4.3 // indirect
github.com/jackc/pgx/v5 v5.5.5 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
github.com/microsoft/go-mssqldb v1.5.0 // indirect
golang.org/x/crypto v0.14.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.15.0 // indirect
gorm.io/datatypes v1.1.1-0.20230130040222-c43177d3cf8c // indirect
gorm.io/hints v1.1.0 // indirect
gorm.io/plugin/dbresolver v1.5.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/text v0.14.0 // indirect
)

replace gorm.io/gorm => ./gorm
16 changes: 14 additions & 2 deletions main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package main

import (
"log"
"os"
"testing"

"gorm.io/gorm"
)

// GORM_REPO: https://github.com/go-gorm/gorm.git
Expand All @@ -11,10 +15,18 @@ import (
func TestGORM(t *testing.T) {
user := User{Name: "jinzhu"}

DB.Create(&user)
DB.Session(&gorm.Session{}).Create(&user)

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

var DB2 *gorm.DB
var err error
if DB2, err = OpenTestConnection(); err != nil {
log.Printf("failed to connect database, got error %v\n", err)
os.Exit(1)
}

if err := DB2.First(&result, user.ID).Update("name", "jinzhu 2").Error; err != nil {
t.Errorf("Failed, got error: %v", err)
}
}
Loading