Skip to content

Convert SQLite JSON columns to JSONB#1224

Open
brandur wants to merge 1 commit intomasterfrom
brandur-sqlite-jsonb-2
Open

Convert SQLite JSON columns to JSONB#1224
brandur wants to merge 1 commit intomasterfrom
brandur-sqlite-jsonb-2

Conversation

@brandur
Copy link
Copy Markdown
Contributor

@brandur brandur commented Apr 21, 2026

Alright, so this one's been some cleanup that I've been intending for a
while. Previously, sqlc made using JSONB in SQLite completely unusable
because it sent back the binary format which you're explicitly not
supposed to parse yourself. I ended up fixing this like a year ago in
[1], but getting a sqlc release out the door took so long that I ended
up forgetting about it.

Here, modify our SQLite definitions so that JSON becomes JSONB, and add
migration to convert existing installation values to the same. Luckily,
this doesn't require a table rewrite because both JSON and JSONB are
SQLite BLOB types.

I didn't want to add a migration version just for SQLite, so to keep
everything in sync I also added a version 7 for Postgres that's just a
no-op with a comment.

[1] sqlc-dev/sqlc#3968

@brandur brandur force-pushed the brandur-sqlite-jsonb-2 branch from d958f6b to 0df950c Compare April 21, 2026 22:50
Alright, so this one's been some cleanup that I've been intending for a
while. Previously, sqlc made using JSONB in SQLite completely unusable
because it sent back the binary format which you're explicitly not
supposed to parse yourself. I ended up fixing this like a year ago in
[1], but getting a sqlc release out the door took so long that I ended
up forgetting about it.

Here, modify our SQLite definitions so that JSON becomes JSONB, and add
migration to convert existing installation values to the same. Luckily,
this doesn't require a table rewrite because both JSON and JSONB are
SQLite BLOB types.

I didn't want to add a migration version just for SQLite, so to keep
everything in sync I also added a version 7 for Postgres that's just a
no-op with a comment.

[1] sqlc-dev/sqlc#3968
@brandur brandur force-pushed the brandur-sqlite-jsonb-2 branch from 0df950c to bfe5ba0 Compare April 21, 2026 22:56
@brandur
Copy link
Copy Markdown
Contributor Author

brandur commented Apr 21, 2026

@bgentry Thoughts on this? I'm kinda wondering if we should try to bundle it up with #1115 (database cleanup) so we don't waste any migration versions. 007 would still be optional for Postgres since the cleanup wouldn't be strictly necessary.

@brandur brandur requested a review from bgentry April 21, 2026 22:59
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

Successfully merging this pull request may close these issues.

1 participant