neo4j-contrib / sql2cypher

Experimental SQL to Cypher Transpiler using jooq and cypher-dsl
Apache License 2.0
26 stars 1 forks source link

Add support for predicates / operators #14

Closed jexp closed 7 months ago

jexp commented 1 year ago

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/

lukaseder commented 1 year 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

lukaseder commented 1 year ago

Regarding these:

My suggestion here is:

jexp commented 1 year 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

lukaseder commented 1 year 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> ~="

jexp commented 1 year ago

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

lukaseder commented 1 year ago

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

lukaseder commented 1 year 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

michael-simons commented 7 months ago

Kamino closed and cloned this issue to neo4j/neo4j-jdbc