mistic100 / jQuery-QueryBuilder

jQuery plugin offering an interface to create complex queries
https://querybuilder.js.org
MIT License
1.68k stars 552 forks source link

Fixed Unexpected 'NUMBER' #880

Closed MinePlay96 closed 3 years ago

MinePlay96 commented 4 years ago

if you had a query with an "IN" with 10 elements or more, the regex of setRulesFromSQL did not match correctly

Merge request checklist

MinePlay96 commented 4 years ago

Hey, I think there's something wrong with the build logic

mistic100 commented 4 years ago

@MinePlay96 can you give more details on what case this is supposed to fix ?

Also add or edit the unit tests (although they don't work on the CI).

MinePlay96 commented 4 years ago
$('#queryBuilder').queryBuilder('setRulesFromSQL', {
    "sql":"Status IN(:Status_1, :Status_2, :Status_3, :Status_4, :Status_5, :Status_6, :Status_7, :Status_8, :Status_9, :Status_10)",
    "params":{
        "Status_1":1,
        "Status_2":2,
        "Status_3":4,
        "Status_4":5,
        "Status_5":6,
        "Status_6":9,
        "Status_7":10,
        "Status_8":11,
        "Status_9":12,
        "Status_10":13
    }
}, 'named');

which would produce the following regex without my adjustments /\:(Status_1|Status_2|Status_3|Status_4|Status_5|Status_6|Status_7|Status_8|Status_9|Status_10)/g This regex would map Status_1 instead of Status_10;. see: https://regex101.com/r/ln3YoL/1