Skip to content

Conversation

Nithishvb
Copy link

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Closes: #5539

This PR includes Automatic JSON handling for SQL parameters: object/array values are now auto-serialized to JSON for execution, enabling seamless insertion and querying of JSON/JSONB columns without manual conversion or API changes.

Related

  • Related Issue #
  • Closes #

@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Sep 21, 2025
Copy link

changeset-bot bot commented Sep 21, 2025

🦋 Changeset detected

Latest commit: aea2875

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@effect/sql-drizzle Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

if (e === null || e === undefined) return e
if (typeof e !== "string") return e
const s = e.trim()
if (!(s.startsWith("{") || s.startsWith("["))) return e
Copy link
Contributor

@tim-smart tim-smart Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work if you have a non-json param that starts with these characters?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @tim-smart , yes if a non-JSON param happens to start with { or [, it will attempt JSON.parse. Since parsing will fail, it falls into the catch block and simply returns the original string unchanged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I don't think this is robust enough to merge sorry. I'm not very familiar with drizzle, but you would need to somehow identify params that are only for json columns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

From Discord: Issue with JSONB Column Handling in @effect/sql-drizzle with PostgreSQL

2 participants