Skip to content

Commit

Permalink
test(endtoend): Fix issues with PostgreSQL tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleconroy committed Sep 1, 2023
1 parent faa1c9d commit d625119
Show file tree
Hide file tree
Showing 63 changed files with 212 additions and 84 deletions.
3 changes: 2 additions & 1 deletion internal/endtoend/testdata/citext/pgx/query.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE EXTENSION IF NOT EXISTS citext;

CREATE TABLE foo (
bar citext,
bat citext not null
Expand All @@ -6,4 +8,3 @@ CREATE TABLE foo (
-- name: GetCitexts :many
SELECT bar, bat
FROM foo;

2 changes: 2 additions & 0 deletions internal/endtoend/testdata/citext/stdlib/query.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE EXTENSION IF NOT EXISTS citext;

CREATE TABLE foo (
bar citext,
bat citext not null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE foo (bar TEXT);
ALTER TABLE foo ALTER bar TYPE TEXT ARRAY;
ALTER TABLE foo ALTER bar TYPE TEXT ARRAY USING bar::text[];
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE foo (bar TEXT);
ALTER TABLE foo ALTER bar TYPE TEXT ARRAY;
ALTER TABLE foo ALTER bar TYPE TEXT ARRAY USING bar::text[];
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE foo (bar TEXT);
ALTER TABLE foo ALTER bar TYPE TEXT ARRAY;
ALTER TABLE foo ALTER bar TYPE TEXT ARRAY USING bar::text[];
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE venues (id SERIAL PRIMARY KEY);
ALTER TABLE venues DROP CONSTRAINT venues_id_pkey;
ALTER TABLE venues DROP CONSTRAINT venues_pkey;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE venues (id SERIAL PRIMARY KEY);
ALTER TABLE venues DROP CONSTRAINT venues_id_pkey;
ALTER TABLE venues DROP CONSTRAINT venues_pkey;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE venues (id SERIAL PRIMARY KEY);
ALTER TABLE venues DROP CONSTRAINT venues_id_pkey;
ALTER TABLE venues DROP CONSTRAINT venues_pkey;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
CREATE TABLE temp(a TEXT);
CREATE TABLE measurement (
city_id int not null,
logdate date not null,
peaktemp int,
unitsales int
) PARTITION BY RANGE (logdate);

CREATE INDEX temp_idx ON temp(a);
ALTER INDEX temp_idx ATTACH PARTITION temp_partition_idx;
CREATE TABLE measurement_y2006m02 PARTITION OF measurement
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');

CREATE INDEX measurement_usls_idx ON ONLY measurement (unitsales);

CREATE INDEX measurement_usls_200602_idx
ON measurement_y2006m02 (unitsales);

ALTER INDEX measurement_usls_idx
ATTACH PARTITION measurement_usls_200602_idx;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
CREATE TABLE temp(a TEXT);
CREATE TABLE measurement (
city_id int not null,
logdate date not null,
peaktemp int,
unitsales int
) PARTITION BY RANGE (logdate);

CREATE INDEX temp_idx ON temp(a);
ALTER INDEX temp_idx ATTACH PARTITION temp_partition_idx;
CREATE TABLE measurement_y2006m02 PARTITION OF measurement
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');

CREATE INDEX measurement_usls_idx ON ONLY measurement (unitsales);

CREATE INDEX measurement_usls_200602_idx
ON measurement_y2006m02 (unitsales);

ALTER INDEX measurement_usls_idx
ATTACH PARTITION measurement_usls_200602_idx;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
CREATE TABLE temp(a TEXT);
CREATE TABLE measurement (
city_id int not null,
logdate date not null,
peaktemp int,
unitsales int
) PARTITION BY RANGE (logdate);

CREATE INDEX temp_idx ON temp(a);
ALTER INDEX temp_idx ATTACH PARTITION temp_partition_idx;
CREATE TABLE measurement_y2006m02 PARTITION OF measurement
FOR VALUES FROM ('2006-02-01') TO ('2006-03-01');

CREATE INDEX measurement_usls_idx ON ONLY measurement (unitsales);

CREATE INDEX measurement_usls_200602_idx
ON measurement_y2006m02 (unitsales);

ALTER INDEX measurement_usls_idx
ATTACH PARTITION measurement_usls_200602_idx;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE foo (bar text);
ALTER TABLE foo ALTER bar SET DATA TYPE bool;
ALTER TABLE foo ALTER bar SET DATA TYPE bool USING bar::boolean;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE foo (bar text);
ALTER TABLE foo ALTER bar SET DATA TYPE bool;
ALTER TABLE foo ALTER bar SET DATA TYPE bool USING bar::boolean;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE TABLE foo (bar text);
ALTER TABLE foo ALTER bar SET DATA TYPE bool;
ALTER TABLE foo ALTER bar SET DATA TYPE bool USING bar::boolean;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CREATE FUNCTION foo(bar TEXT, baz TEXT="baz") RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
CREATE FUNCTION foo(bar TEXT, baz TEXT='baz') RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CREATE FUNCTION foo(bar TEXT, baz TEXT="baz") RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
CREATE FUNCTION foo(bar TEXT, baz TEXT='baz') RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CREATE FUNCTION foo(bar TEXT, baz TEXT="baz") RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
CREATE FUNCTION foo(bar TEXT, baz TEXT='baz') RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE FUNCTION foo(bar TEXT) RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
CREATE FUNCTION foo(bar INTEGER) RETURNS TEXT AS $$ SELECT "baz" $$ LANGUAGE sql;
CREATE FUNCTION foo(bar INTEGER) RETURNS TEXT AS $$ SELECT 'baz' $$ LANGUAGE sql;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE FUNCTION foo(bar TEXT) RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
CREATE FUNCTION foo(bar INTEGER) RETURNS TEXT AS $$ SELECT "baz" $$ LANGUAGE sql;
CREATE FUNCTION foo(bar INTEGER) RETURNS TEXT AS $$ SELECT 'baz' $$ LANGUAGE sql;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CREATE FUNCTION foo(bar TEXT) RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
CREATE FUNCTION foo(bar INTEGER) RETURNS TEXT AS $$ SELECT "baz" $$ LANGUAGE sql;
CREATE FUNCTION foo(bar INTEGER) RETURNS TEXT AS $$ SELECT 'baz' $$ LANGUAGE sql;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE foo (
id uuid PRIMARY KEY,
id uuid NOT NULL,
other_id uuid NOT NULL
) PARTITION BY HASH (other_id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE foo (
id uuid PRIMARY KEY,
id uuid NOT NULL,
other_id uuid NOT NULL
) PARTITION BY HASH (other_id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE foo (
id uuid PRIMARY KEY,
id uuid NOT NULL,
other_id uuid NOT NULL
) PARTITION BY HASH (other_id);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CREATE SCHEMA foo;
CREATE TABLE foo.bar (baz text);
DROP SCHEMA foo;
DROP SCHEMA foo CASCADE;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CREATE SCHEMA foo;
CREATE TABLE foo.bar (baz text);
DROP SCHEMA foo;
DROP SCHEMA foo CASCADE;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CREATE SCHEMA foo;
CREATE TABLE foo.bar (baz text);
DROP SCHEMA foo;
DROP SCHEMA foo CASCADE;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE TABLE old (val SERIAL);
CREATE TABLE new (val SERIAL);
CREATE TABLE pg_temp.migrate (val SERIAL);
INSERT INTO pg_temp.migrate (val) SELECT val FROM old;
INSERT INTO new (val) SELECT val FROM pg_temp.migrate;
INSERT INTO new (val) SELECT val FROM pg_temp.migrate;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE TABLE old (val SERIAL);
CREATE TABLE new (val SERIAL);
CREATE TABLE pg_temp.migrate (val SERIAL);
INSERT INTO pg_temp.migrate (val) SELECT val FROM old;
INSERT INTO new (val) SELECT val FROM pg_temp.migrate;
INSERT INTO new (val) SELECT val FROM pg_temp.migrate;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE TABLE old (val SERIAL);
CREATE TABLE new (val SERIAL);
CREATE TABLE pg_temp.migrate (val SERIAL);
INSERT INTO pg_temp.migrate (val) SELECT val FROM old;
INSERT INTO new (val) SELECT val FROM pg_temp.migrate;
INSERT INTO new (val) SELECT val FROM pg_temp.migrate;
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
CREATE TABLE users (
id integer,
first_name varchar(255) NOT NULL
id integer,
first_name varchar(255) NOT NULL
);

CREATE FUNCTION users_func() RETURNS SETOF users AS $func$ BEGIN QUERY
SELECT *
FROM users
END $func$ LANGUAGE plpgsql;
CREATE FUNCTION users_func() RETURNS SETOF users AS $func$
BEGIN
SELECT *
FROM users;
END;
$func$ LANGUAGE plpgsql;
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
CREATE TABLE users (
id integer,
first_name varchar(255) NOT NULL
id integer,
first_name varchar(255) NOT NULL
);

CREATE FUNCTION users_func() RETURNS SETOF users AS $func$ BEGIN QUERY
SELECT *
FROM users
END $func$ LANGUAGE plpgsql;
CREATE FUNCTION users_func() RETURNS SETOF users AS $func$
BEGIN
SELECT *
FROM users;
END;
$func$ LANGUAGE plpgsql;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ CREATE TABLE users (
first_name varchar(255) NOT NULL
);

CREATE FUNCTION users_func() RETURNS SETOF users AS $func$ BEGIN QUERY
SELECT *
FROM users
END $func$ LANGUAGE plpgsql;
CREATE FUNCTION users_func() RETURNS SETOF users AS $func$
BEGIN
SELECT *
FROM users;
END;
$func$ LANGUAGE plpgsql;
2 changes: 2 additions & 0 deletions internal/endtoend/testdata/hstore/pgx/v4/hstore.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE EXTENSION IF NOT EXISTS hstore;

CREATE TABLE foo (
bar hstore NOT NULL,
baz hstore
Expand Down
2 changes: 2 additions & 0 deletions internal/endtoend/testdata/hstore/pgx/v5/hstore.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE EXTENSION IF NOT EXISTS hstore;

CREATE TABLE foo (
bar hstore NOT NULL,
baz hstore
Expand Down
2 changes: 2 additions & 0 deletions internal/endtoend/testdata/hstore/stdlib/hstore.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
CREATE EXTENSION IF NOT EXISTS hstore;

CREATE TABLE foo (
bar hstore NOT NULL,
baz hstore
Expand Down
3 changes: 2 additions & 1 deletion internal/endtoend/testdata/identifier_dollar_sign/query.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CREATE FUNCTION f$n() RETURNS integer AS 'SELECT 1';
CREATE FUNCTION f$n() RETURNS integer
AS $$ SELECT 1 $$ LANGUAGE SQL;

-- name: Fn :one
SELECT f$n();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE foo (id serial not null);
CREATE TABLE foo (id serial not null unique);
CREATE TABLE bar (id serial not null references foo(id), title text);

-- name: AliasJoin :many
Expand Down
Loading

0 comments on commit d625119

Please sign in to comment.