From 89cd3fe1966dee5955305d422c53e7903a183ad1 Mon Sep 17 00:00:00 2001 From: rajajisai Date: Tue, 19 Aug 2025 21:49:04 -0400 Subject: [PATCH 1/3] `notnull` is now set based on the `nullable` field instead of being hardcoded. --- core/schema.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/schema.rs b/core/schema.rs index 90c511bfb..c5b0cfb7e 100644 --- a/core/schema.rs +++ b/core/schema.rs @@ -931,8 +931,10 @@ fn create_table( order = o; } } - turso_sqlite3_parser::ast::ColumnConstraint::NotNull { .. } => { - notnull = true; + turso_sqlite3_parser::ast::ColumnConstraint::NotNull { + nullable, .. + } => { + notnull = !nullable; } turso_sqlite3_parser::ast::ColumnConstraint::Default(expr) => { default = Some(expr) From 73500eb00c5d543b3f725cb1748df4e270be05fd Mon Sep 17 00:00:00 2001 From: rajajisai Date: Tue, 19 Aug 2025 22:33:59 -0400 Subject: [PATCH 2/3] Include tests --- testing/insert.test | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/testing/insert.test b/testing/insert.test index ff5bf286a..aa58481bf 100755 --- a/testing/insert.test +++ b/testing/insert.test @@ -516,6 +516,12 @@ do_execsql_test_on_specific_db {:memory:} insert-explicit-rowid-with-rowidalias 8|6|8|5 12|10|12|9} +do_execsql_test_on_specific_db {:memory:} null-value-insert-null-type-column { + CREATE TABLE test (id INTEGER,name NULL); + INSERT INTO test (id, name) VALUES (1, NULL); + SELECT * FROM test; +} {1|} + do_execsql_test_in_memory_error_content insert-explicit-rowid-conflict { create table t (x); insert into t(rowid, x) values (1, 1); @@ -595,3 +601,8 @@ do_catchsql_test unknown-backtick-identifier-in-values-clause { CREATE TABLE tt (x); INSERT INTO tt VALUES(`asdf`); } {1 {no such column: `asdf`}} + +do_execsql_test_in_memory_error_content null-insert-in-nulltype-column-notnull-constraint { + CREATE TABLE test (id INTEGER,name NULL NOT NULL); + INSERT INTO test (id, name) VALUES (1, NULL); +} {Runtime error: NOT NULL constraint failed:} \ No newline at end of file From ff2d62aa9dadc982364176419492ececec1434f9 Mon Sep 17 00:00:00 2001 From: rajajisai Date: Tue, 19 Aug 2025 23:11:10 -0400 Subject: [PATCH 3/3] update test --- testing/insert.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/insert.test b/testing/insert.test index aa58481bf..70c1c49bd 100755 --- a/testing/insert.test +++ b/testing/insert.test @@ -605,4 +605,4 @@ do_catchsql_test unknown-backtick-identifier-in-values-clause { do_execsql_test_in_memory_error_content null-insert-in-nulltype-column-notnull-constraint { CREATE TABLE test (id INTEGER,name NULL NOT NULL); INSERT INTO test (id, name) VALUES (1, NULL); -} {Runtime error: NOT NULL constraint failed:} \ No newline at end of file +} {NOT NULL constraint failed} \ No newline at end of file