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

dbresolver error with gorm v1.25.12 #149

Open
baiyuxiong opened this issue Sep 27, 2024 · 2 comments
Open

dbresolver error with gorm v1.25.12 #149

baiyuxiong opened this issue Sep 27, 2024 · 2 comments
Assignees

Comments

@baiyuxiong
Copy link

It works well with gorm v1.25.10. But with V1.25.12, I got this error :

# gorm.io/plugin/dbresolver
../../go/pkg/mod/gorm.io/plugin/[email protected]/dbresolver.go:147:5: unknown field PreparedSQL in struct literal of type gorm.PreparedStmtDB
gen .sql

My code :

package main

import (
	"gorm.io/driver/mysql"
	"gorm.io/gen"
	"gorm.io/gorm"
)

func main() {

	//-outPath=./models -modelPkgName="models"  -fieldWithTypeTag -onlyModel -fieldWithIndexTag
	g := gen.NewGenerator(gen.Config{
		OutPath:           "model",
		FieldWithIndexTag: true,
		FieldWithTypeTag:  true,
		ModelPkgPath:      "model",
	})

	g.WithImportPkgPath("gorm.io/plugin/soft_delete")

	gormdb, err := gorm.Open(mysql.Open("root:123456@(localhost:3306)/ginstartup?charset=utf8mb4&parseTime=True&loc=Local"))
	if err != nil {
		panic(err)
	}
	g.UseDB(gormdb) // reuse your gorm db

	g.GenerateAllTable(gen.FieldType("deleted_at", "soft_delete.DeletedAt"))

	// Generate the code
	g.Execute()
}
@mualala
Copy link

mualala commented Sep 29, 2024

update dbresolve v1.5.3, so ok

@sslime336
Copy link

Workaround simply:

go get gorm.io/[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants