Skip to content

Commit

Permalink
Fix tests, add quotes for alter-table
Browse files Browse the repository at this point in the history
  • Loading branch information
Aitem committed Oct 11, 2023
1 parent a75249e commit 6e19acb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/dsql/pg.clj
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@
(cond-> pk
(-> (conj "PRIMARY KEY")
(conj "(")
(ql/reduce-separated2 "," (fn [acc exp] (conj acc (name exp))) pk)
(ql/reduce-separated2 "," (fn [acc exp] (conj acc (str "\"" (name exp) "\""))) pk)
(conj ")")))
))

Expand Down
10 changes: 5 additions & 5 deletions test/dsql/pg_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@
:match_tags {:type "text[]"}
:dedup_tags {:type "text[]"}}
}
["CREATE UNLOGGED TABLE IF NOT EXISTS mytable ( id text PRIMARY KEY , filelds jsonb , match_tags text[] , dedup_tags text[] )"])
["CREATE UNLOGGED TABLE IF NOT EXISTS mytable ( \"id\" text PRIMARY KEY , \"filelds\" jsonb , \"match_tags\" text[] , \"dedup_tags\" text[] )"])

(format=
{:ql/type :pg/create-table
Expand All @@ -572,20 +572,20 @@
:status [:resource_status "not null"]
:partition [:int "not null"]
:resource [:jsonb "not null"]}}
["CREATE TABLE mytable ( id uuid not null , version uuid not null , cts timestamptz not null DEFAULT current_timestamp , ts timestamptz not null DEFAULT current_timestamp , status resource_status not null , partition int not null , resource jsonb not null )"])
["CREATE TABLE mytable ( \"id\" uuid not null , \"version\" uuid not null , \"cts\" timestamptz not null DEFAULT current_timestamp , \"ts\" timestamptz not null DEFAULT current_timestamp , \"status\" resource_status not null , \"partition\" int not null , \"resource\" jsonb not null )"])

(testing "default value"
(format=
{:ql/type :pg/create-table
:table-name "mytable"
:columns {:a {:type "integer" :not-null true :default 8}}}
["CREATE TABLE mytable ( a integer NOT NULL DEFAULT ? )" 8])
["CREATE TABLE mytable ( \"a\" integer NOT NULL DEFAULT ? )" 8])

(format=
{:ql/type :pg/create-table
:table-name "mytable"
:columns {:a {:type "timestamp" :not-null true :default :current_timestamp}}}
["CREATE TABLE mytable ( a timestamp NOT NULL DEFAULT current_timestamp )"]))
["CREATE TABLE mytable ( \"a\" timestamp NOT NULL DEFAULT current_timestamp )"]))

(testing "without columns"
(format=
Expand Down Expand Up @@ -1088,7 +1088,7 @@
{:ql/type :pg/alter-table
:table "table1"
:add {:primary-key [:a :b]}}
["ALTER TABLE table1 ADD PRIMARY KEY ( a , b )"])
["ALTER TABLE table1 ADD PRIMARY KEY ( \"a\" , \"b\" )"])

(format=
{:ql/type :pg/create-table-as
Expand Down

0 comments on commit 6e19acb

Please sign in to comment.