From e94cfcf2bc176c1130f5d8baad365811916f6239 Mon Sep 17 00:00:00 2001 From: Andrej Mihajlov Date: Sat, 8 Oct 2016 21:58:28 +0100 Subject: [PATCH 1/2] Add test for null values --- Tests/PostgreSQLTests/PostgreSQLTests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/PostgreSQLTests/PostgreSQLTests.swift b/Tests/PostgreSQLTests/PostgreSQLTests.swift index 15ab3ba..525582b 100644 --- a/Tests/PostgreSQLTests/PostgreSQLTests.swift +++ b/Tests/PostgreSQLTests/PostgreSQLTests.swift @@ -70,6 +70,8 @@ class PostgreSQLTests: XCTestCase { do { try postgreSQL.execute("DROP TABLE IF EXISTS parameterization") try postgreSQL.execute("CREATE TABLE parameterization (d FLOAT4, i INT, s VARCHAR(16), u INT)") + + try postgreSQL.execute("INSERT INTO parameterization VALUES ($1, $2, $3, $4)", [.null, .null, "life".makeNode(), .null], on: nil) try postgreSQL.execute("INSERT INTO parameterization VALUES (3.14, NULL, 'pi', NULL)") try postgreSQL.execute("INSERT INTO parameterization VALUES (NULL, NULL, 'life', 42)") From 5e1079ae97f1287da04f0a2d53af101a97d81bab Mon Sep 17 00:00:00 2001 From: Andrej Mihajlov Date: Sat, 8 Oct 2016 22:07:46 +0100 Subject: [PATCH 2/2] Fix NULL conversion for optional fields --- Sources/PostgreSQL/Database.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/PostgreSQL/Database.swift b/Sources/PostgreSQL/Database.swift index 8a51918..a1560dd 100644 --- a/Sources/PostgreSQL/Database.swift +++ b/Sources/PostgreSQL/Database.swift @@ -52,6 +52,10 @@ public class Database { defer { for i in 0..