We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

setRulesFromSql with full SQL statement

Pasting a full SQL statement appears to parse the WHERE condition and render the appropriate rules in Query Builder.

We do run a validation/cleanup on the rules generated to remove invalid/incomplete rules (see stackblitz example).

We're running into an issue when the SELECT statement contains a matching column name. This then doesn't render the rule correctly for that matching column name.

See 3 example SQL string tests provided at https://stackblitz.com/edit/angular-ivy-quzld2?file=src%2Fapp%2Fapp.component.ts

Run test1 and test2 to see the expected behavior generating the correct rules. Run test3 to see the bug that does not generate the correct rule.

Please advise.

Also, we're curious about our approach to set rules by SQL and then manually validate and re-set rules. Does this look reasonable? Is there a better/alternative approach? Or possibly some cleanup that you guys would do internally to make this step unnecessary?

Thank you!

Luke


3 Replies

YA YuvanShankar Arunagiri Syncfusion Team October 28, 2022 07:44 AM UTC

Hi Luke,


Sorry for the delay.


We have validated your reported query and currently we don’t have support for checking the valid\Invalid SQL query. Currently we can set rule as SQL with field, operator, and value like below UG sample.

UG link: https://ej2.syncfusion.com/angular/documentation/query-builder/import-export/#importing-from-sql

And setRulesFromSql method does not support for below SQL query.

var test1 = 'select * from tablename where admin = false';


We need to validate more on this issue, so we will update further details on November 1st, 2022.


Regards,

YuvanShankar A



LA Luke Adams October 28, 2022 07:06 PM UTC

Ok thank you for your response.



YA YuvanShankar Arunagiri Syncfusion Team November 1, 2022 12:07 PM UTC

The query builder only supports the SQL "where condition". It does not support the below SQL query.

var test1 = 'select * from tablename where admin = false';



Loader.
Live Chat Icon For mobile
Up arrow icon