Skip to content

Saving struct to db with Missing value inserts "missing!" string instead of NULL #67

Description

@PGimenez

Describe the bug
When a struct's field has missingvalue of type Missing, saving it to a sqlite DB inserts a string instead of a NULL value.

To reproduce

I've created a MWE that inserts missing, nothing and Int values. The full code is here: https://github.com/GenieFramework/CodeExamples/tree/main/src/3.database/null_values

using SearchLight
using SearchLightSQLite
include("app/resources/houses/Houses.jl")
using .Houses

SearchLight.Configuration.load() |> SearchLight.connect

h = House(street="Barcelona", size=400, rooms=missing)
save(h)
h = House(street="Barcelona 2", size=400, rooms=nothing)
save(h)
h = House(street="Barcelona 3", size=400, rooms=4)
save(h)

This is the log info:

[ Info: INSERT  INTO houses ("street", "size", "rooms") VALUES ('Barcelona', 400.0, 'missing')
[ Info: ; SELECT CASE WHEN last_insert_rowid() = 0 THEN -1 ELSE last_insert_rowid() END AS LAST_INSERT_ID
[ Info: INSERT  INTO houses ("street", "size", "rooms") VALUES ('Barcelona 2', 400.0, NULL)
[ Info: ; SELECT CASE WHEN last_insert_rowid() = 0 THEN -1 ELSE last_insert_rowid() END AS LAST_INSERT_ID
[ Info: INSERT  INTO houses ("street", "size", "rooms") VALUES ('Barcelona 3', 400.0, 4)
[ Info: ; SELECT CASE WHEN last_insert_rowid() = 0 THEN -1 ELSE last_insert_rowid() END AS LAST_INSERT_ID

Expected behavior
missing should insert NULLlike nothingdoes

Additional context
This issue comes from a Discord thread https://discord.com/channels/774897545717219328/1089630389263405086

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions