Skip to content

Treat empty string as nil when inflating datetime/date columns - #198

Merged
fukamachi merged 1 commit into
masterfrom
fix/nullable-timestamp-empty-string
Apr 17, 2026
Merged

Treat empty string as nil when inflating datetime/date columns#198
fukamachi merged 1 commit into
masterfrom
fix/nullable-timestamp-empty-string

Conversation

@fukamachi

Copy link
Copy Markdown
Owner

What

In inflate-for-col-type, handle empty string "" as nil for :datetime and :date col-types (and their aliases :timestamp, :timestamptz).

Why

When a column is declared (or :null :timestamp) and the database stores "" instead of NULL — which can happen with data imports, external tools, or direct SQL inserts that use empty string for missing dates — local-time:parse-timestring is called with "" and raises an error. An empty string is never a valid timestamp, so treating it as nil is the right behavior.

Fixes #197.

MySQL returns "" instead of nil for NULL timestamp/date columns.
The inflate methods handled nil via etypecase but not "", causing
local-time:parse-timestring to fail with an empty string input.
@fukamachi
fukamachi merged commit 8b9e53d into master Apr 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant