Treat NULLs as DateTime epoch

This commit is contained in:
jaina heartles 2022-12-10 01:27:46 -08:00
parent 882ff042e2
commit 766878432b

View file

@ -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_FLOAT => getColumnFloat(stmt, T, idx),
c.SQLITE_TEXT => getColumnText(stmt, T, idx, alloc), c.SQLITE_TEXT => getColumnText(stmt, T, idx, alloc),
c.SQLITE_NULL => { c.SQLITE_NULL => {
if (T == DateTime) {
std.log.warn("SQLite: Treating NULL as DateTime epoch", .{});
return std.mem.zeroes(DateTime);
}
if (@typeInfo(T) != .Optional) { if (@typeInfo(T) != .Optional) {
std.log.err("SQLite column {}: Expected value of type {}, got (null)", .{ idx, T }); std.log.err("SQLite column {}: Expected value of type {}, got (null)", .{ idx, T });
return error.ResultTypeMismatch; return error.ResultTypeMismatch;