Skip to content

fix(database-pgsql): JSON-encode array bindings before passing to PDO#72

Open
michalbiarda wants to merge 1 commit into
marko-php:developfrom
michalbiarda:fix/pgsql-array-binding-json-encode
Open

fix(database-pgsql): JSON-encode array bindings before passing to PDO#72
michalbiarda wants to merge 1 commit into
marko-php:developfrom
michalbiarda:fix/pgsql-array-binding-json-encode

Conversation

@michalbiarda
Copy link
Copy Markdown

Fixes #71

Summary

  • Detect array values in PgSqlConnection::bindValues() and call json_encode() before binding, so json/jsonb columns receive a valid JSON string instead of the literal "Array"
  • Add a regression test covering the array binding path

Test plan

  • ./vendor/bin/pest packages/database-pgsql/tests/Connection/PgSqlConnectionTest.php — all 29 tests pass including the new one

🤖 Generated with Claude Code

PDO silently casts PHP arrays to the string "Array" when bound as query
parameters. For json/jsonb columns this causes an "invalid input syntax
for type json" error at the database level.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the bug Something isn't working label May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Array values bound as literal "Array" string instead of JSON

1 participant