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

sqlite module returns empty instead of nill #1479

Closed
flaviut opened this issue Aug 13, 2014 · 8 comments
Closed

sqlite module returns empty instead of nill #1479

flaviut opened this issue Aug 13, 2014 · 8 comments

Comments

@flaviut
Copy link
Contributor

flaviut commented Aug 13, 2014

null is returned as "", not as nil as expected. A query with no results returns a row of ""s, not [] as expected.

related to #1364, I wouldn't be surprised if there were more places with this behavior.

@Araq
Copy link
Member

Araq commented Aug 13, 2014

This is the documented behaviour. Or at least it is well known. It's also the right behaviour because it's only ambiguous when it's a string and if your data model distinguishes between "" and NULL, it's broken. People who care about not losing information should use the dbj_ modules.

@Araq Araq closed this as completed Aug 13, 2014
@flaviut
Copy link
Contributor Author

flaviut commented Aug 13, 2014

Sorry, I disagree. Even though it is documented, it is not the expected behavior and leads to information loss, the avoidance of which is highly critical.

@Skrylar
Copy link
Contributor

Skrylar commented Aug 14, 2014

A string of length zero and a NUL are not identical semantically. (e.g. doing data analysis in R, there is a clear distinction between NA and an empty string; one could mean a user choose to enter a blank option, while the other means the information was not available in the dataset.)

@dom96
Copy link
Contributor

dom96 commented Aug 14, 2014

I think the db module should distinguish between "" and NULL. The strutils module should then provide a isNullOrEmpty procedure similar to what C# provides.

@simonkrauter
Copy link
Contributor

Any news after 2 years?
What about adding additional procs like getAllRowsNilable()?

@Araq
Copy link
Member

Araq commented Aug 13, 2016

We fixed the db modules since forever.

@dom96
Copy link
Contributor

dom96 commented Aug 13, 2016

So the db modules now return nil?

@simonkrauter
Copy link
Contributor

@Araq: What do you mean? I don't see the wanted behavior anywhere.
Code line https://github.com/nim-lang/Nim/blob/devel/lib/impure/db_sqlite.nim#L142 sets the empty string.

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

5 participants