Skip to content

Use jsonb_path_query_first for jsonExtract with singleValue=true on PostgreSql #6308

@ma-tasnimi

Description

@ma-tasnimi

Querying a json field with jsonExtract in PostgreSQL results in a query with jsonb_path_query. This causes some issues eg. rows that don't contain this field being filtered out. While using jsonb_path_query_first (for scalar values) doesn't have this issue (it returns null).

Current Behaviour

Knex currently generates

select jsonb_path_query("details", '$.data') as "data" from "item"

Expected behaviour

select jsonb_path_query_first("details", '$.data') as "data" from "item"

Steps to Reproduce

knex.from('item').jsonExtract('details', '$.data', 'data', true)

Environment

Knex version: 3.1.0
DB Driver: pg

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions