package datability;

import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

import java.sql.Connection;

public class PostgreSqlTest {

    @ClassRule
    public static PostgresqlRule postgreSql = new PostgresqlRule();

    @Test
    public void table_with_not_null() throws Exception {
        postgreSql.execute("drop table if exists mytable", "create table mytable (a int not null)");

        try (Connection connection = postgreSql.openConnection()) {
            Databases.postgresql(connection).disableNotNulls("mytable");
            connection.prepareStatement("insert into mytable(a) values (null)").execute();
        }
    }

    @Test
    public void table_with_many_not_nulls() throws Exception {
        postgreSql.execute("drop table if exists mytable", "create table mytable (a int not null, b text not null)");

        try (Connection connection = postgreSql.openConnection()) {
            Databases.postgresql(connection).disableNotNulls("mytable");
            connection.prepareStatement("insert into mytable(a,b) values (null,null)").execute();
        }
    }

    @Test
    public void two_tables_with_not_nulls() throws Exception {
        postgreSql.execute(
                "drop table if exists tablea", "create table tablea (a int not null, b text not null)",
                "drop table if exists tableb", "create table tableb (c int not null, d text not null)");

        try (Connection connection = postgreSql.openConnection()) {
            Databases.postgresql(connection).disableNotNulls("tablea", "tableb");
            connection.prepareStatement("insert into tablea(a,b) values (null, null)").execute();
            connection.prepareStatement("insert into tableb(c,d) values (null, null)").execute();
        }
    }

}
@@ -558,38 +558,37 @@
      connection.
-prepar
+creat
 eStatement(%22inse
@@ -574,32 +574,42 @@
 createStatement(
+).execute(
 %22insert into myt
@@ -627,34 +627,24 @@
 ues (null)%22)
-.execute()
 ;%0A        %7D%0A
@@ -998,38 +998,37 @@
      connection.
-prepar
+creat
 eStatement(%22inse
@@ -1014,32 +1014,42 @@
 createStatement(
+).execute(
 %22insert into myt
@@ -1074,34 +1074,24 @@
 null,null)%22)
-.execute()
 ;%0A        %7D%0A
@@ -1573,38 +1573,37 @@
      connection.
-prepar
+creat
 eStatement(%22inse
@@ -1589,32 +1589,42 @@
 createStatement(
+).execute(
 %22insert into tab
@@ -1649,34 +1649,24 @@
 ull, null)%22)
-.execute()
 ;%0A          
@@ -1682,14 +1682,13 @@
 ion.
-prepar
+creat
 eSta
@@ -1694,16 +1694,26 @@
 atement(
+).execute(
 %22insert 
@@ -1754,18 +1754,8 @@
 l)%22)
-.execute()
 ;%0A  

Move to plain statement instead of prepared statement