neo4j / neo4j-jdbc

Official Neo4j JDBC Driver
http://neo4j.github.io/neo4j-jdbc/
Apache License 2.0
135 stars 53 forks source link

Add support for predicates / operators #518

Open michael-simons opened 9 months ago

michael-simons commented 9 months ago

From sql2cypher created by jexp: neo4j-contrib/sql2cypher#14

Conditional Operators / Predicates

https://neo4j.com/docs/cypher-manual/current/clauses/where/#boolean-operations

Predicate functions https://neo4j.com/docs/cypher-manual/current/functions/predicate/

michael-simons commented 9 months ago
  • Less Than Equal, Greater Than Equal (missing in jooq @lukaseder)

See QOM.Le, QOM.Ge

  • TRUE / FALSE (are they in SQL @lukaseder?)

Yes, there are org.jooq.True, org.jooq.False, and org.jooq.Null. They should probably be reflected in the QOM API for better discoverablity: https://github.com/jOOQ/jOOQ/issues/14537

michael-simons commented 9 months ago

Regarding these:

My suggestion here is:

michael-simons commented 9 months ago

for LIKE: might even make sense to do the replace in cypher, so that non-literal values (parameters) or expressions are also handled correctly.

the only tricky bit is escaping for regexp, perhaps something like:

reduce(s=str, rep IN [['?','\?'], ...['_','.'],['%','.*']] | s = replace(s, rep[0],rep[1])

or alternatively spell it out with a replace cascade

michael-simons commented 9 months ago

might even make sense to do the replace in cypher, so that non-literal values (parameters) or expressions are also handled correctly.

That's what I meant by "Otherwise turn LIKE into a regex: <lhs> ~="

michael-simons commented 9 months ago

Ah you didn't mean replacing the string in the transpiler but in the generated statement. Yep, sgtm.

michael-simons commented 9 months ago

Well, if there's a constant (org.jooq.Param), then that can be processed in the translator. Otherwise, it simply cannot.

michael-simons commented 9 months ago

I've added support for BETWEEN SYMMETRIC too. Dogfooding has shown that the QOM API needed a significant refactoring: https://github.com/jOOQ/jOOQ/issues/14546, so I've moved the tag