oguimbal / pg-mem

An in memory postgres DB instance for your unit tests
MIT License
1.89k stars 94 forks source link

It should not be required to use a space after a `-` to use an arithmetic operation #393

Open Alexnortung opened 3 months ago

Alexnortung commented 3 months ago

Describe the bug

When using postgres it is not required to use space after a -. It seems that the 100-100 is interpreted as two numbers: 100 and -100. Where it should have been interpreted as an arithmetic operation of 100 minus 100.

💔 Your query failed to parse.
This is most likely due to a SQL syntax error. However, you might also have hit a bug, or an unimplemented feature of pg-mem.
If this is the case, please file an issue at https://github.com/oguimbal/pg-mem along with a query that reproduces this syntax error.

👉 Failed query:

    SELECT 100-100;

💀 Syntax error at line 1 col 11:

  SELECT 100-100
            ^
Unexpected int token: "-100". Instead, I was expecting to see one of the following:

    - A "op_cast" token
    - A "lbracket" token
    - A "op_member" token
    - A "op_membertext" token
    - A "word" token
    - A "word" token
    - A "op_exp" token
    - A "star" token
    - A "op_div" token
    - A "op_mod" token
    - A "op_plus" token
    - A "op_minus" token
    - A "op_additive" token
    - A "kw_not" token
    - A "kw_in" token
    - A "kw_not" token
    - A "op_like" token
    - A "op_ilike" token
    - A "op_not_like" token
    - A "op_not_ilike" token
    - A "kw_like" token
    - A "kw_ilike" token
    - A "ops_others" token
    - A "kw_not" token
    - A "kw_is" token
    - A "kw_notnull" token
    - A "kw_is" token
    - A "kw_isnull" token
    - A "kw_is" token
    - A "word" token
    - A "op_compare" token
    - A "op_eq" token
    - A "op_neq" token
    - A "kw_and" token
    - A "kw_or" token
    - A "kw_as" token
    - A "kw_primary" token
    - A "kw_unique" token
    - A "quoted_word" token
    - A "word" token
    - A "comma" token
    - A "kw_from" token
    - A "kw_where" token
    - A "kw_group" token
    - A "kw_order" token
    - A "kw_for" token
    - A "kw_offset" token
    - A "kw_limit" token
    - A "kw_fetch" token
    - A "kw_union" token
    - A "semicolon" token

To Reproduce

SELECT 100-100

pg-mem version

Used playground (it would be nice if the playground showed the current version :))