diff --git a/join_table_test.go b/join_table_test.go index db09c8e6..01b038c2 100644 --- a/join_table_test.go +++ b/join_table_test.go @@ -50,7 +50,7 @@ func (*PersonAddress) Delete(handler gorm.JoinTableHandlerInterface, db *gorm.DB func (pa *PersonAddress) JoinWith(handler gorm.JoinTableHandlerInterface, db *gorm.DB, source interface{}) *gorm.DB { table := pa.Table(db) where := fmt.Sprintf("%v.deleted_at IS NULL OR %v.deleted_at <= ", table, table) - if isOracle(db) { + if isOra(db) { where = where + "DATE '0001-01-02'" } else { where = where + "'0001-01-02'" diff --git a/main_test.go b/main_test.go index 67a9056f..c7a405fa 100644 --- a/main_test.go +++ b/main_test.go @@ -574,7 +574,7 @@ func TestTransactionReadonly(t *testing.T) { if dialect == "" { dialect = "sqlite" } - if isOracle(DB) { + if isOra(DB) { dialect = "oracle" } switch dialect { @@ -1352,7 +1352,7 @@ func TestQueryHint1(t *testing.T) { db := DB.New() q := "select 1" - if isOracle(db) { + if isOra(db) { q = q + " from dual" } _, err := db.Model(User{}).Raw(q).Rows() @@ -1462,8 +1462,8 @@ func parseTime(str string) *time.Time { return &t } -// isOracle gives tests an easy way to determine if the dialect uses Oracle for its RMDBS, since oracle could have multiple dialects for different drivers. -// and since tests run in their own namespace -func isOracle(db *gorm.DB) bool { - return db.Dialect().GetName() == "oci8" +// isOra gives tests an easy way to determine if the dialect uses Oracle for its RMDBS, since oracle could have multiple dialects for different drivers. +func isOra(db *gorm.DB) bool { + _, ok := db.Dialect().(gorm.OraDialect) + return ok } diff --git a/query_test.go b/query_test.go index 2c8320a6..636db069 100644 --- a/query_test.go +++ b/query_test.go @@ -185,7 +185,7 @@ func TestSearchWithPlainSQL(t *testing.T) { } param := "?" - if isOracle(scopedb) { + if isOra(scopedb) { param = "to_date(?, 'YYYY-MM-DD')" } scopedb.Where("birthday > "+param, "2002-10-10").Find(&users) @@ -773,7 +773,7 @@ func TestSelectWithEscapedFieldName(t *testing.T) { DB.Save(&user1).Save(&user2).Save(&user3) colName := "name" - if isOracle(DB) { + if isOra(DB) { colName = "NAME" // oracle upper cases all identifiers that aren't explicitly escaped when the table is created } var names []string @@ -794,7 +794,7 @@ func TestSelectWithVariables(t *testing.T) { } else { columns, _ := rows.Columns() colName := "fake" - if isOracle(DB) { + if isOra(DB) { colName = "FAKE" // oracle upper cases all identifiers that aren't explicitly escaped when the table is created } if !reflect.DeepEqual(columns, []string{colName}) { diff --git a/scope_test.go b/scope_test.go index a08b5d4f..9d06b072 100644 --- a/scope_test.go +++ b/scope_test.go @@ -65,7 +65,7 @@ func TestValuer(t *testing.T) { var user2 User - if isOracle(DB) { + if isOra(DB) { where := fmt.Sprintf("name = ? AND %s AND %s", oracle.SearchBlob("password_hash"), oracle.SearchBlob("password")) if err := DB.Where(where, name, "abc", "***pass1").First(&user2).Error; err != nil {