From 099bdfc7d957f3593eac8810cfa9c6cf0abe5d04 Mon Sep 17 00:00:00 2001 From: Rogee Date: Wed, 28 May 2025 19:38:03 +0800 Subject: [PATCH] feat: update tools --- .vscode/settings.json | 19 ++++++++++++++++++- pkg/ast/model/table_funcs.go.tpl | 5 ++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2761437..8198866 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,20 @@ { - "editor.fontSize": 10 + "editor.fontSize": 10, + "dbcode.connections": [ + { + "connectionId": "l6fEOogu2kQt5G3BashDt", + "name": "10.1.1.2", + "driver": "postgres", + "connectionType": "host", + "host": "10.1.1.2", + "port": 5432, + "ssl": false, + "username": "postgres", + "password": "", + "savePassword": "secretStorage", + "database": "quyun", + "readOnly": false, + "connectionTimeout": 30 + } + ] } \ No newline at end of file diff --git a/pkg/ast/model/table_funcs.go.tpl b/pkg/ast/model/table_funcs.go.tpl index 8980b97..60833df 100644 --- a/pkg/ast/model/table_funcs.go.tpl +++ b/pkg/ast/model/table_funcs.go.tpl @@ -43,7 +43,7 @@ func (m *{{.PascalTable}}) Create(ctx context.Context) error { {{- end}} - stmt := tblMedias.INSERT(tbl{{.PascalTable}}.MutableColumns).MODEL(m).RETURNING(tblMedias.AllColumns) + stmt := tbl{{.PascalTable}}.INSERT(tbl{{.PascalTable}}.MutableColumns).MODEL(m).RETURNING(tbl{{.PascalTable}}.AllColumns) m.log().WithField("func","Create").Info( stmt.DebugSql()) if err := stmt.QueryContext(ctx, db, m); err != nil { @@ -207,8 +207,7 @@ func (m *{{.PascalTable}}) GetByID(ctx context.Context, id int64, conds ...Cond) func (m *{{.PascalTable}}) Count(ctx context.Context, conds ...Cond) (int64, error) { cond := CondTrue(conds...) - tbl := tbl{{.PascalTable}} - stmt := tbl.SELECT(COUNT(tbl.ID).AS("count")).WHERE(cond) + stmt := tbl{{.PascalTable}}.SELECT(COUNT(tbl{{.PascalTable}}.ID).AS("count")).WHERE(cond) m.log().Infof("sql: %s", stmt.DebugSql()) var count struct {