Skip to content

Commit

Permalink
Add tests for Decimal
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGariepy committed Oct 31, 2022
1 parent 1c9b9f3 commit 804042d
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 35 deletions.
22 changes: 22 additions & 0 deletions Cargo.lock

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

8 changes: 7 additions & 1 deletion codegen_test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ tokio-postgres = { version = "0.7.7", features = [
] }
postgres-types = { version = "0.2.4", features = ["derive"] }
serde = { version = "1.0.144", features = ["derive"], package = "serde" }
serde_json = { version = "1.0.85", features = ["raw_value"], package = "serde_json" }
serde_json = { version = "1.0.85", features = [
"raw_value",
], package = "serde_json" }
time = { version = "0.3.14", features = ["parsing", "serde"] }
uuid = { version = "1.1.2", features = ["serde"] }
eui48 = { version = "1.1.0", features = ["serde"] }
rust_decimal = { version = "1.26.1", features = [
"db-tokio-postgres",
"db-postgres",
] }
futures = "0.3.24"

cornucopia_sync = { path = "../clients/sync", features = ["with-serde_json-1"] }
Expand Down
41 changes: 29 additions & 12 deletions codegen_test/queries/stress.sql
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
--! select_everything: Everything()
SELECT * FROM Everything;
SELECT
*
FROM
Everything;

--! select_everything_null: EverythingNull(bool_?, boolean_?, char_?, smallint_?, int2_?, smallserial_?, serial2_?, int_?, int4_?, serial_?, serial4_?, bingint_?, int8_?, bigserial_?, serial8_?, float4_?, real_?, float8_?, double_precision_?, text_?, varchar_?, bytea_?, timestamp_?, timestamp_without_time_zone_?, timestamptz_?, timestamp_with_time_zone_?, date_?, time_?, json_?, jsonb_?, uuid_?, inet_?, macaddr_?)
SELECT * FROM Everything;
--! select_everything_null: EverythingNull(bool_?, boolean_?, char_?, smallint_?, int2_?, smallserial_?, serial2_?, int_?, int4_?, serial_?, serial4_?, bingint_?, int8_?, bigserial_?, serial8_?, float4_?, real_?, float8_?, double_precision_?, text_?, varchar_?, bytea_?, timestamp_?, timestamp_without_time_zone_?, timestamptz_?, timestamp_with_time_zone_?, date_?, time_?, json_?, jsonb_?, uuid_?, inet_?, macaddr_?, numeric_?)
SELECT
*
FROM
Everything;

--! insert_everything EverythingParams()
INSERT INTO Everything (bool_, boolean_, char_, smallint_, int2_, smallserial_, serial2_, int_, int4_, serial_, serial4_, bingint_, int8_, bigserial_, serial8_, float4_, real_, float8_, double_precision_, text_, varchar_, bytea_, timestamp_, timestamp_without_time_zone_, timestamptz_, timestamp_with_time_zone_, date_, time_, json_, jsonb_, uuid_, inet_, macaddr_)
VALUES (:bool_, :boolean_, :char_, :smallint_, :int2_, :smallserial_, :serial2_, :int_, :int4_, :serial_, :serial4_, :bingint_, :int8_, :bigserial_, :serial8_, :float4_, :real_, :float8_, :double_precision_, :text_, :varchar_, :bytea_, :timestamp_, :timestamp_without_time_zone_, :timestamptz_, :timestamp_with_time_zone_, :date_, :time_, :json_, :jsonb_, :uuid_, :inet_, :macaddr_);
INSERT INTO Everything (bool_, boolean_, char_, smallint_, int2_, smallserial_, serial2_, int_, int4_, serial_, serial4_, bingint_, int8_, bigserial_, serial8_, float4_, real_, float8_, double_precision_, text_, varchar_, bytea_, timestamp_, timestamp_without_time_zone_, timestamptz_, timestamp_with_time_zone_, date_, time_, json_, jsonb_, uuid_, inet_, macaddr_, numeric_)
VALUES (:bool_, :boolean_, :char_, :smallint_, :int2_, :smallserial_, :serial2_, :int_, :int4_, :serial_, :serial4_, :bingint_, :int8_, :bigserial_, :serial8_, :float4_, :real_, :float8_, :double_precision_, :text_, :varchar_, :bytea_, :timestamp_, :timestamp_without_time_zone_, :timestamptz_, :timestamp_with_time_zone_, :date_, :time_, :json_, :jsonb_, :uuid_, :inet_, :macaddr_, :numeric_);

--! select_everything_array: EverythingArray()
SELECT * FROM EverythingArray;
SELECT
*
FROM
EverythingArray;

--! select_everything_array_null: EverythingArrayNull(bool_?, boolean_?, char_?, smallint_?, int2_?, int_?, int4_?, bingint_?, int8_?, float4_?, real_?, float8_?, double_precision_?, text_?, varchar_?, bytea_?, timestamp_?, timestamp_without_time_zone_?, timestamptz_?, timestamp_with_time_zone_?, date_?, time_?, json_?, jsonb_?, uuid_?, inet_?, macaddr_?)
SELECT * FROM EverythingArray;
--! select_everything_array_null: EverythingArrayNull(bool_?, boolean_?, char_?, smallint_?, int2_?, int_?, int4_?, bingint_?, int8_?, float4_?, real_?, float8_?, double_precision_?, text_?, varchar_?, bytea_?, timestamp_?, timestamp_without_time_zone_?, timestamptz_?, timestamp_with_time_zone_?, date_?, time_?, json_?, jsonb_?, uuid_?, inet_?, macaddr_?, numeric_?)
SELECT
*
FROM
EverythingArray;

--! insert_everything_array EverythingArrayParams()
INSERT INTO EverythingArray (bool_, boolean_, char_, smallint_, int2_, int_, int4_, bingint_, int8_, float4_, real_, float8_, double_precision_, text_, varchar_, bytea_, timestamp_, timestamp_without_time_zone_, timestamptz_, timestamp_with_time_zone_, date_, time_, json_, jsonb_, uuid_, inet_, macaddr_)
VALUES (:bool_, :boolean_, :char_, :smallint_, :int2_, :int_, :int4_, :bingint_, :int8_, :float4_, :real_, :float8_, :double_precision_, :text_, :varchar_, :bytea_, :timestamp_, :timestamp_without_time_zone_, :timestamptz_, :timestamp_with_time_zone_, :date_, :time_, :json_, :jsonb_, :uuid_, :inet_, :macaddr_);
INSERT INTO EverythingArray (bool_, boolean_, char_, smallint_, int2_, int_, int4_, bingint_, int8_, float4_, real_, float8_, double_precision_, text_, varchar_, bytea_, timestamp_, timestamp_without_time_zone_, timestamptz_, timestamp_with_time_zone_, date_, time_, json_, jsonb_, uuid_, inet_, macaddr_, numeric_)
VALUES (:bool_, :boolean_, :char_, :smallint_, :int2_, :int_, :int4_, :bingint_, :int8_, :float4_, :real_, :float8_, :double_precision_, :text_, :varchar_, :bytea_, :timestamp_, :timestamp_without_time_zone_, :timestamptz_, :timestamp_with_time_zone_, :date_, :time_, :json_, :jsonb_, :uuid_, :inet_, :macaddr_, :numeric_);

--! select_nightmare
SELECT * FROM nightmare;
SELECT
*
FROM
nightmare;

--! insert_nightmare
INSERT INTO nightmare (composite) VALUES (:composite);
INSERT INTO nightmare (composite)
VALUES (:composite);

7 changes: 5 additions & 2 deletions codegen_test/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ CREATE TABLE Everything (
jsonb_ jsonb,
uuid_ uuid,
inet_ inet,
macaddr_ macaddr
macaddr_ macaddr,
numeric_ numeric
);

CREATE TABLE EverythingArray (
Expand Down Expand Up @@ -151,7 +152,9 @@ CREATE TABLE EverythingArray (
jsonb_ jsonb[],
uuid_ uuid[],
inet_ inet[],
macaddr_ macaddr[]
macaddr_ macaddr[],
numeric_ numeric[]

);

CREATE TYPE spongebob_character AS enum (
Expand Down
Loading

0 comments on commit 804042d

Please sign in to comment.