GenieFramework / GenieFramework/SearchLight.jl

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

Open
#67 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
149
Forks
18
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When a struct's field has `missing`value 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

```julia
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 `NULL`like `nothing`does

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.