just use interfaces

This commit is contained in:
Alex Grintsvayg 2017-08-24 11:58:13 -04:00
parent 544ff7afdd
commit 55f42bc038
3 changed files with 4 additions and 10 deletions

View file

@ -182,7 +182,6 @@ func newImporter() importer {
imp.Singleton = mapImports{
"boil_queries": imports{
standard: importList{
`"database/sql"`,
`"fmt"`,
`"reflect"`,
`"strconv"`,

View file

@ -69,12 +69,7 @@ func Merge{{$tableNamePlural}}(exec boil.Executor, primaryID uint64, secondaryID
{{- end }}
}
sqlTx, ok := tx.(*sql.Tx)
if !ok {
return errors.New("tx must be an sql.Tx")
}
err = mergeModels(sqlTx, primaryID, secondaryID, foreignKeys, conflictingKeys)
err = mergeModels(tx, primaryID, secondaryID, foreignKeys, conflictingKeys)
if err != nil {
return err
}

View file

@ -20,7 +20,7 @@ func NewQuery(exec boil.Executor, mods ...qm.QueryMod) *queries.Query {
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 {
return nil
}
@ -48,7 +48,7 @@ func mergeModels(tx *sql.Tx, primaryID uint64, secondaryID uint64, 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})
if len(conflictingColumns) < 1 {
@ -98,7 +98,7 @@ func deleteConflictsBeforeMerge(tx *sql.Tx, conflict conflictingUniqueKey, prima
return nil
}
func checkMerge(tx *sql.Tx, foreignKeys []foreignKey) error {
func checkMerge(tx boil.Executor, foreignKeys []foreignKey) error {
uniqueColumns := []interface{}{}
uniqueColumnNames := map[string]bool{}
handledTablesColumns := map[string]bool{}