From 997c7a40b8435931fbf1835fa67b2bdf16aa6167 Mon Sep 17 00:00:00 2001 From: chenjian2664 Date: Tue, 10 Dec 2024 17:12:32 +0800 Subject: [PATCH] Inline method addPrimaryKeyToCopyTable Inline method `addPrimaryKeyToCopyTable` in `TestPostgreSqlJdbcConnectionAccesses` and `TestPostgreSqlJdbcConnectionCreation` for readability --- .../postgresql/TestPostgreSqlJdbcConnectionAccesses.java | 7 +------ .../postgresql/TestPostgreSqlJdbcConnectionCreation.java | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionAccesses.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionAccesses.java index e09d7324c609..ad85f01582d8 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionAccesses.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionAccesses.java @@ -130,17 +130,12 @@ private void testJdbcMergeConnectionCreations() { assertJdbcConnections("CREATE TABLE copy_of_customer AS SELECT * FROM customer", 15, Optional.empty()); - addPrimaryKeyToCopyTable(); + postgreSqlServer.execute("ALTER TABLE copy_of_customer ADD CONSTRAINT t_copy_of_customer PRIMARY KEY (custkey)"); assertJdbcConnections("DELETE FROM copy_of_customer WHERE abs(custkey) = 1", 24, Optional.empty()); assertJdbcConnections("UPDATE copy_of_customer SET name = 'POLAND' WHERE abs(custkey) = 1", 32, Optional.empty()); assertJdbcConnections("MERGE INTO copy_of_customer c USING customer r ON r.custkey = c.custkey WHEN MATCHED THEN DELETE", 28, Optional.empty()); } - private void addPrimaryKeyToCopyTable() - { - postgreSqlServer.execute("ALTER TABLE copy_of_customer ADD CONSTRAINT t_copy_of_customer PRIMARY KEY (custkey)"); - } - private static final class TestingPostgreSqlModule extends AbstractConfigurationAwareModule { diff --git a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java index 7afea0c3a528..2454b0ef6da3 100644 --- a/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java +++ b/plugin/trino-postgresql/src/test/java/io/trino/plugin/postgresql/TestPostgreSqlJdbcConnectionCreation.java @@ -127,17 +127,12 @@ private void testJdbcMergeConnectionCreations() { assertJdbcConnections("CREATE TABLE copy_of_customer AS SELECT * FROM customer", 6, Optional.empty()); - addPrimaryKeyToCopyTable(); + postgreSqlServer.execute("ALTER TABLE copy_of_customer ADD CONSTRAINT t_copy_of_nation PRIMARY KEY (custkey)"); assertJdbcConnections("DELETE FROM copy_of_customer WHERE abs(custkey) = 1", 17, Optional.empty()); assertJdbcConnections("UPDATE copy_of_customer SET name = 'POLAND' WHERE abs(custkey) = 1", 25, Optional.empty()); assertJdbcConnections("MERGE INTO copy_of_customer c USING customer r ON r.custkey = c.custkey WHEN MATCHED THEN DELETE", 18, Optional.empty()); } - private void addPrimaryKeyToCopyTable() - { - postgreSqlServer.execute("ALTER TABLE copy_of_customer ADD CONSTRAINT t_copy_of_nation PRIMARY KEY (custkey)"); - } - private static final class TestingPostgreSqlModule extends AbstractConfigurationAwareModule {