Skip to content

Commit

Permalink
Merge pull request go-jet#434 from formica2/master
Browse files Browse the repository at this point in the history
Add additional postgres reserved keywords
  • Loading branch information
go-jet authored Jan 15, 2025
2 parents 4ab24b3 + 8646646 commit 269bb4a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
26 changes: 25 additions & 1 deletion postgres/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package postgres

import (
"fmt"
"github.com/go-jet/jet/v2/internal/jet"
"strconv"

"github.com/go-jet/jet/v2/internal/jet"
)

// Dialect is implementation of postgres dialect for SQL Builder serialisation.
Expand Down Expand Up @@ -121,17 +122,23 @@ var reservedWords = []string{
"AS",
"ASC",
"ASYMMETRIC",
"AUTHORIZATION",
"BINARY",
"BOTH",
"CASE",
"CAST",
"CHECK",
"COLLATE",
"COLLATION",
"COLUMN",
"CONCURRENTLY",
"CONSTRAINT",
"CREATE",
"CROSS",
"CURRENT_CATALOG",
"CURRENT_DATE",
"CURRENT_ROLE",
"CURRENT_SCHEMA",
"CURRENT_TIME",
"CURRENT_TIMESTAMP",
"CURRENT_USER",
Expand All @@ -147,36 +154,52 @@ var reservedWords = []string{
"FETCH",
"FOR",
"FOREIGN",
"FREEZE",
"FROM",
"FULL",
"GRANT",
"GROUP",
"HAVING",
"ILIKE",
"IN",
"INITIALLY",
"INNER",
"INTERSECT",
"INTO",
"IS",
"ISNULL",
"JOIN",
"LATERAL",
"LEADING",
"LEFT",
"LIKE",
"LIMIT",
"LOCALTIME",
"LOCALTIMESTAMP",
"NATURAL",
"NOT",
"NOTNULL",
"NULL",
"OFFSET",
"ON",
"ONLY",
"OR",
"ORDER",
"OUTER",
"OVERLAPS",
"PLACING",
"PRIMARY",
"REFERENCES",
"RETURNING",
"RIGHT",
"SELECT",
"SESSION_USER",
"SIMILAR",
"SOME",
"SYMMETRIC",
"SYSTEM_USER",
"TABLE",
"TABLESAMPLE",
"THEN",
"TO",
"TRAILING",
Expand All @@ -186,6 +209,7 @@ var reservedWords = []string{
"USER",
"USING",
"VARIADIC",
"VERBOSE",
"WHEN",
"WHERE",
"WINDOW",
Expand Down
7 changes: 4 additions & 3 deletions tests/postgres/sample_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package postgres

import (
"testing"

"github.com/go-jet/jet/v2/internal/utils/ptr"
"github.com/go-jet/jet/v2/qrm"
"github.com/google/uuid"
"testing"

"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -452,8 +453,8 @@ SELECT "User"."column" AS "User.column",
"User"."desc" AS "User.desc",
"User".empty AS "User.empty",
"User".float AS "User.float",
"User".join AS "User.join",
"User".like AS "User.like",
"User"."join" AS "User.join",
"User"."like" AS "User.like",
"User".max AS "User.max",
"User".rank AS "User.rank"
FROM test_sample."User";
Expand Down

0 comments on commit 269bb4a

Please sign in to comment.