Skip to content

[BUG]: live.query silently binds positional params in textual order #1055

Description

@nightridefm

https://github.com/electric-sql/pglite/blob/main/packages/pglite/src/utils.ts#L53-L56

formatQuery emits %NL instead of %N$L
%NL is 'pad with whitespace to width=N'
NOT 'use argument at position N'

SELECT format('%2L %1L',  'first', 'second');  -- 'first' 'second' (sequential, incorrect)
SELECT format('%2$L %1$L','first', 'second');  -- 'second' 'first' (positional, correct)
SELECT format('%1L %1L',  'only');             -- ERROR: too few arguments for format()
SELECT format('%1$L %1$L','only');             -- 'only' 'only'
SELECT format('%20L %1L',  'first', 'second'); --              'first' 'second' (13 leading whitespace)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions