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

Allow inserting nothing as null value #56

Open
bryaan opened this issue Jun 11, 2023 · 1 comment
Open

Allow inserting nothing as null value #56

bryaan opened this issue Jun 11, 2023 · 1 comment

Comments

@bryaan
Copy link

bryaan commented Jun 11, 2023

Instead of having to write conversion code for nothing => missing then wrap a bunch of calls in it can this lib just support inserting values of nothing as null?

@wookay
Copy link
Owner

wookay commented Jun 11, 2023

about missing, NULL from docs
https://docs.julialang.org/en/v1/manual/missing/
"missing is equivalent to NULL in SQL and NA in R, and behaves like them in most situations."

there was a question,
How to pass a null value to a prepared statement with LibPQ.jl
https://discourse.julialang.org/t/how-to-pass-a-null-value-to-a-prepared-statement-with-libpq-jl/25068

testing NULL in test/adapters/postgresql/null.jl
https://github.com/wookay/Octo.jl/blob/master/test/adapters/postgresql/null.jl

but you could try this code that nothing for NULL

julia> using Octo.Adapters.PostgreSQL

julia> using Octo.AdapterBase: ElementStyle, SqlPartElement

julia> Octo.AdapterBase.sqlrepr(::Octo.DBMS.PostgreSQL, ::Nothing) = SqlPartElement(ElementStyle(:cyan), "NULL")

julia> to_sql([nothing])
"NULL"

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

2 participants