Skip to content

Commit 87e5a66

Browse files
committed
refactor(orm): simplify quoteIdent to strip quote characters
1 parent 9f6456e commit 87e5a66

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

database/gorm/queries_relationships.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -914,13 +914,7 @@ func aggregateAlias(relation, fn, column string) string {
914914
// emit the bare identifier and let the dialects accept it - all tested dialects parse unquoted
915915
// identifiers when the names are simple snake_case.
916916
func quoteIdent(name string) string {
917-
if name == "" {
918-
return ""
919-
}
920-
if strings.ContainsAny(name, " (.") {
921-
return name
922-
}
923-
return name
917+
return strings.NewReplacer("`", "", "'", "", `"`, "").Replace(name)
924918
}
925919

926920
// Sanity: ensure *Query satisfies contractsorm.QueryWithRelations at compile time.

0 commit comments

Comments
 (0)