just use interfaces
This commit is contained in:
parent
544ff7afdd
commit
55f42bc038
3 changed files with 4 additions and 10 deletions
|
@ -182,7 +182,6 @@ func newImporter() importer {
|
||||||
imp.Singleton = mapImports{
|
imp.Singleton = mapImports{
|
||||||
"boil_queries": imports{
|
"boil_queries": imports{
|
||||||
standard: importList{
|
standard: importList{
|
||||||
`"database/sql"`,
|
|
||||||
`"fmt"`,
|
`"fmt"`,
|
||||||
`"reflect"`,
|
`"reflect"`,
|
||||||
`"strconv"`,
|
`"strconv"`,
|
||||||
|
|
|
@ -69,12 +69,7 @@ func Merge{{$tableNamePlural}}(exec boil.Executor, primaryID uint64, secondaryID
|
||||||
{{- end }}
|
{{- end }}
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlTx, ok := tx.(*sql.Tx)
|
err = mergeModels(tx, primaryID, secondaryID, foreignKeys, conflictingKeys)
|
||||||
if !ok {
|
|
||||||
return errors.New("tx must be an sql.Tx")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = mergeModels(sqlTx, primaryID, secondaryID, foreignKeys, conflictingKeys)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ func NewQuery(exec boil.Executor, mods ...qm.QueryMod) *queries.Query {
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
func mergeModels(tx *sql.Tx, primaryID uint64, secondaryID uint64, foreignKeys []foreignKey, conflictingKeys []conflictingUniqueKey) error {
|
func mergeModels(tx boil.Executor, primaryID uint64, secondaryID uint64, foreignKeys []foreignKey, conflictingKeys []conflictingUniqueKey) error {
|
||||||
if len(foreignKeys) < 1 {
|
if len(foreignKeys) < 1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func mergeModels(tx *sql.Tx, primaryID uint64, secondaryID uint64, foreignKeys [
|
||||||
return checkMerge(tx, foreignKeys)
|
return checkMerge(tx, foreignKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteConflictsBeforeMerge(tx *sql.Tx, conflict conflictingUniqueKey, primaryID uint64, secondaryID uint64) error {
|
func deleteConflictsBeforeMerge(tx boil.Executor, conflict conflictingUniqueKey, primaryID uint64, secondaryID uint64) error {
|
||||||
conflictingColumns := strmangle.SetComplement(conflict.columns, []string{conflict.objectIdColumn})
|
conflictingColumns := strmangle.SetComplement(conflict.columns, []string{conflict.objectIdColumn})
|
||||||
|
|
||||||
if len(conflictingColumns) < 1 {
|
if len(conflictingColumns) < 1 {
|
||||||
|
@ -98,7 +98,7 @@ func deleteConflictsBeforeMerge(tx *sql.Tx, conflict conflictingUniqueKey, prima
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkMerge(tx *sql.Tx, foreignKeys []foreignKey) error {
|
func checkMerge(tx boil.Executor, foreignKeys []foreignKey) error {
|
||||||
uniqueColumns := []interface{}{}
|
uniqueColumns := []interface{}{}
|
||||||
uniqueColumnNames := map[string]bool{}
|
uniqueColumnNames := map[string]bool{}
|
||||||
handledTablesColumns := map[string]bool{}
|
handledTablesColumns := map[string]bool{}
|
||||||
|
|
Loading…
Add table
Reference in a new issue