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
close icon

setRulesFromSql freezes browser window

We have a feature that allows users to input raw SQL to the Query Builder. There is a use case where the user may provide invalid SQL. Most occurances with invalid SQL to the Query Builder rightfully throw a JS error.

However, if the user inputs invalid SQL where a Query Builder ColumnModel group name is used incorrectly as a field name (or missing the separator & field name), the call to setRulesFromSql hangs and freezes the browser window.

We would expect this to return a similar JS error as any other invalid SQL statement provided to Query Builder.

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

Run comment out test1 and run test2 to see the expected JS error. Run test3 to see the bug that freezes the browser window.

Please advise. Thank you!

Luke


3 Replies

YA YuvanShankar Arunagiri Syncfusion Team October 28, 2022 02:54 AM

Hi Luke,


Sorry for the delay.


We have validated your reported query and found an issue in your sample code. We can’t set the rule for parent column in query builder. If we set the columns property to query builder column, then we can’t set the rule for that field, like below user field.

{

      field: 'user',

      label: 'User',

      columns: [

        { field: 'id'label: 'ID'type: 'string' },

        { field: 'name'label: 'Name'type: 'string' },

      ],

    },


We have set rule for only the user.id and user.name field only. It is behavior of the query builder.


Regards,

YuvanShankar A



LA Luke Adams replied to YuvanShankar Arunagiri October 28, 2022 02:03 PM

I'm not sure I understand your explanation.

I recognize that you're not able to create a rule for this SQL:

columndoesnotexist = 'somevalue'


That throws an expected JS error.


I also recognize that you're not able to create a rule for this SQL:

user = 'somevalue'


However, this completely freezes the browser window. Just wanted you to be aware that this isn't being handled gracefully.


We found a hacky workaround by simply prefixing the parent field name with "group_":

{

field: 'group_user',

label: 'User',

columns: [

{ field: 'id', label: 'ID', type: 'string' },

{ field: 'name', label: 'Name', type: 'string' },

],

},


Now it would only be an issue if someone were to input "group_user = 'somevalue'" which is much less likely.


Still an issue that I think should be addressed in Query Builder.


Thanks!



YA YuvanShankar Arunagiri Syncfusion Team November 3, 2022 04:31 AM

Luke, we have confirmed this as an issue with browser window gets freezes for invalid SQL and logged a bug report. The fix will be available at the end of November. You will be informed regarding this once the fix is published.


NOTE: As we stated earlier, we can’t set the rule for a column that has sub-columns like the example below.


Example: "group_user = 'somevalue'"

{

field: 'group_user',

label: 'User',

columns: [

{ field: 'id', label: 'ID', type: 'string' },

{ field: 'name', label: 'Name', type: 'string' },

],

},



Loader.
Live Chat Icon For mobile
Up arrow icon