News for hackers. Stuff that matters.
Re:JSONB Has Landed in SQLite by btown on Wednesday December 06, 2023 @12:42PM (#38547103)
The question is whether people think of their database as a processor of data or a storage location for data, exactly as it was provided. Given that a lot of people use SQLite as the latter, it's a worthwhile caveat to make people aware of.

Additionally, Javascript environments (formalized in ES2015), your text editor, and your filesystem all guarantee that they'll preserve object key order when JSON is evaluated. It's not unreasonable that someone would expect this of their database!

Re:JSONB Has Landed in SQLite by cryptonector on Wednesday December 06, 2023 @06:26PM (#38550896)
> The question is whether people think of their database as a processor of data or a storage location for data

If you use the database's JSON type(s) and/or functions, then yes, your database is a JSON processor.

And, yes, your database is not a dumb store, not if it's an RDBMS. The whole point of it is that it's not a dumb store.

Re:JSONB Has Landed in SQLite by seanhunter on Wednesday December 06, 2023 @02:14PM (#38548232)
If you're storing it exactly as provided then surely until you know it's actually valid json you want a string, not a json/jsonb column.
Re:JSONB Has Landed in SQLite by ash on Wednesday December 06, 2023 @12:50PM (#38547211)
> Javascript environments ... guarantee that they'll preserve object key order when JSON is evaluated

Yes, but only for non-integer keys.

Re:JSONB Has Landed in SQLite by gmfawcett on Thursday December 07, 2023 @06:20PM (#38563175)
Is there such a thing as a non-string JSON key to be evaluated? https://www.json.org/ suggests not.
Re:JSONB Has Landed in SQLite by ash on Thursday December 14, 2023 @09:30AM (#38641692)
Yes, in the context of JSON handling by JavaScript. I meant string keys that can be interpreted as non-negative numbers. Those are traversed first, the rest of the keys are coming in insertion order. For example:

    > JSON.stringify({'one': 1, '3': 3, 'two': 2, '2': 2, 'three': 3, '1': 1})
    '{"1":1,"2":2,"3":3,"one":1,"two":2,"three":3}'
Re:JSONB Has Landed in SQLite by gmfawcett on Sunday December 17, 2023 @09:42AM (#38673157)
Thanks for explaining. That behaviour is... interesting!