Skip to content

Add SQLite integration test for #[sqlx(json)] on TEXT columns#4316

Closed
xiangkaiz wants to merge 1 commit into
transact-rs:mainfrom
xiangkaiz:add-sqlite-json-fromrow-test
Closed

Add SQLite integration test for #[sqlx(json)] on TEXT columns#4316
xiangkaiz wants to merge 1 commit into
transact-rs:mainfrom
xiangkaiz:add-sqlite-json-fromrow-test

Conversation

@xiangkaiz

Copy link
Copy Markdown

Summary

SQLite stores JSON as TEXT. This adds integration test coverage for reading such a column into a FromRow struct field annotated with #[sqlx(json)], decoding it via serde_json.

The #[sqlx(json)] attribute and its SQLite Json<T> decode path already exist; this PR adds the missing test coverage:

  • it_reads_json_from_text_column — selects '{"key": "value"}' from a TEXT column into a struct with #[sqlx(json)] data: serde_json::Value.
  • it_surfaces_invalid_json_as_column_decode_error — invalid JSON surfaces as sqlx::Error::ColumnDecode.

Test plan

  • cargo test -p sqlx --test sqlite-derives (with sqlite,macros,migrate,json features) — all 8 tests pass, including the 2 new ones.
  • Existing derive tests unaffected. No changes to MySQL/PostgreSQL paths.

🤖 Generated with Claude Code

Covers reading a JSON-as-TEXT column into a FromRow struct field
annotated with #[sqlx(json)], and the error path where invalid JSON
surfaces as sqlx::Error::ColumnDecode.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@xiangkaiz xiangkaiz closed this Jun 20, 2026
@xiangkaiz xiangkaiz deleted the add-sqlite-json-fromrow-test branch June 20, 2026 07:18
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