← nitronium.dev
SQLite'ta PostgreSQL JSONB operatörlerinin karşılıkları
2026-06-18
PostgreSQL JSONB operatörlerini SQLite'a taşırken her birinin karşılığını bulmak gerekiyor. SQLite'ta bunların tamamı json_extract() ile yapılır.
| PostgreSQL | SQLite |
|---|---|
| context->>'key' | json_extract(context, '$.key') |
| context->'key' | json_extract(context, '$.key') |
| context ? 'key' (key varlığı) | json_extract(context, '$.key') IS NOT NULL |
| context->>'key' != '[]' | json_extract(context, '$.key') != '[]' |
Örnek: PostgreSQL'de
`sql
WHERE context ? 'depends_on' AND context->>'depends_on' != '[]'
`
SQLite'ta:
`sql
WHERE json_extract(context, '$.depends_on') IS NOT NULL
AND json_extract(context, '$.depends_on') != '[]'
`
psql CLI'ı kullanan kodlar da değişiyor: execa("psql", [...]) yerine bun:sqlite veya better-sqlite3 ile doğrudan sorgu. db.prepare(...).all() senkron, await yok.