From 766878432b1e2a393ebaedf576d6e73a7d28ab97 Mon Sep 17 00:00:00 2001 From: jaina heartles Date: Sat, 10 Dec 2022 01:27:46 -0800 Subject: [PATCH] Treat NULLs as DateTime epoch --- src/sql/engines/sqlite.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/sql/engines/sqlite.zig b/src/sql/engines/sqlite.zig index a69de93..be94c7e 100644 --- a/src/sql/engines/sqlite.zig +++ b/src/sql/engines/sqlite.zig @@ -313,6 +313,11 @@ fn getColumn(stmt: *c.sqlite3_stmt, comptime T: type, idx: u15, alloc: ?Allocato c.SQLITE_FLOAT => getColumnFloat(stmt, T, idx), c.SQLITE_TEXT => getColumnText(stmt, T, idx, alloc), c.SQLITE_NULL => { + if (T == DateTime) { + std.log.warn("SQLite: Treating NULL as DateTime epoch", .{}); + return std.mem.zeroes(DateTime); + } + if (@typeInfo(T) != .Optional) { std.log.err("SQLite column {}: Expected value of type {}, got (null)", .{ idx, T }); return error.ResultTypeMismatch;