Skip to content

Use JSONB columns for structured data - #1305

Merged
wu-clan merged 1 commit into
masterfrom
feature/jsonb-columns
Nov 12, 2026
Merged

wu-clan merged 1 commit into
masterfrom
feature/jsonb-columns

Conversation

@wu-clan

@wu-clan wu-clan commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Description

fba 2.0.0 dropped MySQL support, so PostgreSQL is the only database the framework and its plugins run on. The generic sa.JSON type only existed to stay portable across databases, and on PostgreSQL it lands as the json type, which has two limitations:

  • it has no containment operator — json @> jsonb fails with operator does not exist, so an array containment query needs an explicit cast, and casting the column also disables the index
  • it keeps the original text, so every read re-parses the document

postgresql.JSONB stores the parsed form, supports @> and JSONPath directly, and can be indexed with GIN.

The three remaining generic JSON columns in the base apps also carried a data shape that did not match their declared type: the scheduler serialised its arguments with json.dumps before writing them into a JSON column, so the column held a JSON string that had to be decoded again on read.

Changes

  • sys_opera_log.args becomes JSONB, and its annotation matches the dictionary the middleware actually writes
  • task_scheduler.args and task_scheduler.kwargs become JSONB, and the annotations match the list and the dictionary they hold
  • The scheduler writes the arguments and the keyword arguments as structured values instead of pre-serialising them, and the read path drops the extra json.loads

Verification

  • ruff check --no-fix backend/app and ruff format --check backend/app pass
  • The database is reinitialised with fba init, so the columns are created as JSONB directly

@wu-clan
wu-clan force-pushed the feature/jsonb-columns branch from 0070075 to fb8e335 Compare November 12, 2026 06:32
@wu-clan
wu-clan merged commit eea31b7 into master Nov 12, 2026
3 checks passed
@wu-clan
wu-clan deleted the feature/jsonb-columns branch November 12, 2026 06:34
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