Skip to content

Commit e9ce36a

Browse files
authored
Merge pull request #13 from oracle-samples/tests_fix
Add quoted identifiers to fix tests.
2 parents d90fe6c + 8faa8c8 commit e9ce36a

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

tests/passed-tests.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@ TestNilPointerSlice
212212
TestNilPointerSlice2
213213
TestPrefixedPreloadDuplication
214214
TestPreloadManyToManyCallbacks
215-
#TestPreloadWithAssociations
216-
#TestNestedPreload
215+
TestPreloadWithAssociations
216+
TestNestedPreload
217217
TestNestedPreloadForSlice
218218
#TestPreloadWithConds
219-
#TestNestedPreloadWithConds
219+
TestNestedPreloadWithConds
220220
TestPreloadEmptyData
221221
TestPreloadGoroutine
222-
#TestPreloadWithDiffModel
223-
#TestNestedPreloadWithUnscoped
222+
TestPreloadWithDiffModel
223+
TestNestedPreloadWithUnscoped
224224
TestNestedPreloadWithNestedJoin
225225
#TestMergeNestedPreloadWithNestedJoin
226226
TestNestedPreloadWithPointerJoin
@@ -370,7 +370,7 @@ TestDistinctWithVaryingCase
370370
#TestDistinctWithAggregation
371371
TestUpsertWithSave
372372
TestFindOrInitialize
373-
#TestFindOrCreate
373+
TestFindOrCreate
374374
TestUpdateWithMissWhere
375375
BenchmarkCreate
376376
BenchmarkFind

tests/preload_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestPreloadWithAssociations(t *testing.T) {
7676
CheckUser(t, user, user)
7777

7878
var user2 User
79-
DB.Preload(clause.Associations).Find(&user2, "id = ?", user.ID)
79+
DB.Preload(clause.Associations).Find(&user2, "\"id\" = ?", user.ID)
8080
CheckUser(t, user2, user)
8181

8282
user3 := *GetUser("preload_with_associations_new", Config{
@@ -90,7 +90,7 @@ func TestPreloadWithAssociations(t *testing.T) {
9090
Friends: 1,
9191
})
9292

93-
DB.Preload(clause.Associations).Find(&user3, "id = ?", user.ID)
93+
DB.Preload(clause.Associations).Find(&user3, "\"id\" = ?", user.ID)
9494
CheckUser(t, user3, user)
9595
}
9696

@@ -107,15 +107,15 @@ func TestNestedPreload(t *testing.T) {
107107
}
108108

109109
var user2 User
110-
DB.Preload("Pets.Toy").Find(&user2, "id = ?", user.ID)
110+
DB.Preload("Pets.Toy").Find(&user2, "\"id\" = ?", user.ID)
111111
CheckUser(t, user2, user)
112112

113113
var user3 User
114-
DB.Preload(clause.Associations+"."+clause.Associations).Find(&user3, "id = ?", user.ID)
114+
DB.Preload(clause.Associations+"."+clause.Associations).Find(&user3, "\"id\" = ?", user.ID)
115115
CheckUser(t, user3, user)
116116

117117
var user4 *User
118-
DB.Preload("Pets.Toy").Find(&user4, "id = ?", user.ID)
118+
DB.Preload("Pets.Toy").Find(&user4, "\"id\" = ?", user.ID)
119119
CheckUser(t, *user4, user)
120120
}
121121

@@ -167,7 +167,7 @@ func TestPreloadWithConds(t *testing.T) {
167167
}
168168

169169
var users2 []User
170-
DB.Preload("Account", clause.Eq{Column: "number", Value: users[0].Account.AccountNumber}).Find(&users2, "id IN ?", userIDs)
170+
DB.Preload("Account", clause.Eq{Column: "account_number", Value: users[0].Account.AccountNumber}).Find(&users2, "id IN ?", userIDs)
171171
sort.Slice(users2, func(i, j int) bool {
172172
return users2[i].ID < users2[j].ID
173173
})
@@ -232,7 +232,7 @@ func TestNestedPreloadWithConds(t *testing.T) {
232232
}
233233

234234
var users2 []User
235-
DB.Preload("Pets.Toy", "name like ?", `%preload_3`).Find(&users2, "id IN ?", userIDs)
235+
DB.Preload("Pets.Toy", "\"name\" like ?", `%preload_3`).Find(&users2, "\"id\" IN ?", userIDs)
236236

237237
for idx, user := range users2[0:2] {
238238
for _, pet := range user.Pets {
@@ -312,8 +312,8 @@ func TestPreloadWithDiffModel(t *testing.T) {
312312
User
313313
}
314314

315-
DB.Model(User{}).Preload("Account", clause.Eq{Column: "number", Value: user.Account.AccountNumber}).Select(
316-
"users.*, 'yo' as something").First(&result, "name = ?", user.Name)
315+
DB.Model(User{}).Preload("Account", clause.Eq{Column: "\"account_number\"", Value: user.Account.AccountNumber}).Select(
316+
"\"users\".*, 'yo' as something").First(&result, "\"name\" = ?", user.Name)
317317

318318
CheckUser(t, user, result.User)
319319
}
@@ -330,29 +330,29 @@ func TestNestedPreloadWithUnscoped(t *testing.T) {
330330
}
331331

332332
var user2 User
333-
DB.Preload("Pets.Toy").Find(&user2, "id = ?", user.ID)
333+
DB.Preload("Pets.Toy").Find(&user2, "\"id\" = ?", user.ID)
334334
CheckUser(t, user2, user)
335335

336336
DB.Delete(&pet)
337337

338338
var user3 User
339-
DB.Preload(clause.Associations+"."+clause.Associations).Find(&user3, "id = ?", user.ID)
339+
DB.Preload(clause.Associations+"."+clause.Associations).Find(&user3, "\"id\" = ?", user.ID)
340340
if len(user3.Pets) != 0 {
341341
t.Fatalf("User.Pet[0] was deleted and should not exist.")
342342
}
343343

344344
var user4 *User
345-
DB.Preload("Pets.Toy").Find(&user4, "id = ?", user.ID)
345+
DB.Preload("Pets.Toy").Find(&user4, "\"id\" = ?", user.ID)
346346
if len(user4.Pets) != 0 {
347347
t.Fatalf("User.Pet[0] was deleted and should not exist.")
348348
}
349349

350350
var user5 User
351-
DB.Unscoped().Preload(clause.Associations+"."+clause.Associations).Find(&user5, "id = ?", user.ID)
351+
DB.Unscoped().Preload(clause.Associations+"."+clause.Associations).Find(&user5, "\"id\" = ?", user.ID)
352352
CheckUserUnscoped(t, user5, user)
353353

354354
var user6 *User
355-
DB.Unscoped().Preload("Pets.Toy").Find(&user6, "id = ?", user.ID)
355+
DB.Unscoped().Preload("Pets.Toy").Find(&user6, "\"id\" = ?", user.ID)
356356
CheckUserUnscoped(t, *user6, user)
357357
}
358358

tests/upsert_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,11 +344,11 @@ func TestFindOrCreate(t *testing.T) {
344344
}
345345

346346
DB.Where(&User{Name: "find or create embedded struct"}).Assign(User{Age: 44, Account: Account{AccountNumber: "1231231231"}, Pets: []*Pet{{Name: "first_or_create_pet1"}, {Name: "first_or_create_pet2"}}}).FirstOrCreate(&user8)
347-
if err := DB.Where("name = ?", "first_or_create_pet1").First(&Pet{}).Error; err != nil {
347+
if err := DB.Where("\"name\" = ?", "first_or_create_pet1").First(&Pet{}).Error; err != nil {
348348
t.Errorf("has many association should be saved")
349349
}
350350

351-
if err := DB.Where("number = ?", "1231231231").First(&Account{}).Error; err != nil {
351+
if err := DB.Where("\"account_number\" = ?", "1231231231").First(&Account{}).Error; err != nil {
352352
t.Errorf("belongs to association should be saved")
353353
}
354354
}

0 commit comments

Comments
 (0)