Skip to content

Commit cd4a90a

Browse files
regex fix to support table name with alias
1 parent 5de56b6 commit cd4a90a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

oracle/query.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ import (
4646
)
4747

4848
// Identifies the table name alias provided as
49-
// "\"users\" \"u\"" and "\"users\" u". Gorm already handles
49+
// "\"users\" \"u\"" and "\"users\" u" and "\"users\"". Gorm already handles
5050
// the other formats like "users u", "users AS u" etc.
51-
var tableRegexp = regexp.MustCompile(`^"(\w+)"\s+"?(\w+)"?$`)
51+
var tableRegexp = regexp.MustCompile(`^"(\w+)"(?:\s+"?(\w+)"?)?$`)
5252

5353
func BeforeQuery(db *gorm.DB) {
5454
if db == nil || db.Statement == nil || db.Statement.TableExpr == nil {
@@ -64,6 +64,7 @@ func BeforeQuery(db *gorm.DB) {
6464
}
6565
}
6666
}
67+
return
6768
}
6869

6970
// MismatchedCaseHandler handles Oracle Case Insensitivity.

0 commit comments

Comments
 (0)