Fabricio Silva
Fabricio Silva

Reputation: 57

Escaping quotes and diacritics in Neo4j query

Let's say I have the following query passed to Neo4j as string in a C#/.NET application:

MATCH (e)-[:BELONGS_TO]->(t:Tenant) WHERE t.id={id} AND ( e:Unit OR e:UnitInactive ) AND e.name contains {queryName} RETURN e

How do I format the query string to retrieve an specific e.name like "Mary's" or "João", escaping quotes and diacritics and case-insensitive?

Upvotes: 0

Views: 627

Answers (2)

lenhhoxung
lenhhoxung

Reputation: 2746

In case the query is used in a programming language (e.g. python), I think the recommendation way would be using parameter. For instance:

e.name contains $queryName

And when calling the session query:

session.run(query, queryName=NameValue)

Upvotes: 0

jose_bacoy
jose_bacoy

Reputation: 12684

You can treat special characters (diacritics) as regular chars. Then single quote in Mary's can be escaped with \.

For example, in neo4j cypher:

 toLower(e.name) = "joão" OR toLower(e.name) = "mary\'s"

enter image description here

Upvotes: 2

Related Questions