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

managment of NULL #49

Open
craff opened this issue Dec 30, 2022 · 3 comments
Open

managment of NULL #49

craff opened this issue Dec 30, 2022 · 3 comments

Comments

@craff
Copy link

craff commented Dec 30, 2022

I would suggest to use Postgresql.null for null value. This way physical equality
can distinguish the NULL value and the empty string. Accessing the result to know is a parameter is NULL is
a bit annoying.

This is relatively fragile as OCaml could decide to share the representation of the null string. This is not done in 5.0.0.

But even in this case, Postgresl.null could be created from C or in other ways to avoid sharing.

@craff
Copy link
Author

craff commented Dec 30, 2022

A better solution could be a getoptvalue : int -> int -> string option
But this does not solve the problem of get_all and get_tuple. May be
get_optall and get_opttuple too ?

@craff
Copy link
Author

craff commented Jan 9, 2023

I finally decided that the when a column of type string may be null, then the empty string is equivalent to null. This mostly solved the issue. This is a good choice if using html form, when the empty string and undefined can not be distinguished.

I hesitate to close myself ... just leave a bit of time for someone to comment, before.

@rixed
Copy link

rixed commented Oct 20, 2023

Chiming in... I was wondering why Postgresql.null is actually set to the empty string rather than "NULL", which is the keyword to be passed as a parameter for exec.
When reading data one can (and should) use the isnull method so the string representation of the value does not matter, but when inserting new tuples using Postgresql.null currently result in a parse error.

Scratching my head, maybe I'm doing something wrong?

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