-
Notifications
You must be signed in to change notification settings - Fork 561
Consider adding a has_flag
option to the comparison operators
#822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hello, |
I'm not sure I can agree with it being basically an equals operation. It's not at all, imho.. but maybe I am missing something here? And could you please point me in the direction of finding more info on what a "post builder transformer" is? |
if you use an "equal" operator you will get "ProductType = 2" then you only have to transform the output to "ProductType & 2 <> 0" it's all to you to do this transformation, it's not an option of the builder I forgot to say that you also have the possibility to implement you own operator check https://querybuilder.js.org/#operators and the "Operator" section of https://querybuilder.js.org/plugins.html#sql-support |
QueryBuilder is a tool, not an end product, what I mean is that you will always have to generate your final query from it's output and not expect it to do all the work. The SQL output was added due to popular demand but it is not the right path when you have specific needs (while working with MongoDB I never used the Mongo output but always generated my queries from the rules tree). |
@mistic100 Thank you for taking the time to respond. I can certainly appreciate your perspective. However, you're not taking into account that in some cases (like mine), we are creating queries for unknown tables. The filters are changed dynamically, because the users of my app can change tables and even choose any random database they want. So I don't know ahead of time which fields are enumerations and which are not, much less which ones are bitwise flags. Having looked at Mongo's reference manual, I can see they also support bitwise operations: I believe the Mongo equivalent of what I want in SQL would be the But... if you're steadfast against adding this option, I guess I'll have to try figure out something else. On the other hand, if it's just because of a lack of time to implement, then why not leave this issue open and label it as help wanted ? |
Hi again, I've been busy with other work, so didn't have time to look at this yet. I was planning on looking into your workaround soon - the one where you said this: "if you use an "equal" operator you will get "ProductType = 2" then you only have to transform the output to "ProductType & 2 <> 0" I was just thinking about this and I realized this surely can't be right at all. Because there is a difference between wanting to check if the enumeration CONTAINS a value or is ONLY that value. Let me give you an example:
So in this real life situation, a ProductType of 2 is "Hotel". Sometimes we want to query if the booking is for hotel ONLY (=2) or sometimes we want to see all bookings that have a hotel and might also have other products like Flight or Tour. Therefore, what you suggested about transforming the equals operation cannot be correct... and additionally, the queries are dynamic. I don't know the structure of the tables ahead of time - we build the filters dynamically based on database INFORMATION_SCHEMA. I hope this clarifies it. |
Hi again, I don't like to keep nagging about this, but your reason given for not wanting to implement it is based on faulty assumptions. I have explained why in the previous post above. Could you please read it very carefully and respond? There is absolutely no way for me to implement this myself unless you add the new operator. If I automatically convert equals to a check for "has flag", then I lose the option for equals. I need BOTH options. And this does not matter if it's using SQL output or your json filters array.. it's the exact same problem. If I am wrong somehow, or if you do understand the problem and still don't want to implement it anyway, then could you please still respond and give me more info? Because as I said; I don't believe that the reasons you provided before were based on a proper understanding of the situation. Please correct me if I am wrong. |
Sorry I just don't have the time to analyse this issue. Feel free to submit a proper merge request. |
Preferably has a plugin. |
Thanks again for the response. It's not really that complex. The difference is basically this:
vs.
The first one is done with a normal equals operator and the second one is done with a bitwise operator. Mongo supports this as well, so you won't have an issue there. As far as I can tell, this would be impossible to do without adding a new So, please reopen this.. because it's a very important operator for people who store flag values in their data. |
Considering nobody ever asked this I can safely say it is important for you. |
Thank you kindly for reopening this. I appreciate that. I'm not sure why you think I am taking it personally. I just didn't want you to close the issue based on a faulty understanding of the issue. Surely that is a reasonable request? As for wanting it done immediately, that is certainly not the case. I said I totally 100% understand if you don't have the time to do it.. and only want you to leave this open so someone (either yourself or someone else in the community) may eventually get around to it. Again, thank you for reopening this issue and also just for making such a useful jQuery plugin as this is and sharing it with everyone in the first place. |
Would you please consider adding a
has_flag
option to the comparison operators to support bitwise flags? For example, let's say one of our columns called, "ProductType" can hold a value representing one or more of the following flag values:So if a booking record in my database has a value of 3 for the ProductType, this means it was a Flight + Hotel booking. Now if I want to query all records where there is a hotel component (for example), then I need to produce a query as follows:
Having a
has_flag
operator would be good here. As for UI, we could use checkboxes. If multiple values are checked, you would produce multiple WHERE clauses.The text was updated successfully, but these errors were encountered: