Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PGimenez opened this issue Apr 3, 2023 · 0 comments

Comments

@PGimenez
Copy link
Member

PGimenez commented Apr 3, 2023

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

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

No branches or pull requests

1 participant