Remove X funcs and add G funcs
This commit is contained in:
parent
edecf1b704
commit
2d732c727a
17 changed files with 183 additions and 183 deletions
|
@ -1,31 +1,31 @@
|
|||
{{- define "relationship_to_one_helper"}}
|
||||
// {{.Function.Name}}G pointed to by the foreign key.
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}G(selectCols ...string) (*{{.ForeignTable.NameGo}}, error) {
|
||||
return {{.Function.Receiver}}.{{.Function.Name}}(boil.GetDB(), selectCols...)
|
||||
}
|
||||
|
||||
// {{.Function.Name}}GP pointed to by the foreign key. Panics on error.
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}GP(selectCols ...string) *{{.ForeignTable.NameGo}} {
|
||||
o, err := {{.Function.Receiver}}.{{.Function.Name}}(boil.GetDB(), selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
// {{.Function.Name}}P pointed to by the foreign key with exeuctor. Panics on error.
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}P(exec boil.Executor, selectCols ...string) *{{.ForeignTable.NameGo}} {
|
||||
o, err := {{.Function.Receiver}}.{{.Function.Name}}(exec, selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
// {{.Function.Name}} pointed to by the foreign key.
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}(selectCols ...string) (*{{.ForeignTable.NameGo}}, error) {
|
||||
return {{.Function.Receiver}}.{{.Function.Name}}X(boil.GetDB(), selectCols...)
|
||||
}
|
||||
|
||||
// {{.Function.Name}}P pointed to by the foreign key. Panics on error.
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}P(selectCols ...string) *{{.ForeignTable.NameGo}} {
|
||||
o, err := {{.Function.Receiver}}.{{.Function.Name}}X(boil.GetDB(), selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
// {{.Function.Name}}XP pointed to by the foreign key with exeuctor. Panics on error.
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}XP(exec boil.Executor, selectCols ...string) *{{.ForeignTable.NameGo}} {
|
||||
o, err := {{.Function.Receiver}}.{{.Function.Name}}X(exec, selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
||||
return o
|
||||
}
|
||||
|
||||
// {{.Function.Name}}X pointed to by the foreign key.
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}X(exec boil.Executor, selectCols ...string) (*{{.ForeignTable.NameGo}}, error) {
|
||||
func ({{.Function.Receiver}} *{{.LocalTable.NameGo}}) {{.Function.Name}}(exec boil.Executor, selectCols ...string) (*{{.ForeignTable.NameGo}}, error) {
|
||||
{{.Function.Varname}} := &{{.ForeignTable.NameGo}}{}
|
||||
|
||||
selectColumns := `*`
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
{{- template "relationship_to_one_helper" (textsFromOneToOneRelationship $dot.PkgName $dot.Tables $table .) -}}
|
||||
{{- else -}}
|
||||
{{- $rel := textsFromRelationship $dot.Tables $table . -}}
|
||||
// {{$rel.Function.Name}} retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}}
|
||||
// {{$rel.Function.Name}}G retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}}
|
||||
{{- if not (eq $rel.Function.Name $rel.ForeignTable.NamePluralGo)}} via {{.ForeignColumn}} column{{- end}}.
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}(selectCols ...string) ({{$rel.ForeignTable.Slice}}, error) {
|
||||
return {{$rel.Function.Receiver}}.{{$rel.Function.Name}}X(boil.GetDB(), selectCols...)
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}G(selectCols ...string) ({{$rel.ForeignTable.Slice}}, error) {
|
||||
return {{$rel.Function.Receiver}}.{{$rel.Function.Name}}(boil.GetDB(), selectCols...)
|
||||
}
|
||||
|
||||
// {{$rel.Function.Name}}P panics on error. Retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}}
|
||||
// {{$rel.Function.Name}}GP panics on error. Retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}}
|
||||
{{- if not (eq $rel.Function.Name $rel.ForeignTable.NamePluralGo)}} via {{.ForeignColumn}} column{{- end}}.
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}P(selectCols ...string) {{$rel.ForeignTable.Slice}} {
|
||||
o, err := {{$rel.Function.Receiver}}.{{$rel.Function.Name}}X(boil.GetDB(), selectCols...)
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}GP(selectCols ...string) {{$rel.ForeignTable.Slice}} {
|
||||
o, err := {{$rel.Function.Receiver}}.{{$rel.Function.Name}}(boil.GetDB(), selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Na
|
|||
return o
|
||||
}
|
||||
|
||||
// {{$rel.Function.Name}}XP panics on error. Retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}} with an executor
|
||||
// {{$rel.Function.Name}}P panics on error. Retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}} with an executor
|
||||
{{- if not (eq $rel.Function.Name $rel.ForeignTable.NamePluralGo)}} via {{.ForeignColumn}} column{{- end}}.
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}XP(exec boil.Executor, selectCols ...string) {{$rel.ForeignTable.Slice}} {
|
||||
o, err := {{$rel.Function.Receiver}}.{{$rel.Function.Name}}X(exec, selectCols...)
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}P(exec boil.Executor, selectCols ...string) {{$rel.ForeignTable.Slice}} {
|
||||
o, err := {{$rel.Function.Receiver}}.{{$rel.Function.Name}}(exec, selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
@ -35,9 +35,9 @@ func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Na
|
|||
return o
|
||||
}
|
||||
|
||||
// {{$rel.Function.Name}}X retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}} with an executor
|
||||
// {{$rel.Function.Name}} retrieves all the {{$rel.LocalTable.NameSingular}}'s {{$rel.ForeignTable.NameHumanReadable}} with an executor
|
||||
{{- if not (eq $rel.Function.Name $rel.ForeignTable.NamePluralGo)}} via {{.ForeignColumn}} column{{- end}}.
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}X(exec boil.Executor, selectCols ...string) ({{$rel.ForeignTable.Slice}}, error) {
|
||||
func ({{$rel.Function.Receiver}} *{{$rel.LocalTable.NameGo}}) {{$rel.Function.Name}}(exec boil.Executor, selectCols ...string) ({{$rel.ForeignTable.Slice}}, error) {
|
||||
var ret {{$rel.ForeignTable.Slice}}
|
||||
|
||||
selectColumns := `"{{id 0}}".*`
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
|
||||
{{- $tableNamePlural := .Table.Name | plural | titleCase -}}
|
||||
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
||||
// {{$tableNamePlural}}All retrieves all records.
|
||||
func {{$tableNamePlural}}(mods ...qm.QueryMod) {{$varNameSingular}}Query {
|
||||
return {{$tableNamePlural}}X(boil.GetDB(), mods...)
|
||||
// {{$tableNamePlural}}G retrieves all records.
|
||||
func {{$tableNamePlural}}G(mods ...qm.QueryMod) {{$varNameSingular}}Query {
|
||||
return {{$tableNamePlural}}(boil.GetDB(), mods...)
|
||||
}
|
||||
|
||||
// {{$tableNamePlural}}X retrieves all the records using an executor.
|
||||
func {{$tableNamePlural}}X(exec boil.Executor, mods ...qm.QueryMod) {{$varNameSingular}}Query {
|
||||
mods = append(mods, qm.Table("{{.Table.Name}}"))
|
||||
return {{$varNameSingular}}Query{NewQueryX(exec, mods...)}
|
||||
// {{$tableNamePlural}} retrieves all the records using an executor.
|
||||
func {{$tableNamePlural}}(exec boil.Executor, mods ...qm.QueryMod) {{$varNameSingular}}Query {
|
||||
mods = append(mods, qm.From("{{.Table.Name}}"))
|
||||
return {{$varNameSingular}}Query{NewQuery(exec, mods...)}
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@
|
|||
{{- $colDefs := sqlColDefinitions .Table.Columns .Table.PKey.Columns -}}
|
||||
{{- $pkNames := $colDefs.Names | stringMap .StringFuncs.camelCase -}}
|
||||
{{- $pkArgs := joinSlices " " $pkNames $colDefs.Types | join ", "}}
|
||||
// {{$tableNameSingular}}Find retrieves a single record by ID.
|
||||
func {{$tableNameSingular}}Find({{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) {
|
||||
return {{$tableNameSingular}}FindX(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...)
|
||||
// {{$tableNameSingular}}FindG retrieves a single record by ID.
|
||||
func {{$tableNameSingular}}FindG({{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) {
|
||||
return {{$tableNameSingular}}Find(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...)
|
||||
}
|
||||
|
||||
// {{$tableNameSingular}}FindP retrieves a single record by ID, and panics on error.
|
||||
func {{$tableNameSingular}}FindP({{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
|
||||
o, err := {{$tableNameSingular}}FindX(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...)
|
||||
// {{$tableNameSingular}}FindGP retrieves a single record by ID, and panics on error.
|
||||
func {{$tableNameSingular}}FindGP({{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
|
||||
o, err := {{$tableNameSingular}}Find(boil.GetDB(), {{$pkNames | join ", "}}, selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
@ -19,17 +19,17 @@ func {{$tableNameSingular}}FindP({{$pkArgs}}, selectCols ...string) *{{$tableNam
|
|||
return o
|
||||
}
|
||||
|
||||
// {{$tableNameSingular}}FindX retrieves a single record by ID with an executor.
|
||||
func {{$tableNameSingular}}FindX(exec boil.Executor, {{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) {
|
||||
// {{$tableNameSingular}}Find retrieves a single record by ID with an executor.
|
||||
func {{$tableNameSingular}}Find(exec boil.Executor, {{$pkArgs}}, selectCols ...string) (*{{$tableNameSingular}}, error) {
|
||||
{{$varNameSingular}} := &{{$tableNameSingular}}{}
|
||||
|
||||
mods := []qm.QueryMod{
|
||||
qm.Select(selectCols...),
|
||||
qm.Table("{{.Table.Name}}"),
|
||||
qm.From("{{.Table.Name}}"),
|
||||
qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{$pkNames | join ", "}}),
|
||||
}
|
||||
|
||||
q := NewQueryX(exec, mods...)
|
||||
q := NewQuery(exec, mods...)
|
||||
|
||||
err := boil.ExecQueryOne(q).Scan(boil.GetStructPointers({{$varNameSingular}}, selectCols...)...)
|
||||
|
||||
|
@ -40,9 +40,9 @@ func {{$tableNameSingular}}FindX(exec boil.Executor, {{$pkArgs}}, selectCols ...
|
|||
return {{$varNameSingular}}, nil
|
||||
}
|
||||
|
||||
// {{$tableNameSingular}}FindXP retrieves a single record by ID with an executor, and panics on error.
|
||||
func {{$tableNameSingular}}FindXP(exec boil.Executor, {{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
|
||||
o, err := {{$tableNameSingular}}FindX(exec, {{$pkNames | join ", "}}, selectCols...)
|
||||
// {{$tableNameSingular}}FindP retrieves a single record by ID with an executor, and panics on error.
|
||||
func {{$tableNameSingular}}FindP(exec boil.Executor, {{$pkArgs}}, selectCols ...string) *{{$tableNameSingular}} {
|
||||
o, err := {{$tableNameSingular}}Find(exec, {{$pkNames | join ", "}}, selectCols...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
|
||||
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
||||
// Insert a single record.
|
||||
func (o *{{$tableNameSingular}}) Insert(whitelist ... string) error {
|
||||
return o.InsertX(boil.GetDB(), whitelist...)
|
||||
// InsertG a single record.
|
||||
func (o *{{$tableNameSingular}}) InsertG(whitelist ... string) error {
|
||||
return o.Insert(boil.GetDB(), whitelist...)
|
||||
}
|
||||
|
||||
// InsertP a single record, and panics on error.
|
||||
func (o *{{$tableNameSingular}}) InsertP(whitelist ... string) {
|
||||
if err := o.InsertX(boil.GetDB(), whitelist...); err != nil {
|
||||
// InsertGP a single record, and panics on error.
|
||||
func (o *{{$tableNameSingular}}) InsertGP(whitelist ... string) {
|
||||
if err := o.Insert(boil.GetDB(), whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
||||
// InsertX a single record using an executor.
|
||||
func (o *{{$tableNameSingular}}) InsertX(exec boil.Executor, whitelist ... string) error {
|
||||
// Insert a single record using an executor.
|
||||
func (o *{{$tableNameSingular}}) Insert(exec boil.Executor, whitelist ... string) error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{.Table.Name}} provided for insertion")
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ func (o *{{$tableNameSingular}}) InsertX(exec boil.Executor, whitelist ... strin
|
|||
return nil
|
||||
}
|
||||
|
||||
// InsertXP a single record using an executor, and panics on error.
|
||||
func (o *{{$tableNameSingular}}) InsertXP(exec boil.Executor, whitelist ... string) {
|
||||
if err := o.InsertX(exec, whitelist...); err != nil {
|
||||
// InsertP a single record using an executor, and panics on error.
|
||||
func (o *{{$tableNameSingular}}) InsertP(exec boil.Executor, whitelist ... string) {
|
||||
if err := o.Insert(exec, whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,50 +3,50 @@
|
|||
{{- $colDefs := sqlColDefinitions .Table.Columns .Table.PKey.Columns -}}
|
||||
{{- $pkNames := $colDefs.Names | stringMap .StringFuncs.camelCase -}}
|
||||
{{- $pkArgs := joinSlices " " $pkNames $colDefs.Types | join ", "}}
|
||||
// Update a single {{$tableNameSingular}} record.
|
||||
// Update takes a whitelist of column names that should be updated.
|
||||
// UpdateG a single {{$tableNameSingular}} record.
|
||||
// UpdateG takes a whitelist of column names that should be updated.
|
||||
// The primary key will be used to find the record to update.
|
||||
func (o *{{$tableNameSingular}}) Update(whitelist ...string) error {
|
||||
return o.UpdateX(boil.GetDB(), whitelist...)
|
||||
func (o *{{$tableNameSingular}}) UpdateG(whitelist ...string) error {
|
||||
return o.Update(boil.GetDB(), whitelist...)
|
||||
}
|
||||
|
||||
// Update a single {{$tableNameSingular}} record.
|
||||
// UpdateP takes a whitelist of column names that should be updated.
|
||||
// UpdateGP a single {{$tableNameSingular}} record.
|
||||
// UpdateGP takes a whitelist of column names that should be updated.
|
||||
// The primary key will be used to find the record to update.
|
||||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpdateP(whitelist ...string) {
|
||||
if err := o.UpdateX(boil.GetDB(), whitelist...); err != nil {
|
||||
func (o *{{$tableNameSingular}}) UpdateGP(whitelist ...string) {
|
||||
if err := o.Update(boil.GetDB(), whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateX uses an executor to update the {{$tableNameSingular}}.
|
||||
func (o *{{$tableNameSingular}}) UpdateX(exec boil.Executor, whitelist ... string) error {
|
||||
return o.UpdateAtX(exec, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}, whitelist...)
|
||||
// Update uses an executor to update the {{$tableNameSingular}}.
|
||||
func (o *{{$tableNameSingular}}) Update(exec boil.Executor, whitelist ... string) error {
|
||||
return o.UpdateAt(exec, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}, whitelist...)
|
||||
}
|
||||
|
||||
// UpdateXP uses an executor to update the {{$tableNameSingular}}, and panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpdateXP(exec boil.Executor, whitelist ... string) {
|
||||
err := o.UpdateAtX(exec, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}, whitelist...)
|
||||
// UpdateP uses an executor to update the {{$tableNameSingular}}, and panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpdateP(exec boil.Executor, whitelist ... string) {
|
||||
err := o.UpdateAt(exec, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}, whitelist...)
|
||||
if err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateAt updates the {{$tableNameSingular}} using the primary key to find the row to update.
|
||||
func (o *{{$tableNameSingular}}) UpdateAt({{$pkArgs}}, whitelist ...string) error {
|
||||
return o.UpdateAtX(boil.GetDB(), {{$pkNames | join ", "}}, whitelist...)
|
||||
// UpdateAtG updates the {{$tableNameSingular}} using the primary key to find the row to update.
|
||||
func (o *{{$tableNameSingular}}) UpdateAtG({{$pkArgs}}, whitelist ...string) error {
|
||||
return o.UpdateAt(boil.GetDB(), {{$pkNames | join ", "}}, whitelist...)
|
||||
}
|
||||
|
||||
// UpdateAtP updates the {{$tableNameSingular}} using the primary key to find the row to update. Panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpdateAtP({{$pkArgs}}, whitelist ...string) {
|
||||
if err := o.UpdateAtX(boil.GetDB(), {{$pkNames | join ", "}}, whitelist...); err != nil {
|
||||
// UpdateAtGP updates the {{$tableNameSingular}} using the primary key to find the row to update. Panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpdateAtGP({{$pkArgs}}, whitelist ...string) {
|
||||
if err := o.UpdateAt(boil.GetDB(), {{$pkNames | join ", "}}, whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateAtX uses an executor to update the {{$tableNameSingular}} using the primary key to find the row to update.
|
||||
func (o *{{$tableNameSingular}}) UpdateAtX(exec boil.Executor, {{$pkArgs}}, whitelist ...string) error {
|
||||
// UpdateAt uses an executor to update the {{$tableNameSingular}} using the primary key to find the row to update.
|
||||
func (o *{{$tableNameSingular}}) UpdateAt(exec boil.Executor, {{$pkArgs}}, whitelist ...string) error {
|
||||
if err := o.doBeforeUpdateHooks(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -82,10 +82,10 @@ func (o *{{$tableNameSingular}}) UpdateAtX(exec boil.Executor, {{$pkArgs}}, whit
|
|||
return nil
|
||||
}
|
||||
|
||||
// UpdateAtXP uses an executor to update the {{$tableNameSingular}} using the primary key to find the row to update.
|
||||
// UpdateAtP uses an executor to update the {{$tableNameSingular}} using the primary key to find the row to update.
|
||||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}) UpdateAtXP(exec boil.Executor, {{$pkArgs}}, whitelist ...string) {
|
||||
if err := o.UpdateAtX(exec, {{$pkNames | join ", "}}, whitelist...); err != nil {
|
||||
func (o *{{$tableNameSingular}}) UpdateAtP(exec boil.Executor, {{$pkArgs}}, whitelist ...string) {
|
||||
if err := o.UpdateAt(exec, {{$pkNames | join ", "}}, whitelist...); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
{{- $tableNameSingular := .Table.Name | singular | titleCase -}}
|
||||
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
||||
// Delete deletes a single {{$tableNameSingular}} record.
|
||||
// Delete will match against the primary key column to find the record to delete.
|
||||
func (o *{{$tableNameSingular}}) Delete() error {
|
||||
// DeleteG deletes a single {{$tableNameSingular}} record.
|
||||
// DeleteG will match against the primary key column to find the record to delete.
|
||||
func (o *{{$tableNameSingular}}) DeleteG() error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} provided for deletion")
|
||||
}
|
||||
|
||||
return o.DeleteX(boil.GetDB())
|
||||
return o.Delete(boil.GetDB())
|
||||
}
|
||||
|
||||
// DeleteP deletes a single {{$tableNameSingular}} record.
|
||||
// DeleteP will match against the primary key column to find the record to delete.
|
||||
// DeleteGP deletes a single {{$tableNameSingular}} record.
|
||||
// DeleteGP will match against the primary key column to find the record to delete.
|
||||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}) DeleteP() {
|
||||
if err := o.Delete(); err != nil {
|
||||
func (o *{{$tableNameSingular}}) DeleteGP() {
|
||||
if err := o.DeleteG(); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteX deletes a single {{$tableNameSingular}} record with an executor.
|
||||
// DeleteX will match against the primary key column to find the record to delete.
|
||||
func (o *{{$tableNameSingular}}) DeleteX(exec boil.Executor) error {
|
||||
// Delete deletes a single {{$tableNameSingular}} record with an executor.
|
||||
// Delete will match against the primary key column to find the record to delete.
|
||||
func (o *{{$tableNameSingular}}) Delete(exec boil.Executor) error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} provided for deletion")
|
||||
}
|
||||
|
@ -29,11 +29,11 @@ func (o *{{$tableNameSingular}}) DeleteX(exec boil.Executor) error {
|
|||
var mods []qm.QueryMod
|
||||
|
||||
mods = append(mods,
|
||||
qm.Table("{{.Table.Name}}"),
|
||||
qm.From("{{.Table.Name}}"),
|
||||
qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}}),
|
||||
)
|
||||
|
||||
query := NewQueryX(exec, mods...)
|
||||
query := NewQuery(exec, mods...)
|
||||
boil.SetDelete(query)
|
||||
|
||||
_, err := boil.ExecQuery(query)
|
||||
|
@ -44,11 +44,11 @@ func (o *{{$tableNameSingular}}) DeleteX(exec boil.Executor) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeleteXP deletes a single {{$tableNameSingular}} record with an executor.
|
||||
// DeleteXP will match against the primary key column to find the record to delete.
|
||||
// DeleteP deletes a single {{$tableNameSingular}} record with an executor.
|
||||
// DeleteP will match against the primary key column to find the record to delete.
|
||||
// Panics on error.
|
||||
func (o *{{$tableNameSingular}}) DeleteXP(exec boil.Executor) {
|
||||
if err := o.DeleteX(exec); err != nil {
|
||||
func (o *{{$tableNameSingular}}) DeleteP(exec boil.Executor) {
|
||||
if err := o.Delete(exec); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
@ -76,23 +76,23 @@ func (o {{$varNameSingular}}Query) DeleteAllP() {
|
|||
}
|
||||
}
|
||||
|
||||
// DeleteAll deletes all rows in the slice.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAll() error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all")
|
||||
}
|
||||
return o.DeleteAllX(boil.GetDB())
|
||||
}
|
||||
|
||||
// DeleteAll deletes all rows in the slice.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllP() {
|
||||
if err := o.DeleteAll(); err != nil {
|
||||
// DeleteAll deletes all rows in the slice, and panics on error.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllGP() {
|
||||
if err := o.DeleteAllG(); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
||||
// DeleteAllX deletes all rows in the slice with an executor.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllX(exec boil.Executor) error {
|
||||
// DeleteAllG deletes all rows in the slice.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllG() error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all")
|
||||
}
|
||||
return o.DeleteAll(boil.GetDB())
|
||||
}
|
||||
|
||||
// DeleteAll deletes all rows in the slice with an executor.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAll(exec boil.Executor) error {
|
||||
if o == nil {
|
||||
return errors.New("{{.PkgName}}: no {{$tableNameSingular}} slice provided for delete all")
|
||||
}
|
||||
|
@ -103,11 +103,11 @@ func (o {{$tableNameSingular}}Slice) DeleteAllX(exec boil.Executor) error {
|
|||
in := boil.WherePrimaryKeyIn(len(o), {{.Table.PKey.Columns | stringMap .StringFuncs.quoteWrap | join ", "}})
|
||||
|
||||
mods = append(mods,
|
||||
qm.Table("{{.Table.Name}}"),
|
||||
qm.From("{{.Table.Name}}"),
|
||||
qm.Where(in, args...),
|
||||
)
|
||||
|
||||
query := NewQueryX(exec, mods...)
|
||||
query := NewQuery(exec, mods...)
|
||||
boil.SetDelete(query)
|
||||
|
||||
_, err := boil.ExecQuery(query)
|
||||
|
@ -121,9 +121,9 @@ func (o {{$tableNameSingular}}Slice) DeleteAllX(exec boil.Executor) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// DeleteAllXP deletes all rows in the slice with an executor, and panics on error.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllXP(exec boil.Executor) {
|
||||
if err := o.DeleteAllX(exec); err != nil {
|
||||
// DeleteAllP deletes all rows in the slice with an executor, and panics on error.
|
||||
func (o {{$tableNameSingular}}Slice) DeleteAllP(exec boil.Executor) {
|
||||
if err := o.DeleteAll(exec); err != nil {
|
||||
panic(boil.WrapErr(err))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
// M type is for providing where filters to Where helpers.
|
||||
type M map[string]interface{}
|
||||
|
||||
// NewQuery initializes a new Query using the passed in QueryMods
|
||||
func NewQuery(mods ...qm.QueryMod) *boil.Query {
|
||||
return NewQueryX(boil.GetDB(), mods...)
|
||||
// NewQueryG initializes a new Query using the passed in QueryMods
|
||||
func NewQueryG(mods ...qm.QueryMod) *boil.Query {
|
||||
return NewQuery(boil.GetDB(), mods...)
|
||||
}
|
||||
|
||||
// NewQueryX initializes a new Query using the passed in QueryMods
|
||||
func NewQueryX(exec boil.Executor, mods ...qm.QueryMod) *boil.Query {
|
||||
// NewQuery initializes a new Query using the passed in QueryMods
|
||||
func NewQuery(exec boil.Executor, mods ...qm.QueryMod) *boil.Query {
|
||||
q := &boil.Query{}
|
||||
boil.SetExecutor(q, exec)
|
||||
qm.Apply(q, mods...)
|
||||
|
|
|
@ -13,21 +13,21 @@ func Test{{$tableNamePlural}}(t *testing.T) {
|
|||
|
||||
// insert two random objects to test DeleteAll
|
||||
for i := 0; i < len(o); i++ {
|
||||
err = o[i].Insert()
|
||||
err = o[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
// Delete all rows to give a clean slate
|
||||
err = {{$tableNamePlural}}().DeleteAll()
|
||||
err = {{$tableNamePlural}}G().DeleteAll()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to delete all from {{$tableNamePlural}}: %s", err)
|
||||
}
|
||||
|
||||
// Check number of rows in table to ensure DeleteAll was successful
|
||||
var c int64
|
||||
c, err = {{$tableNamePlural}}().Count()
|
||||
c, err = {{$tableNamePlural}}G().Count()
|
||||
|
||||
if c != 0 {
|
||||
t.Errorf("Expected {{.Table.Name}} table to be empty, but got %d rows", c)
|
||||
|
@ -39,20 +39,20 @@ func Test{{$tableNamePlural}}(t *testing.T) {
|
|||
}
|
||||
|
||||
for i := 0; i < len(o); i++ {
|
||||
err = o[i].Insert()
|
||||
err = o[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure Count is valid
|
||||
c, err = {{$tableNamePlural}}().Count()
|
||||
c, err = {{$tableNamePlural}}G().Count()
|
||||
if c != 3 {
|
||||
t.Errorf("Expected {{.Table.Name}} table to have 3 rows, but got %d", c)
|
||||
}
|
||||
|
||||
// Attempt to retrieve all objects
|
||||
res, err := {{$tableNamePlural}}().All()
|
||||
res, err := {{$tableNamePlural}}G().All()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to retrieve all {{$tableNamePlural}}, err: %s", err)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{{- $varNameSingular := .Table.Name | singular | camelCase -}}
|
||||
func {{$varNamePlural}}DeleteAllRows(t *testing.T) {
|
||||
// Delete all rows to give a clean slate
|
||||
err := {{$tableNamePlural}}().DeleteAll()
|
||||
err := {{$tableNamePlural}}G().DeleteAll()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to delete all from {{$tableNamePlural}}: %s", err)
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func Test{{$tableNamePlural}}QueryDeleteAll(t *testing.T) {
|
|||
{{$varNamePlural}}DeleteAllRows(t)
|
||||
|
||||
// Check number of rows in table to ensure DeleteAll was successful
|
||||
c, err = {{$tableNamePlural}}().Count()
|
||||
c, err = {{$tableNamePlural}}G().Count()
|
||||
|
||||
if c != 0 {
|
||||
t.Errorf("Expected 0 rows after ObjDeleteAllRows() call, but got %d rows", c)
|
||||
|
@ -32,20 +32,20 @@ func Test{{$tableNamePlural}}QueryDeleteAll(t *testing.T) {
|
|||
|
||||
// insert random columns to test DeleteAll
|
||||
for i := 0; i < len(o); i++ {
|
||||
err = o[i].Insert()
|
||||
err = o[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
// Test DeleteAll() query function
|
||||
err = {{$tableNamePlural}}().DeleteAll()
|
||||
err = {{$tableNamePlural}}G().DeleteAll()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to delete all from {{$tableNamePlural}}: %s", err)
|
||||
}
|
||||
|
||||
// Check number of rows in table to ensure DeleteAll was successful
|
||||
c, err = {{$tableNamePlural}}().Count()
|
||||
c, err = {{$tableNamePlural}}G().Count()
|
||||
|
||||
if c != 0 {
|
||||
t.Errorf("Expected 0 rows after Obj().DeleteAll() call, but got %d rows", c)
|
||||
|
@ -63,19 +63,19 @@ func Test{{$tableNamePlural}}SliceDeleteAll(t *testing.T) {
|
|||
}
|
||||
|
||||
for i := 0; i < len(o); i++ {
|
||||
err = o[i].Insert()
|
||||
err = o[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
// test DeleteAll slice function
|
||||
if err = o.DeleteAll(); err != nil {
|
||||
if err = o.DeleteAllG(); err != nil {
|
||||
t.Errorf("Unable to objSlice.DeleteAll(): %s", err)
|
||||
}
|
||||
|
||||
// Check number of rows in table to ensure DeleteAll was successful
|
||||
c, err = {{$tableNamePlural}}().Count()
|
||||
c, err = {{$tableNamePlural}}G().Count()
|
||||
|
||||
if c != 0 {
|
||||
t.Errorf("Expected 0 rows after objSlice.DeleteAll() call, but got %d rows", c)
|
||||
|
@ -93,26 +93,26 @@ func Test{{$tableNamePlural}}Delete(t *testing.T) {
|
|||
}
|
||||
|
||||
for i := 0; i < len(o); i++ {
|
||||
err = o[i].Insert()
|
||||
err = o[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
o[0].Delete()
|
||||
o[0].DeleteG()
|
||||
|
||||
// Check number of rows in table to ensure DeleteAll was successful
|
||||
c, err = {{$tableNamePlural}}().Count()
|
||||
c, err = {{$tableNamePlural}}G().Count()
|
||||
|
||||
if c != 2 {
|
||||
t.Errorf("Expected 2 rows after obj.Delete() call, but got %d rows", c)
|
||||
}
|
||||
|
||||
o[1].Delete()
|
||||
o[2].Delete()
|
||||
o[1].DeleteG()
|
||||
o[2].DeleteG()
|
||||
|
||||
// Check number of rows in table to ensure Delete worked for all rows
|
||||
c, err = {{$tableNamePlural}}().Count()
|
||||
c, err = {{$tableNamePlural}}G().Count()
|
||||
|
||||
if c != 0 {
|
||||
t.Errorf("Expected 0 rows after all obj.Delete() calls, but got %d rows", c)
|
||||
|
|
|
@ -12,7 +12,7 @@ func Test{{$tableNamePlural}}Find(t *testing.T) {
|
|||
}
|
||||
|
||||
for i := 0; i < len(o); i++ {
|
||||
if err = o[i].Insert(); err != nil {
|
||||
if err = o[i].InsertG(); err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ func Test{{$tableNamePlural}}Find(t *testing.T) {
|
|||
j := make({{$tableNameSingular}}Slice, 3)
|
||||
// Perform all Find queries and assign result objects to slice for comparison
|
||||
for i := 0; i < len(j); i++ {
|
||||
j[i], err = {{$tableNameSingular}}Find({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[i]." | join ", "}})
|
||||
j[i], err = {{$tableNameSingular}}FindG({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[i]." | join ", "}})
|
||||
{{$varNameSingular}}CompareVals(o[i], j[i], t)
|
||||
}
|
||||
|
||||
f, err := {{$tableNameSingular}}Find({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[0]." | join ", "}}, {{$varNameSingular}}PrimaryKeyColumns...)
|
||||
f, err := {{$tableNameSingular}}FindG({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[0]." | join ", "}}, {{$varNameSingular}}PrimaryKeyColumns...)
|
||||
{{range $key, $value := .Table.PKey.Columns}}
|
||||
if o[0].{{titleCase $value}} != f.{{titleCase $value}} {
|
||||
t.Errorf("Expected primary key values to match, {{titleCase $value}} did not match")
|
||||
|
|
|
@ -11,13 +11,13 @@ func Test{{$tableNamePlural}}Bind(t *testing.T) {
|
|||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
if err = o.Insert(); err != nil {
|
||||
if err = o.InsertG(); err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o, err)
|
||||
}
|
||||
|
||||
j := {{$tableNameSingular}}{}
|
||||
|
||||
err = {{$tableNamePlural}}(qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})).Bind(&j)
|
||||
err = {{$tableNamePlural}}G(qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o." | join ", "}})).Bind(&j)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to call Bind on {{$tableNameSingular}} single object: %s", err)
|
||||
}
|
||||
|
@ -34,14 +34,14 @@ func Test{{$tableNamePlural}}Bind(t *testing.T) {
|
|||
|
||||
// insert random columns to test DeleteAll
|
||||
for i := 0; i < len(y); i++ {
|
||||
err = y[i].Insert()
|
||||
err = y[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", y[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
k := {{$tableNameSingular}}Slice{}
|
||||
err = {{$tableNamePlural}}().Bind(&k)
|
||||
err = {{$tableNamePlural}}G().Bind(&k)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to call Bind on {{$tableNameSingular}} slice of objects: %s", err)
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ func Test{{$tableNamePlural}}One(t *testing.T) {
|
|||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
if err = o.Insert(); err != nil {
|
||||
if err = o.InsertG(); err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o, err)
|
||||
}
|
||||
|
||||
j, err := {{$tableNamePlural}}().One()
|
||||
j, err := {{$tableNamePlural}}G().One()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to fetch One {{$tableNameSingular}} result:\n#%v\nErr: %s", j, err)
|
||||
}
|
||||
|
@ -89,13 +89,13 @@ func Test{{$tableNamePlural}}All(t *testing.T) {
|
|||
|
||||
// insert random columns to test DeleteAll
|
||||
for i := 0; i < len(o); i++ {
|
||||
err = o[i].Insert()
|
||||
err = o[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
j, err := {{$tableNamePlural}}().All()
|
||||
j, err := {{$tableNamePlural}}G().All()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to fetch All {{$tableNameSingular}} results: %s", err)
|
||||
}
|
||||
|
@ -121,13 +121,13 @@ func Test{{$tableNamePlural}}Count(t *testing.T) {
|
|||
|
||||
// insert random columns to test Count
|
||||
for i := 0; i < len(o); i++ {
|
||||
err = o[i].Insert()
|
||||
err = o[i].InsertG()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
||||
c, err := {{$tableNamePlural}}().Count()
|
||||
c, err := {{$tableNamePlural}}G().Count()
|
||||
if err != nil {
|
||||
t.Errorf("Unable to count query {{$tableNameSingular}}: %s", err)
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func Test{{$tableNamePlural}}Insert(t *testing.T) {
|
|||
}
|
||||
|
||||
for i := 0; i < len(o); i++ {
|
||||
if err = o[i].Insert(); err != nil {
|
||||
if err = o[i].InsertG(); err != nil {
|
||||
t.Errorf("Unable to insert {{$tableNameSingular}}:\n%#v\nErr: %s", o[i], err)
|
||||
}
|
||||
}
|
||||
|
@ -30,14 +30,14 @@ func Test{{$tableNamePlural}}Insert(t *testing.T) {
|
|||
j := make({{$tableNameSingular}}Slice, 3)
|
||||
// Perform all Find queries and assign result objects to slice for comparison
|
||||
for i := 0; i < len(j); i++ {
|
||||
j[i], err = {{$tableNameSingular}}Find({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[i]." | join ", "}})
|
||||
j[i], err = {{$tableNameSingular}}FindG({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "o[i]." | join ", "}})
|
||||
{{$varNameSingular}}CompareVals(o[i], j[i], t)
|
||||
}
|
||||
|
||||
{{$varNamePlural}}DeleteAllRows(t)
|
||||
|
||||
item := &{{$tableNameSingular}}{}
|
||||
if err = item.Insert(); err != nil {
|
||||
if err = item.InsertG(); err != nil {
|
||||
t.Errorf("Unable to insert zero-value item {{$tableNameSingular}}:\n%#v\nErr: %s", item, err)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ func Test{{$rel.LocalTable.NameGo}}ToMany{{$rel.Function.Name}}(t *testing.T) {
|
|||
var a {{$rel.LocalTable.NameGo}}
|
||||
var b, c {{$rel.ForeignTable.NameGo}}
|
||||
|
||||
if err := a.InsertX(tx); err != nil {
|
||||
if err := a.Insert(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -32,10 +32,10 @@ func Test{{$rel.LocalTable.NameGo}}ToMany{{$rel.Function.Name}}(t *testing.T) {
|
|||
b.{{$rel.Function.ForeignAssignment}} = a.{{$rel.Function.LocalAssignment}}
|
||||
c.{{$rel.Function.ForeignAssignment}} = a.{{$rel.Function.LocalAssignment}}
|
||||
{{- end}}
|
||||
if err = b.InsertX(tx); err != nil {
|
||||
if err = b.Insert(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = c.InsertX(tx); err != nil {
|
||||
if err = c.Insert(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func Test{{$rel.LocalTable.NameGo}}ToMany{{$rel.Function.Name}}(t *testing.T) {
|
|||
{{end}}
|
||||
|
||||
{{$varname := $rel.ForeignTable.NamePluralGo | toLower -}}
|
||||
{{$varname}}, err := a.{{$rel.Function.Name}}X(tx)
|
||||
{{$varname}}, err := a.{{$rel.Function.Name}}(tx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -14,26 +14,26 @@ func Test{{.LocalTable.NameGo}}ToOne{{.ForeignTable.NameGo}}_{{.Function.Name}}(
|
|||
|
||||
|
||||
{{if not .Function.ReverseInserts -}}
|
||||
if err := foreign.InsertX(tx); err != nil {
|
||||
if err := foreign.Insert(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
local.{{.Function.LocalAssignment}} = foreign.{{.Function.ForeignAssignment}}
|
||||
if err := local.InsertX(tx); err != nil {
|
||||
if err := local.Insert(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
{{else -}}
|
||||
if err := local.InsertX(tx); err != nil {
|
||||
if err := local.Insert(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
foreign.{{.Function.ForeignAssignment}} = local.{{.Function.LocalAssignment}}
|
||||
if err := foreign.InsertX(tx); err != nil {
|
||||
if err := foreign.Insert(tx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
{{end -}}
|
||||
|
||||
check, err := local.{{.Function.Name}}X(tx)
|
||||
check, err := local.{{.Function.Name}}(tx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -26,11 +26,11 @@ func Test{{$tableNamePlural}}Select(t *testing.T) {
|
|||
t.Errorf("Unable to randomize {{$tableNameSingular}} struct: %s", err)
|
||||
}
|
||||
|
||||
if err = item.Insert(); err != nil {
|
||||
if err = item.InsertG(); err != nil {
|
||||
t.Errorf("Unable to insert item {{$tableNameSingular}}:\n%#v\nErr: %s", item, err)
|
||||
}
|
||||
|
||||
err = {{$tableNamePlural}}(qm.Select({{$varNameSingular}}AutoIncrementColumns...), qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "item." | join ", "}})).Bind(x)
|
||||
err = {{$tableNamePlural}}G(qm.Select({{$varNameSingular}}AutoIncrementColumns...), qm.Where(`{{whereClause .Table.PKey.Columns 1}}`, {{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "item." | join ", "}})).Bind(x)
|
||||
if err != nil {
|
||||
t.Errorf("Unable to select insert results with bind: %s", err)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ func Test{{$tableNamePlural}}Update(t *testing.T) {
|
|||
var err error
|
||||
|
||||
item := {{$tableNameSingular}}{}
|
||||
if err = item.Insert(); err != nil {
|
||||
if err = item.InsertG(); err != nil {
|
||||
t.Errorf("Unable to insert zero-value item {{$tableNameSingular}}:\n%#v\nErr: %s", item, err)
|
||||
}
|
||||
|
||||
|
@ -17,12 +17,12 @@ func Test{{$tableNamePlural}}Update(t *testing.T) {
|
|||
}
|
||||
|
||||
whitelist := boil.SetComplement({{$varNameSingular}}Columns, {{$varNameSingular}}AutoIncrementColumns)
|
||||
if err = item.Update(whitelist...); err != nil {
|
||||
if err = item.UpdateG(whitelist...); err != nil {
|
||||
t.Errorf("Unable to update {{$tableNameSingular}}: %s", err)
|
||||
}
|
||||
|
||||
var j *{{$tableNameSingular}}
|
||||
j, err = {{$tableNameSingular}}Find({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "item." | join ", "}})
|
||||
j, err = {{$tableNameSingular}}FindG({{.Table.PKey.Columns | stringMap .StringFuncs.titleCase | prefixStringSlice "item." | join ", "}})
|
||||
if err != nil {
|
||||
t.Errorf("Unable to find {{$tableNameSingular}} row: %s", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue