lovasoa / SQLpage

SQL-only webapp builder, empowering data analysts to build websites and applications quickly
https://sql.datapage.app
MIT License
1.29k stars 69 forks source link

MySQL's `REGEXP` binary operator is not supported #107

Closed accforgithubtest closed 10 months ago

accforgithubtest commented 10 months ago

I have gotten sqlpage to work with mysql, and able to see the data on UI for a bunch of queries.

However, any query with a REGEXP in it seems to cause the error -

Backtrace
sql parser error: Expected an SQL statement, found: REGEXP at Line: 26, Column 15
SQLPage could not parse and prepare this SQL statement

Is REGEXP somehow not supported in sqlpage ? [I have confirmed the exact same query to be working outside sqlpage.]

lovasoa commented 10 months ago

SQLPage needs to parse your queries in order to know which parameters to extract from the user's request to pass to the database, and to implement SQLPage functions.

To do that, it uses a very powerful and versatile SQL parser: sqlparser-rs. It's the same parser that is used in InfluxDB and Apache DataFusion, among others.

However, it may happen that some syntax that is valid in one database is not supported by the parser. When this happens, you can open an issue here with an example failing query, and we will implement it upstream in sqlparser. In this case, I opened this issue.

In the meantime, you can use the traditional function syntax for matching regular expressions:

select regexp_like('hello', '^hell');

instead of

select 'hello' REGEXP '^hell';
accforgithubtest commented 10 months ago

Thanks for the suggestions and also raising the issue, will give this a spin ! Thank you.

lovasoa commented 10 months ago

My patch to sqlparser-rs was merged, we'll soon have support for the REGEXP operator in sqlpage :confetti_ball:

lovasoa commented 10 months ago

fix released in v0.15

accforgithubtest commented 10 months ago

thanks @lovasoa ! Just tried this with latest version and it works !