Open tgroutars opened 4 years ago
@jamesfer
My current workaround it to use a double negative assertion, so instead of trying to build
condition1 AND condition2 AND condition3
I do:
NOT (NOT condition1 OR NOT condition2 OR NOT condition3)
But let's admit it's not very pretty 😅
Hey Thomas,
That's a good pickup. Definitely a bug that I will try to look at.
In the meantime, the only other workaround I can recommend is to add a space after the property name for each condition you want to check on. Very hacky, but it may or may not be a cleaner workaround than the one you came up with:
new cypher.Query().where({
someNode: {
someProperty: cypher.greaterThan(1),
['someProperty ']: cypher.lessThan(100),
},
}).toString();
// WHERE someNode.someProperty > $someProperty AND someNode.someProperty < $someProperty2;
I believe #99 and #14 would fix this issue, allowing you to write:
new cypher.Query().where({
someNode: {
someProperty: cypher.and([cypher.greaterThan(1), cypher.lessThan(100)]),
},
}).toString();
// WHERE someNode.someProperty > $someProperty AND someNode.someProperty < $someProperty2;
Hey Thomas,
That's a good pickup. Definitely a bug that I will try to look at.
In the meantime, the only other workaround I can recommend is to add a space after the property name for each condition you want to check on. Very hacky, but it may or may not be a cleaner workaround than the one you came up with:
new cypher.Query().where({ someNode: { someProperty: cypher.greaterThan(1), ['someProperty ']: cypher.lessThan(100), }, }).toString(); // WHERE someNode.someProperty > $someProperty AND someNode.someProperty < $someProperty2;
Oh I didn't think of that, that's definitely a better workaround than what I did 😄
I can try to open a PR for https://github.com/jamesfer/cypher-query-builder/issues/14 next week
Thanks a lot for this lib btw, it has already helped a lot 🙏
Seems like a stupid question, but how do I generate a query like this one:
I want to be able to add any type of conditions, not just
<
and>
, so please don't tell me to usebetween
😛Since you need to pass an object to
and
, it seems like there's no way to combine multiple conditions on a single property