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

Closed
opened 2026-08-05 03:07:56 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/2746
Author: @bcmmbaga
Created: 10/16/2024
Status: Merged
Merged: 10/16/2024
Merged by: @mlsmaycon

Base: mainHead: fix/get-group-by-name-postgres


📝 Commits (3)

📊 Changes

2 files changed (+23 additions, -2 deletions)

View changed files

📝 management/server/sql_store.go (+10 -2)
📝 management/server/sql_store_test.go (+13 -0)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/2746 **Author:** [@bcmmbaga](https://github.com/bcmmbaga) **Created:** 10/16/2024 **Status:** ✅ Merged **Merged:** 10/16/2024 **Merged by:** [@mlsmaycon](https://github.com/mlsmaycon) **Base:** `main` ← **Head:** `fix/get-group-by-name-postgres` --- ### 📝 Commits (3) - [`b97ed40`](https://github.com/netbirdio/netbird/commit/b97ed40960e97dd0480024f39d7705eee85441e9) Cast peers to json on postgres - [`18bfa6f`](https://github.com/netbirdio/netbird/commit/18bfa6f01efe2f30c168c3f9978357a8d679f1ab) add todo note - [`0f01daf`](https://github.com/netbirdio/netbird/commit/0f01daf4b7c97a2ac27ead6d7a93a87286358092) add tests ### 📊 Changes **2 files changed** (+23 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `management/server/sql_store.go` (+10 -2) 📝 `management/server/sql_store_test.go` (+13 -0) </details> ### 📄 Description ## 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 03:07:56 -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#15556