-
-
Notifications
You must be signed in to change notification settings - Fork 741
Open
Description
Description
./test.shgit clone --depth 1 -b master https://github.com/go-gorm/gorm.git
Cloning into 'gorm'...
remote: Enumerating objects: 179, done.
remote: Counting objects: 100% (179/179), done.
remote: Compressing objects: 100% (173/173), done.
remote: Total 179 (delta 11), reused 61 (delta 4), pack-reused 0
Receiving objects: 100% (179/179), 226.27 KiB | 2.73 MiB/s, done.
Resolving deltas: 100% (11/11), done.
go: downloading gorm.io/driver/postgres v1.5.2
go: downloading gorm.io/driver/sqlite v1.5.3
go: downloading gorm.io/driver/mysql v1.5.1
go: downloading gorm.io/driver/sqlserver v1.5.1
go: downloading github.com/jackc/pgx/v5 v5.4.3
go: downloading github.com/go-sql-driver/mysql v1.7.1
go: downloading github.com/microsoft/go-mssqldb v1.5.0
go: downloading github.com/jackc/pgx v3.6.2+incompatible
go: downloading github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a
go: downloading golang.org/x/crypto v0.12.0
go: downloading golang.org/x/text v0.12.0
go: downloading github.com/jackc/pgpassfile v1.0.0
go: downloading github.com/microsoft/go-mssqldb v1.6.0
go: downloading github.com/golang-sql/sqlexp v0.1.0
go: downloading github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9
go: downloading golang.org/x/crypto v0.14.0
go: downloading golang.org/x/text v0.13.0
go: upgraded github.com/microsoft/go-mssqldb v1.5.0 => v1.6.0
go: upgraded golang.org/x/crypto v0.12.0 => v0.14.0
go: upgraded golang.org/x/text v0.12.0 => v0.13.0
go: upgraded gorm.io/driver/sqlite v1.5.3 => v1.5.4
Creating network "playground_default" with the default driver
Creating playground_mysql_1 ... done
Creating playground_postgres_1 ... done
Creating playground_mssql_1 ... done
starting...
testing sqlite...
2023/10/08 15:46:37 testing sqlite3...
2023/10/08 15:46:37 /home/qcazelles/Desktop/playground/db.go:97 table "companies" has more than one primary key
[0.023ms] [rows:0] CREATE TABLE `companies` (`id` integer PRIMARY KEY AUTOINCREMENT,`name` text,PRIMARY KEY (`id`))
2023/10/08 15:46:37 Failed to auto migrate, but got error table "companies" has more than one primary key
FAIL gorm.io/playground 0.038s
I wanted to use the playground to submit the same issue for Gorm usage with sqlite itself ...
go version go1.20.2 linux/amd64Gorm is in version 1.25.4
gorm.io/driver/sqlite in v1.5.4
Minimal reproducer
main.go
package main
import (
"fmt"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
type TestStruct struct {
gorm.Model
field string
}
func main() {
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
// Migrate the schema
err = db.AutoMigrate(&TestStruct{})
if err != nil {
fmt.Println(err)
}
}2023/10/08 15:40:03 /home/qcazelles/Desktop/minimal_reproducer/main.go:21 table "test_structs" has more than one primary key
[0.016ms] [rows:0] CREATE TABLE `test_structs` (`id` integer PRIMARY KEY AUTOINCREMENT,`created_at` datetime,`updated_at` datetime,`deleted_at` datetime,PRIMARY KEY (`id`))
table "test_structs" has more than one primary key
This last code works fine with mysql driver.
Thank you
Metadata
Metadata
Assignees
Labels
No labels