Skip to content

normalize params for postgres replaces literal question marks #216

@nimonian

Description

@nimonian

function normalizeParams(sql: string) {
let i = 0;
return sql.replace(/\?/g, () => `$${++i}`);
}

see also nuxt/content#3682

this method attempts to normalise ? params for postgres, but ends up replacing literal question marks too

i came across this when using nuxt/content and my markdown files had $1, $2, ... where question marks should have been

of course, nuxt/content uses sqlite by default during local development so i didn't discover this until i saw the page in production :)

anyways, i think the fix here is to beef up normalizeParams to detect exactly the ? which are params and leave literal question marks alone

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions