From a7cb8181eb998eca39e3cf5cd7dce950d22b2b7f Mon Sep 17 00:00:00 2001 From: Mikhail Knyazhev Date: Sat, 18 Oct 2025 05:54:47 +0300 Subject: [PATCH] fix sql generate --- _example/go-gen/repo_meta.go | 6 +++--- _example/go-gen/repo_user.go | 6 +++--- internal/gen/ormb/generate_code.go | 1 - 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/_example/go-gen/repo_meta.go b/_example/go-gen/repo_meta.go index f6fa8fb..445dbae 100755 --- a/_example/go-gen/repo_meta.go +++ b/_example/go-gen/repo_meta.go @@ -17,7 +17,7 @@ import ( const sqlCreateMeta = `INSERT INTO "meta" ("uid", "user_id", "roles", "fail", "created_at", "updated_at", "deleted_at") VALUES ($1, $2, $3, $4, $5, $6, $7)` -func (v *Repo) CreateBulkMeta(ctx context.Context, ms []Meta, opts ...CreateOption) error { +func (v *Repo) CreateBulkMeta(ctx context.Context, ms []*Meta, opts ...CreateOption) error { if len(ms) == 0 { return nil } @@ -44,7 +44,7 @@ func (v *Repo) CreateBulkMeta(ctx context.Context, ms []Meta, opts ...CreateOpti } }) } -func (v *Repo) CreateMeta(ctx context.Context, m Meta, opts ...CreateOption) error { +func (v *Repo) CreateMeta(ctx context.Context, m *Meta, opts ...CreateOption) error { m.UID = uuid.New() m.CreatedAt = time.Now() buf := _sqlBuilderPool.Get() @@ -278,7 +278,7 @@ func (v *Repo) SelectMetaByDeletedAt(ctx context.Context, args ...time.Time) ([] const sqlUpdateMetaById = `UPDATE "meta" SET "created_at"=$5, "deleted_at"=$7, "fail"=$4, "roles"=$3, "uid"=$1, "updated_at"=$6, "user_id"=$2 WHERE "id"=$8;` -func (v *Repo) UpdateMetaById(ctx context.Context, ms ...Meta) error { +func (v *Repo) UpdateMetaById(ctx context.Context, ms ...*Meta) error { if len(ms) == 0 { return nil } diff --git a/_example/go-gen/repo_user.go b/_example/go-gen/repo_user.go index bfdd86e..0cb478e 100755 --- a/_example/go-gen/repo_user.go +++ b/_example/go-gen/repo_user.go @@ -14,7 +14,7 @@ import ( const sqlCreateUser = `INSERT INTO "users" ("name", "value", "meta0") VALUES ($1, $2, $3)` -func (v *Repo) CreateBulkUser(ctx context.Context, ms []User, opts ...CreateOption) error { +func (v *Repo) CreateBulkUser(ctx context.Context, ms []*User, opts ...CreateOption) error { if len(ms) == 0 { return nil } @@ -37,7 +37,7 @@ func (v *Repo) CreateBulkUser(ctx context.Context, ms []User, opts ...CreateOpti } }) } -func (v *Repo) CreateUser(ctx context.Context, m User, opts ...CreateOption) error { +func (v *Repo) CreateUser(ctx context.Context, m *User, opts ...CreateOption) error { buf := _sqlBuilderPool.Get() defer func() { _sqlBuilderPool.Put(buf) }() buf.WriteString(sqlCreateUser) @@ -173,7 +173,7 @@ func (v *Repo) SelectUserByMeta0(ctx context.Context, args ...Meta) ([]User, err const sqlUpdateUserById = `UPDATE "users" SET "meta0"=$3, "name"=$1, "value"=$2 WHERE "id"=$4;` -func (v *Repo) UpdateUserById(ctx context.Context, ms ...User) error { +func (v *Repo) UpdateUserById(ctx context.Context, ms ...*User) error { if len(ms) == 0 { return nil } diff --git a/internal/gen/ormb/generate_code.go b/internal/gen/ormb/generate_code.go index f799793..9eeaa5b 100644 --- a/internal/gen/ormb/generate_code.go +++ b/internal/gen/ormb/generate_code.go @@ -52,7 +52,6 @@ func GenerateCode(cc common.Config, vv *visitor.Visitor, g *dialects.Gen) error common.Writeln(w, `"fmt"`) common.Writeln(w, `"strings"`) common.Writeln(w, `"go.osspkg.com/ioutils/pool"`) - common.Writeln(w, `"go.osspkg.com/goppy/v2/orm"`) for _, imp := range ci.Imports { common.Writelnf(w, `%s "%s"`, imp.Name, imp.Pkg) }