ygrek / sqlgg

SQL Guided (code) Generator
https://ygrek.org/p/sqlgg/
GNU General Public License v2.0
62 stars 20 forks source link

`LIKE` operator precedence #63

Closed cyberhuman closed 5 years ago

cyberhuman commented 5 years ago

the following does not work:

create table test ( x text, y text );
select * from test where x like 'hello%' or y like 'world%';
resolve_types failed with Failure("types do not match : Bool -> Bool -> Bool applied to (Text, Bool)") at:
`Func ((Text -> Text -> Bool,
        [`Value (Text);
          `Func ((Bool -> Bool -> Bool,
                  [`Value (Text);
                    `Func ((Text -> Text -> Bool,
                            [`Value (Text); `Value (Text)]))
                    ]))
          ]))
Failed : select * from test where x like 'hello%' or y like 'world%'
Fatal error: exception Failure("types do not match : Bool -> Bool -> Bool applied to (Text, Bool)")

but this does work:

create table test ( x text, y text );
select * from test where (x like 'hello%') or y like 'world%';
ygrek commented 5 years ago

Thanks for report! FTR menhir has an awesome menhir --interpret --interpret-show-cst mode which helps to debug this easier.