diff --git a/internal/template/struct.go b/internal/template/struct.go index f3a5e737..3aa1a9c2 100644 --- a/internal/template/struct.go +++ b/internal/template/struct.go @@ -23,6 +23,8 @@ const ( func ({{.S}} {{.QueryStructName}}) Alias() string { return {{.S}}.{{.QueryStructName}}Do.Alias() } + func ({{.S}} {{.QueryStructName}}) Columns(cols ...field.Expr) gen.Columns { return {{.S}}.{{.QueryStructName}}Do.Columns(cols...) } + ` + getFieldMethod + fillFieldMapMethod + cloneMethod + replaceMethod + relationship + defineMethodStruct // TableQueryIface table query interface diff --git a/tests/.expect/dal_1/query/banks.gen.go b/tests/.expect/dal_1/query/banks.gen.go index 0f587b45..8eec526e 100644 --- a/tests/.expect/dal_1/query/banks.gen.go +++ b/tests/.expect/dal_1/query/banks.gen.go @@ -77,6 +77,8 @@ func (b bank) TableName() string { return b.bankDo.TableName() } func (b bank) Alias() string { return b.bankDo.Alias() } +func (b bank) Columns(cols ...field.Expr) gen.Columns { return b.bankDo.Columns(cols...) } + func (b *bank) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := b.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_1/query/credit_cards.gen.go b/tests/.expect/dal_1/query/credit_cards.gen.go index 9c280402..5cebbed8 100644 --- a/tests/.expect/dal_1/query/credit_cards.gen.go +++ b/tests/.expect/dal_1/query/credit_cards.gen.go @@ -88,6 +88,8 @@ func (c creditCard) TableName() string { return c.creditCardDo.TableName() } func (c creditCard) Alias() string { return c.creditCardDo.Alias() } +func (c creditCard) Columns(cols ...field.Expr) gen.Columns { return c.creditCardDo.Columns(cols...) } + func (c *creditCard) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_1/query/customers.gen.go b/tests/.expect/dal_1/query/customers.gen.go index 1c7d0b71..9a2586e7 100644 --- a/tests/.expect/dal_1/query/customers.gen.go +++ b/tests/.expect/dal_1/query/customers.gen.go @@ -80,6 +80,8 @@ func (c customer) TableName() string { return c.customerDo.TableName() } func (c customer) Alias() string { return c.customerDo.Alias() } +func (c customer) Columns(cols ...field.Expr) gen.Columns { return c.customerDo.Columns(cols...) } + func (c *customer) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_1/query/people.gen.go b/tests/.expect/dal_1/query/people.gen.go index 89e8a2c7..40795ccc 100644 --- a/tests/.expect/dal_1/query/people.gen.go +++ b/tests/.expect/dal_1/query/people.gen.go @@ -128,6 +128,8 @@ func (p person) TableName() string { return p.personDo.TableName() } func (p person) Alias() string { return p.personDo.Alias() } +func (p person) Columns(cols ...field.Expr) gen.Columns { return p.personDo.Columns(cols...) } + func (p *person) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := p.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_1/query/users.gen.go b/tests/.expect/dal_1/query/users.gen.go index ba0ff322..36ed2363 100644 --- a/tests/.expect/dal_1/query/users.gen.go +++ b/tests/.expect/dal_1/query/users.gen.go @@ -94,6 +94,8 @@ func (u user) TableName() string { return u.userDo.TableName() } func (u user) Alias() string { return u.userDo.Alias() } +func (u user) Columns(cols ...field.Expr) gen.Columns { return u.userDo.Columns(cols...) } + func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := u.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_2/query/banks.gen.go b/tests/.expect/dal_2/query/banks.gen.go index 3107c75b..599dfe52 100644 --- a/tests/.expect/dal_2/query/banks.gen.go +++ b/tests/.expect/dal_2/query/banks.gen.go @@ -77,6 +77,8 @@ func (b bank) TableName() string { return b.bankDo.TableName() } func (b bank) Alias() string { return b.bankDo.Alias() } +func (b bank) Columns(cols ...field.Expr) gen.Columns { return b.bankDo.Columns(cols...) } + func (b *bank) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := b.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_2/query/credit_cards.gen.go b/tests/.expect/dal_2/query/credit_cards.gen.go index a9b44e6b..55fd821f 100644 --- a/tests/.expect/dal_2/query/credit_cards.gen.go +++ b/tests/.expect/dal_2/query/credit_cards.gen.go @@ -88,6 +88,8 @@ func (c creditCard) TableName() string { return c.creditCardDo.TableName() } func (c creditCard) Alias() string { return c.creditCardDo.Alias() } +func (c creditCard) Columns(cols ...field.Expr) gen.Columns { return c.creditCardDo.Columns(cols...) } + func (c *creditCard) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_2/query/customers.gen.go b/tests/.expect/dal_2/query/customers.gen.go index d24a0788..3992060e 100644 --- a/tests/.expect/dal_2/query/customers.gen.go +++ b/tests/.expect/dal_2/query/customers.gen.go @@ -80,6 +80,8 @@ func (c customer) TableName() string { return c.customerDo.TableName() } func (c customer) Alias() string { return c.customerDo.Alias() } +func (c customer) Columns(cols ...field.Expr) gen.Columns { return c.customerDo.Columns(cols...) } + func (c *customer) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_2/query/people.gen.go b/tests/.expect/dal_2/query/people.gen.go index 6a79ab18..5348c749 100644 --- a/tests/.expect/dal_2/query/people.gen.go +++ b/tests/.expect/dal_2/query/people.gen.go @@ -128,6 +128,8 @@ func (p person) TableName() string { return p.personDo.TableName() } func (p person) Alias() string { return p.personDo.Alias() } +func (p person) Columns(cols ...field.Expr) gen.Columns { return p.personDo.Columns(cols...) } + func (p *person) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := p.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_2/query/users.gen.go b/tests/.expect/dal_2/query/users.gen.go index 6419ef89..7409e4f7 100644 --- a/tests/.expect/dal_2/query/users.gen.go +++ b/tests/.expect/dal_2/query/users.gen.go @@ -94,6 +94,8 @@ func (u user) TableName() string { return u.userDo.TableName() } func (u user) Alias() string { return u.userDo.Alias() } +func (u user) Columns(cols ...field.Expr) gen.Columns { return u.userDo.Columns(cols...) } + func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := u.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_3/query/banks.gen.go b/tests/.expect/dal_3/query/banks.gen.go index 0e6a28a2..643a66f6 100644 --- a/tests/.expect/dal_3/query/banks.gen.go +++ b/tests/.expect/dal_3/query/banks.gen.go @@ -77,6 +77,8 @@ func (b bank) TableName() string { return b.bankDo.TableName() } func (b bank) Alias() string { return b.bankDo.Alias() } +func (b bank) Columns(cols ...field.Expr) gen.Columns { return b.bankDo.Columns(cols...) } + func (b *bank) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := b.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_3/query/credit_cards.gen.go b/tests/.expect/dal_3/query/credit_cards.gen.go index feead3d4..f1c6d6b2 100644 --- a/tests/.expect/dal_3/query/credit_cards.gen.go +++ b/tests/.expect/dal_3/query/credit_cards.gen.go @@ -88,6 +88,8 @@ func (c creditCard) TableName() string { return c.creditCardDo.TableName() } func (c creditCard) Alias() string { return c.creditCardDo.Alias() } +func (c creditCard) Columns(cols ...field.Expr) gen.Columns { return c.creditCardDo.Columns(cols...) } + func (c *creditCard) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_3/query/customers.gen.go b/tests/.expect/dal_3/query/customers.gen.go index 6383e92b..79b87454 100644 --- a/tests/.expect/dal_3/query/customers.gen.go +++ b/tests/.expect/dal_3/query/customers.gen.go @@ -80,6 +80,8 @@ func (c customer) TableName() string { return c.customerDo.TableName() } func (c customer) Alias() string { return c.customerDo.Alias() } +func (c customer) Columns(cols ...field.Expr) gen.Columns { return c.customerDo.Columns(cols...) } + func (c *customer) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_3/query/people.gen.go b/tests/.expect/dal_3/query/people.gen.go index 169f918e..6a83be21 100644 --- a/tests/.expect/dal_3/query/people.gen.go +++ b/tests/.expect/dal_3/query/people.gen.go @@ -128,6 +128,8 @@ func (p person) TableName() string { return p.personDo.TableName() } func (p person) Alias() string { return p.personDo.Alias() } +func (p person) Columns(cols ...field.Expr) gen.Columns { return p.personDo.Columns(cols...) } + func (p *person) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := p.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_3/query/users.gen.go b/tests/.expect/dal_3/query/users.gen.go index 6f4ff9de..50f06783 100644 --- a/tests/.expect/dal_3/query/users.gen.go +++ b/tests/.expect/dal_3/query/users.gen.go @@ -94,6 +94,8 @@ func (u user) TableName() string { return u.userDo.TableName() } func (u user) Alias() string { return u.userDo.Alias() } +func (u user) Columns(cols ...field.Expr) gen.Columns { return u.userDo.Columns(cols...) } + func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := u.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_4/query/banks.gen.go b/tests/.expect/dal_4/query/banks.gen.go index cdf9111b..3b80694d 100644 --- a/tests/.expect/dal_4/query/banks.gen.go +++ b/tests/.expect/dal_4/query/banks.gen.go @@ -77,6 +77,8 @@ func (b bank) TableName() string { return b.bankDo.TableName() } func (b bank) Alias() string { return b.bankDo.Alias() } +func (b bank) Columns(cols ...field.Expr) gen.Columns { return b.bankDo.Columns(cols...) } + func (b *bank) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := b.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_4/query/credit_cards.gen.go b/tests/.expect/dal_4/query/credit_cards.gen.go index b6552a8a..df0dd28f 100644 --- a/tests/.expect/dal_4/query/credit_cards.gen.go +++ b/tests/.expect/dal_4/query/credit_cards.gen.go @@ -88,6 +88,8 @@ func (c creditCard) TableName() string { return c.creditCardDo.TableName() } func (c creditCard) Alias() string { return c.creditCardDo.Alias() } +func (c creditCard) Columns(cols ...field.Expr) gen.Columns { return c.creditCardDo.Columns(cols...) } + func (c *creditCard) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_4/query/customers.gen.go b/tests/.expect/dal_4/query/customers.gen.go index 9b726e65..59694ff5 100644 --- a/tests/.expect/dal_4/query/customers.gen.go +++ b/tests/.expect/dal_4/query/customers.gen.go @@ -80,6 +80,8 @@ func (c customer) TableName() string { return c.customerDo.TableName() } func (c customer) Alias() string { return c.customerDo.Alias() } +func (c customer) Columns(cols ...field.Expr) gen.Columns { return c.customerDo.Columns(cols...) } + func (c *customer) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := c.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_4/query/people.gen.go b/tests/.expect/dal_4/query/people.gen.go index 103ab9e3..14cf2f8a 100644 --- a/tests/.expect/dal_4/query/people.gen.go +++ b/tests/.expect/dal_4/query/people.gen.go @@ -128,6 +128,8 @@ func (p person) TableName() string { return p.personDo.TableName() } func (p person) Alias() string { return p.personDo.Alias() } +func (p person) Columns(cols ...field.Expr) gen.Columns { return p.personDo.Columns(cols...) } + func (p *person) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := p.fieldMap[fieldName] if !ok || _f == nil { diff --git a/tests/.expect/dal_4/query/users.gen.go b/tests/.expect/dal_4/query/users.gen.go index 3726d50c..8049fdcd 100644 --- a/tests/.expect/dal_4/query/users.gen.go +++ b/tests/.expect/dal_4/query/users.gen.go @@ -99,6 +99,8 @@ func (u user) TableName() string { return u.userDo.TableName() } func (u user) Alias() string { return u.userDo.Alias() } +func (u user) Columns(cols ...field.Expr) gen.Columns { return u.userDo.Columns(cols...) } + func (u *user) GetFieldByName(fieldName string) (field.OrderExpr, bool) { _f, ok := u.fieldMap[fieldName] if !ok || _f == nil {