diff --git a/main.go b/main.go index 0980c13b..24f67621 100644 --- a/main.go +++ b/main.go @@ -16,11 +16,12 @@ type DB struct { dialect Dialect tagIdentifier string singularTable bool + source string } func Open(driver, source string) (DB, error) { var err error - db := DB{dialect: NewDialect(driver), tagIdentifier: "sql", logger: defaultLogger, callback: DefaultCallback} + db := DB{dialect: NewDialect(driver), tagIdentifier: "sql", logger: defaultLogger, callback: DefaultCallback, source: source} db.db, err = sql.Open(driver, source) db.parent = &db return db, err diff --git a/scope_private.go b/scope_private.go index d9f16438..ee57316f 100644 --- a/scope_private.go +++ b/scope_private.go @@ -448,7 +448,8 @@ func (scope *Scope) removeIndex(indexName string) { func (scope *Scope) autoMigrate() *Scope { var tableName string - scope.Raw(fmt.Sprintf("SELECT table_name FROM INFORMATION_SCHEMA.tables where table_name = %v", scope.AddToVars(scope.TableName()))) + scope.Raw(fmt.Sprintf("SELECT table_name FROM INFORMATION_SCHEMA.tables where table_name = %v", + scope.AddToVars(scope.TableName()))) scope.DB().QueryRow(scope.Sql, scope.SqlVars...).Scan(&tableName) scope.SqlVars = []interface{}{} @@ -458,7 +459,7 @@ func (scope *Scope) autoMigrate() *Scope { } else { for _, field := range scope.Fields() { var column, data string - scope.Raw(fmt.Sprintf("SELECT column_name, data_type FROM information_schema.columns WHERE table_name = %v and column_name = %v", + scope.Raw(fmt.Sprintf("SELECT column_name, data_type FROM information_schema.columns WHERE table_name = %v AND column_name = %v", scope.AddToVars(scope.TableName()), scope.AddToVars(field.DBName), ))