Remix.run Logo
Groxx 2 hours ago

>* The length() SQL function only counts characters up to and excluding the first NUL.*

>The quote() SQL function only shows characters up to and excluding the first NUL.

>The .dump command in the CLI omits the first NUL character and all subsequent text in the SQL output that it generates. In fact, the CLI omits everything past the first NUL character in all contexts.

That's just all kinds of "oh no", wow.

I mean, I can't come up with a better strategy, but... oof. C-style strings being a thing at all really hurts.

inigyou 15 minutes ago | parent | next [-]

The better strategy is that it should just work, isn't it?

Scaevolus 2 hours ago | parent | prev [-]

It's not really a big problem. You should be storing arbitrary binary strings as blobs (and length() works properly with them), but the underlying encoding is nearly identical: https://www.sqlite.org/fileformat.html#record_format

deepsun 6 minutes ago | parent [-]

Then DBMS should not allow to save a string that would make some function return wrong results. Either truncate with a warning on INSERT (MySQL approach) or better throw an error.