Skip to content
This repository was archived by the owner on Sep 8, 2023. It is now read-only.
This repository was archived by the owner on Sep 8, 2023. It is now read-only.

escape.ident should quote identifiers that have capital letters #22

@jedwards1211

Description

@jedwards1211

Expected behavior: escape.ident('Foo') === '"Foo"'
Actual behavior: escape.ident('Foo') === 'Foo'

If we had pool.query(`CREATE DATABASE ${escape.ident(name)}`), and name is 'Foo', the created database would have the name foo instead since Postgres lowercases unquoted identifiers.

I'm not even sure if name.toLowerCase() !== name would be a sufficient to decide whether to quote because who knows if JS lowercases all the same non-Latin characters as Postgres does? I think the safest bet would be to add double quotes if the name doesn't match /^[a-z_][a-z0-9_$]*$/ (case sensitive)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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