Skip to content

Commit

Permalink
Add type mapping tests for Postgres serial types
Browse files Browse the repository at this point in the history
  • Loading branch information
hashhar committed Mar 9, 2022
1 parent 9e957e4 commit a3ed6ba
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ public void testSmallint()
.execute(getQueryRunner(), trinoCreateAndInsert("test_smallint"));
}

@Test
public void testSmallserial()
{
// smallserial is an autoincrementing smallint and doesn't accept NULLs
SqlDataTypeTest.create()
.addRoundTrip("smallserial", "-32768", SMALLINT, "SMALLINT '-32768'") // min value in PostgreSQL and Trino
.addRoundTrip("smallserial", "32456", SMALLINT, "SMALLINT '32456'")
.addRoundTrip("smallserial", "32767", SMALLINT, "SMALLINT '32767'") // max value in PostgreSQL and Trino
.execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_smallserial"))
.execute(getQueryRunner(), postgresCreateTrinoInsert("tpch.test_smallserial"));
}

@Test
public void testUnsupportedSmallint()
{
Expand All @@ -244,6 +256,18 @@ public void testInteger()
.execute(getQueryRunner(), trinoCreateAndInsert("test_int"));
}

@Test
public void testSerial()
{
// serial is an autoincrementing int and doesn't accept NULLs
SqlDataTypeTest.create()
.addRoundTrip("serial", "-2147483648", INTEGER, "-2147483648") // min value in PostgreSQL and Trino
.addRoundTrip("serial", "1234567890", INTEGER, "1234567890")
.addRoundTrip("serial", "2147483647", INTEGER, "2147483647") // max value in PostgreSQL and Trino
.execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_serial"))
.execute(getQueryRunner(), postgresCreateTrinoInsert("tpch.test_serial"));
}

@Test
public void testUnsupportedInteger()
{
Expand All @@ -270,6 +294,18 @@ public void testBigint()
.execute(getQueryRunner(), trinoCreateAndInsert("test_bigint"));
}

@Test
public void testBigserial()
{
// bigserial is an autoincrementing bigint and doesn't accept NULLs
SqlDataTypeTest.create()
.addRoundTrip("bigserial", "-9223372036854775808", BIGINT, "-9223372036854775808") // min value in PostgreSQL and Trino
.addRoundTrip("bigserial", "123456789012", BIGINT, "123456789012")
.addRoundTrip("bigserial", "9223372036854775807", BIGINT, "9223372036854775807") // max value in PostgreSQL and Trino
.execute(getQueryRunner(), postgresCreateAndInsert("tpch.test_bigserial"))
.execute(getQueryRunner(), postgresCreateTrinoInsert("tpch.test_bigserial"));
}

@Test
public void testUnsupportedBigint()
{
Expand Down

0 comments on commit a3ed6ba

Please sign in to comment.