[PR #2746] Fix JSON function compatibility for SQLite and PostgreSQL #20385

Open
opened 2026-08-05 05:07:11 -04:00 by saavagebueno · 0 comments
Owner

Original Pull Request: https://github.com/netbirdio/netbird/pull/2746

State: closed
Merged: Yes


Describe your changes

This PR resolves the issue with json_array_length compatibility between SQLite and PostgreSQL. It adjusts the query to conditionally cast types:

  • PostgreSQL: Casts to json with ::json.
  • SQLite: Uses the text representation directly.

Closes #2745

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary
**Original Pull Request:** https://github.com/netbirdio/netbird/pull/2746 **State:** closed **Merged:** Yes --- ## Describe your changes This PR resolves the issue with `json_array_length` compatibility between SQLite and PostgreSQL. It adjusts the query to conditionally cast types: - **PostgreSQL**: Casts to `json` with `::json`. - **SQLite**: Uses the text representation directly. ## Issue ticket number and link Closes #2745 ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) - [ ] Extended the README / documentation, if necessary
saavagebueno added the pull-request label 2026-08-05 05:07:11 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#20385