From 4066ee41d1a337726f0a6792db6f7d394ca63a6a Mon Sep 17 00:00:00 2001 From: Pavel Merzlyakov Date: Fri, 16 Jun 2023 00:45:09 +0300 Subject: [PATCH] revert sqlbuilder --- tpl/codegen_bundle.twig | 16 ---------------- tpl/macros_struct.twig | 8 ++++---- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/tpl/codegen_bundle.twig b/tpl/codegen_bundle.twig index 3c07bac..119a89e 100644 --- a/tpl/codegen_bundle.twig +++ b/tpl/codegen_bundle.twig @@ -15,7 +15,6 @@ import ( "git.bit5.ru/backend/versioning" "git.bit5.ru/gomodules/metadb" "github.com/doug-martin/goqu/v9" - "github.com/doug-martin/goqu/v9/dialect/mysql" "github.com/doug-martin/goqu/v9/exp" "github.com/go-logr/logr" "github.com/pkg/errors" @@ -178,18 +177,3 @@ func (rctx *RpcContext) SetLogger(logger logr.Logger) { func (rctx *RpcContext) Logger() logr.Logger { return rctx.logger } - -const ( - goquDialect = "mysql8bit" -) - -func init() { - opts := mysql.DialectOptionsV8() - opts.SupportsInsertIgnoreSyntax = false - - goqu.RegisterDialect(goquDialect, opts) -} - -func SqlBuilder() goqu.DialectWrapper { - return goqu.Dialect(goquDialect) -} diff --git a/tpl/macros_struct.twig b/tpl/macros_struct.twig index dd99686..557e41f 100644 --- a/tpl/macros_struct.twig +++ b/tpl/macros_struct.twig @@ -84,7 +84,7 @@ func Save{{ s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ s.name return err } - ds := SqlBuilder(). + ds := metadb.SqlBuilder(). Insert(goqu.T("{{ table_name }}")). Cols( {% for c in insert_columns -%} @@ -140,7 +140,7 @@ func Save{{ s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ s.name {{ _self.table_delete_diff(_context) }} func Save{{ s.name }}Diff(ctx context.Context, dbe metadb.Execer, rec {{ s.name }}) error { - ds := SqlBuilder(). + ds := metadb.SqlBuilder(). Insert(goqu.T("{{ table_name }}")). Cols( {% for f in pkey %} @@ -269,7 +269,7 @@ func Save{{ ctx.s.name }}Collection(ctx context.Context, dbe metadb.Execer, recs return nil } - ds := SqlBuilder(). + ds := metadb.SqlBuilder(). Insert(goqu.T("{{ ctx.table_name }}")). Cols( {%~ for c in ctx.insert_columns %} @@ -471,7 +471,7 @@ func Delete{{ ctx.s.name }}CollectionById( )) } - ds := SqlBuilder(). + ds := metadb.SqlBuilder(). Delete(goqu.T("level_state")). Where(goqu.L("({{ pkey_values_expr }}) IN ?", {% for f in ctx.pkey %}