Skip to content

Any non-keyword word is considered as identifier #189

Closed

Description

@vladshcherbin

Describe the bug

insert into "brands" ("name") values ('Aston Martin') returning "id", "name"

In this example returning keyword is not in keywords list and is considered as identifier.

Expected behavior
Any non-keyword should be considered unknown or all keywords should be added to the keywords list.

All keywords can be taken from postgres docs

Screenshots

image

sql-highlight (please complete the following information):

  • Version: 5.0.0-beta.2

Activity

  1. Qtax commented on Mar 12, 2024

    @Qtax
    Contributor

    This is also an issue for any non-postgres SQL dialect that has more/some other keywords.

  2. wkeese commented on Apr 6, 2024

    @wkeese
    Contributor

    Any non-keyword should be considered unknown

    If we did that though, then no strings would be marked as identifiers.

    or all keywords should be added to the keywords list... All keywords can be taken from postgres docs

    I guess that's a better argument, although I cringe to think that in a string like below, "a" and "c" would be marked as keywords rather than identifiers:

    select * from tab where a > c

    The current architecture (doing everything by regexp) has inherent limitations, so there need to be some compromises. It seems like adding all those strings as keywords might make things worse (overall) rather than better.

  3. wkeese commented on Apr 6, 2024

    @wkeese
    Contributor

    PS: I guess what I'm saying is that it's only safe to list reserved keywords in the keywords section (and "returning" is non-reserved).

  4. scriptcoded commented on Jul 2, 2024

    @scriptcoded
    Owner

    Hey there. I think to avoid the odd cases such as a > c we'll just keep accepting suggestions for new keywords for the time being. The returning keyword was added in #188 so I'll mark this as closed.

  5. kodi commented on Mar 18, 2025

    @kodi

    Another question,

    I am running into problems, with

    insert into "schema"."tbl_name"...

    where schema.tbl_name will be considered string instead of identifier.
    you can see the same thing happening here with "brands"

  6. wkeese commented on Mar 20, 2025

    @wkeese
    Contributor

    @kodi - I think that's just how it works; the whole architecture is based on regexps so there's no way to differentiate between the two strings in this example:

    select * from "emp" where name = "Bill"
    

    Actually I'm surprised you can quote schema or table names at all. Can you quote column names too? Given a command like below, how could a database know that "name" is a column but "Bill" is a literal string?

    select * from "emp where "name" = "Bill"
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    no-stalePrevent making as stale

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions