File tree Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Expand file tree Collapse file tree 3 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,10 @@ import (
45
45
)
46
46
47
47
// Identifies the table name alias provided as
48
- // "\"users\" \"u\"". Gorm already handles
48
+ // "\"users\" \"u\"" and "\"users\" u" . Gorm already handles
49
49
//
50
50
// the other formats like "users u", "users AS u" etc.
51
- var tableRegexp = regexp .MustCompile (`^"([^"] +)"\s+"([^"] +)"$` )
51
+ var tableRegexp = regexp .MustCompile (`^"(\w +)"\s+"?(\w +)"? $` )
52
52
53
53
func BeforeQuery (db * gorm.DB ) {
54
54
if db == nil || db .Statement == nil || db .Statement .TableExpr == nil {
Original file line number Diff line number Diff line change @@ -158,7 +158,10 @@ func TestGenericsExecAndUpdate(t *testing.T) {
158
158
t .Fatalf ("Exec insert failed: %v" , err )
159
159
}
160
160
161
- u , err := gorm.G [User ](DB ).Table ("\" users\" \" u\" " ).Where ("\" u\" .\" name\" = ?" , name ).First (ctx )
161
+ // todo: uncomment the below line, once the alias quoting issue is resolved.
162
+ // Gorm issue track: https://github.com/oracle-samples/gorm-oracle/issues/36
163
+ // u, err := gorm.G[User](DB).Table("\"users\" u").Where("u.\"name\" = ?", name).First(ctx)
164
+ u , err := gorm.G [User ](DB ).Table ("users" ).Where ("\" name\" = ?" , name ).First (ctx )
162
165
if err != nil {
163
166
t .Fatalf ("failed to find user, got error: %v" , err )
164
167
} else if u .Name != name || u .ID == 0 {
Original file line number Diff line number Diff line change @@ -179,7 +179,10 @@ func TestPreloadWithConds(t *testing.T) {
179
179
180
180
var users3 []User
181
181
if err := DB .Preload ("Account" , func (tx * gorm.DB ) * gorm.DB {
182
- return tx .Table ("\" accounts\" \" a\" " ).Select ("\" a\" .*" )
182
+ // todo: uncomment the below line, once the alias quoting issue is resolved.
183
+ // Gorm issue track: https://github.com/oracle-samples/gorm-oracle/issues/36
184
+ // return tx.Table("\"accounts\" a").Select("a.*")
185
+ return tx .Table ("accounts" ).Select ("*" )
183
186
}).Find (& users3 , "\" id\" IN ?" , userIDs ).Error ; err != nil {
184
187
t .Errorf ("failed to query, got error %v" , err )
185
188
}
You can’t perform that action at this time.
0 commit comments