From 77fc126a0d4bb4916e5e913ac9fe0f5ee427946e Mon Sep 17 00:00:00 2001 From: anton98i <12586459+anton98i@users.noreply.github.com> Date: Tue, 23 Aug 2022 16:37:26 +0200 Subject: [PATCH] Expresions: added CAO and LAO (alias optional) --- expression_ext.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/expression_ext.go b/expression_ext.go index b6f6992e..9a0a1404 100644 --- a/expression_ext.go +++ b/expression_ext.go @@ -65,6 +65,13 @@ func (db *DB) LA(model interface{}, alias string, name string) *expr { return &expr{expr: scope.Quote(alias) + "." + scope.Quote(field.DBName)} } +func (db *DB) LAO(model interface{}, alias string, name string) *expr { + if alias == "" { + return db.L(model, name) + } + return db.LA(model, alias, name) +} + func (db *DB) QuoteExpr(table string, column string) *expr { scope := db.NewScope(nil) return &expr{expr: scope.Quote(table) + "." + scope.Quote(column)} @@ -92,6 +99,13 @@ func (db *DB) CA(model interface{}, alias string, names ...string) string { return strings.Join(columns, ", ") } +func (db *DB) CAO(model interface{}, alias string, names ...string) string { + if alias == "" { + return db.CQ(model, names...) + } + return db.CA(model, alias, names...) +} + func (db *DB) CQ(model interface{}, names ...string) string { columns := make([]string, 0)