From 64131d235e0c970147a0a1d5c697c4e76843e400 Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Sat, 9 Sep 2023 14:38:24 +0530 Subject: [PATCH] Use $param instead of the old parameter syntax {param} Use $param instead of the old parameter syntax {param} which is no longer supported #449 --- .../groovy/grails/neo4j/Neo4jEntity.groovy | 4 ++-- .../gorm/neo4j/GraphPersistentEntity.groovy | 12 ++++++------ .../datastore/gorm/neo4j/Neo4jSession.java | 9 +++------ .../gorm/neo4j/api/Neo4jGormStaticApi.groovy | 10 +++++----- .../Neo4jAssociationQueryExecutor.groovy | 2 +- .../gorm/neo4j/engine/Neo4jQuery.groovy | 18 +++++++++--------- .../gorm/tests/CypherQueryStringSpec.groovy | 14 +++++++------- .../grails/gorm/tests/ManyToManySpec.groovy | 2 +- .../groovy/grails/gorm/tests/MiscSpec.groovy | 10 +++++----- .../gorm/tests/OneToManyUpdateSpec.groovy | 4 ++-- .../tests/multitenancy/MultiTenancySpec.groovy | 4 ++-- .../grails/gorm/tests/path/PathSpec.groovy | 2 +- .../gorm/neo4j/ApiExtensionsSpec.groovy | 2 +- 13 files changed, 45 insertions(+), 48 deletions(-) diff --git a/grails-datastore-gorm-neo4j/src/main/groovy/grails/neo4j/Neo4jEntity.groovy b/grails-datastore-gorm-neo4j/src/main/groovy/grails/neo4j/Neo4jEntity.groovy index fcbace07..8da26ded 100644 --- a/grails-datastore-gorm-neo4j/src/main/groovy/grails/neo4j/Neo4jEntity.groovy +++ b/grails-datastore-gorm-neo4j/src/main/groovy/grails/neo4j/Neo4jEntity.groovy @@ -148,7 +148,7 @@ trait Neo4jEntity implements GormEntity, DynamicAttributes { GormEnhancer.findDatastore(getClass()).withSession { Neo4jSession session -> Map arguments if (session.getDatastore().multiTenancyMode == MultiTenancySettings.MultiTenancyMode.DISCRIMINATOR) { - if (!queryString.contains("{tenantId}")) { + if (!queryString.contains("\$tenantId")) { throw new TenantNotFoundException("Query does not specify a tenant id, but multi tenant mode is DISCRIMINATOR!") } else { arguments = new LinkedHashMap() @@ -265,7 +265,7 @@ trait Neo4jEntity implements GormEntity, DynamicAttributes { private void includeTenantIdIfNecessary(Neo4jSession session, String queryString, Map paramsMap) { if ((this instanceof MultiTenant) && session.getDatastore().multiTenancyMode == MultiTenancySettings.MultiTenancyMode.DISCRIMINATOR) { - if (!queryString.contains("{tenantId}")) { + if (!queryString.contains("\$tenantId")) { throw new TenantNotFoundException("Query does not specify a tenant id, but multi tenant mode is DISCRIMINATOR!") } else { paramsMap.put(GormProperties.TENANT_IDENTITY, Tenants.currentId(Neo4jDatastore)) diff --git a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/GraphPersistentEntity.groovy b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/GraphPersistentEntity.groovy index 7489b97c..65148b40 100644 --- a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/GraphPersistentEntity.groovy +++ b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/GraphPersistentEntity.groovy @@ -36,7 +36,7 @@ class GraphPersistentEntity extends AbstractPersistentEntity { public static final String LABEL_SEPARATOR = ':' protected static final String MATCH = "MATCH %s" - protected static final String MATCH_ID = "$MATCH WHERE %s = {id}" + protected static final String MATCH_ID = "$MATCH WHERE %s = \$id" protected final NodeConfig mappedForm protected final Collection staticLabels = [] protected Collection labelObjects @@ -183,7 +183,7 @@ class GraphPersistentEntity extends AbstractPersistentEntity { */ String getBatchCreateStatement() { if(this.batchCreateStatement == null) { - this.batchCreateStatement = formatBatchCreate("{${batchId}}") + this.batchCreateStatement = formatBatchCreate("\$${batchId}") } return batchCreateStatement } @@ -215,10 +215,10 @@ class GraphPersistentEntity extends AbstractPersistentEntity { /** * Formats a dynamic association query * @param variable The variable to use - * @return The query which accepts an {id} argument + * @return The query which accepts an $id argument */ String formatDynamicAssociationQuery(String variable = CypherBuilder.NODE_VAR) { - """${formatMatch(variable)}-[r]-(o) WHERE ${formatId(variable)} = {${GormProperties.IDENTITY}} RETURN type(r) as relType, startNode(r) = $variable as out, r.sourceType as sourceType, r.targetType as targetType, {ids: collect(${formatId("o")}), labels: collect(labels(o))} as values""" + """${formatMatch(variable)}-[r]-(o) WHERE ${formatId(variable)} = \$${GormProperties.IDENTITY} RETURN type(r) as relType, startNode(r) = $variable as out, r.sourceType as sourceType, r.targetType as targetType, {ids: collect(${formatId("o")}), labels: collect(labels(o))} as values""" } /** @@ -300,9 +300,9 @@ class GraphPersistentEntity extends AbstractPersistentEntity { StringBuilder builder = new StringBuilder( formatMatchId(variable) ) Class clazz = Long if(isVersioned() && hasProperty(GormProperties.VERSION, clazz)) { - builder.append(" AND ${variable}.version={version}") + builder.append(" AND ${variable}.version=\$version") } - builder.append(" SET ").append(variable).append(" +={props}") + builder.append(" SET ").append(variable).append(" +=\$props") Set keysToRemove = [] for(key in props.keySet()) { Object v = props.get(key) diff --git a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/Neo4jSession.java b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/Neo4jSession.java index 57bd1e40..d8185bba 100644 --- a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/Neo4jSession.java +++ b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/Neo4jSession.java @@ -665,7 +665,7 @@ public void buildEntityCreateOperation(StringBuilder createCypher, String index, Map> dynamicRelProps = amendMapWithUndeclaredProperties(graphEntity, simpleProps, obj, getMappingContext()); final String labels = graphEntity.getLabelsWithInheritance(obj); - String cypher = String.format("(n" + index + "%s {props" + index + "})", labels); + String cypher = String.format("(n" + index + "%s $props" + index + ")", labels); createCypher.append(cypher); params.put("props" + index, simpleProps); @@ -820,12 +820,9 @@ public static boolean isCollectionWithPersistentEntities(Object o, MappingContex if (!(o instanceof Collection)) { return false; } else { - Collection c = (Collection) o; - for (Object obj : c) { - if (mappingContext.isPersistentEntity(obj)) return true; - } + @SuppressWarnings("unchecked") Collection c = (Collection) o; + return c.stream().anyMatch(mappingContext::isPersistentEntity); } - return false; } diff --git a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/api/Neo4jGormStaticApi.groovy b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/api/Neo4jGormStaticApi.groovy index 2212e5cc..f37ebded 100644 --- a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/api/Neo4jGormStaticApi.groovy +++ b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/api/Neo4jGormStaticApi.groovy @@ -258,7 +258,7 @@ class Neo4jGormStaticApi extends GormStaticApi { Relationship relationship = null if(from != null && to != null) { String query = """MATCH (from)-[r]-(to) -WHERE ${fromEntity.formatId(RelationshipPersistentEntity.FROM)} = {start} AND ${toEntity.formatId(RelationshipPersistentEntity.TO)} = {end} +WHERE ${fromEntity.formatId(RelationshipPersistentEntity.FROM)} = \$start AND ${toEntity.formatId(RelationshipPersistentEntity.TO)} = \$end RETURN r LIMIT 1""" List results = executeQuery(query, [start:from.ident(), end:to.ident()]) @@ -291,7 +291,7 @@ LIMIT 1""" String skip = params.offset ? " SKIP ${Integer.valueOf(params.offset.toString())}" : '' String limit = params.max ? " LIMIT ${Integer.valueOf(params.max.toString())}" : '' String query = """MATCH (from)-[r]-(to) -WHERE ${fromEntity.formatId(RelationshipPersistentEntity.FROM)} = {start} AND ${toEntity.formatId(RelationshipPersistentEntity.TO)} = {end} +WHERE ${fromEntity.formatId(RelationshipPersistentEntity.FROM)} = \$start AND ${toEntity.formatId(RelationshipPersistentEntity.TO)} = \$end RETURN DISTINCT(r)$skip$limit""" List results = (List) executeQuery(query, [start:from.ident(), end:to.ident()]) @@ -370,7 +370,7 @@ RETURN DISTINCT(r), from, to$skip$limit""" toEntity.formatNode(RelationshipPersistentEntity.TO) }, p = shortestPath((from)-[*..$maxDistance]-(to)) WHERE ${ fromEntity.formatId(RelationshipPersistentEntity.FROM) - } = {start} AND ${toEntity.formatId(RelationshipPersistentEntity.TO)} = {end} RETURN p""" + } = \$start AND ${toEntity.formatId(RelationshipPersistentEntity.TO)} = \$end RETURN p""" Result result = cypherStatic(query, [start: fromId, end: toId]) if(result.hasNext()) { Record record = result.next() @@ -452,7 +452,7 @@ RETURN DISTINCT(r), from, to$skip$limit""" queryString = query.toString() } if (persistentEntity.isMultiTenant() && session.getDatastore().multiTenancyMode == MultiTenancySettings.MultiTenancyMode.DISCRIMINATOR) { - if (!queryString.contains("{tenantId}")) { + if (!queryString.contains("\$tenantId")) { throw new TenantNotFoundException("Query does not specify a tenant id, but multi tenant mode is DISCRIMINATOR!") } else { Map paramsMap = new LinkedHashMap<>() @@ -511,7 +511,7 @@ RETURN DISTINCT(r), from, to$skip$limit""" private void includeTenantIdIfNecessary(Neo4jSession session, String queryString, Map paramsMap) { if (persistentEntity.isMultiTenant() && session.getDatastore().multiTenancyMode == MultiTenancySettings.MultiTenancyMode.DISCRIMINATOR) { - if (!queryString.contains("{tenantId}")) { + if (!queryString.contains("\$tenantId")) { throw new TenantNotFoundException("Query does not specify a tenant id, but multi tenant mode is DISCRIMINATOR!") } else { paramsMap.put(GormProperties.TENANT_IDENTITY, Tenants.currentId(Neo4jDatastore)) diff --git a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/Neo4jAssociationQueryExecutor.groovy b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/Neo4jAssociationQueryExecutor.groovy index ef6f71aa..7c5655e6 100644 --- a/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/Neo4jAssociationQueryExecutor.groovy +++ b/grails-datastore-gorm-neo4j/src/main/groovy/org/grails/datastore/gorm/neo4j/engine/Neo4jAssociationQueryExecutor.groovy @@ -111,7 +111,7 @@ class Neo4jAssociationQueryExecutor implements AssociationQueryExecutor() { @@ -261,7 +261,7 @@ class Neo4jQuery extends Query { CypherExpression handle(GraphPersistentEntity entity, Query.Like criterion, CypherBuilder builder, String prefix) { int paramNumber = addBuildParameterForCriterion(builder, entity, criterion) String operator = handleLike(criterion, builder, paramNumber, false) - return new CypherExpression(entity.formatProperty(prefix, criterion.property), "{$paramNumber}", operator) + return new CypherExpression(entity.formatProperty(prefix, criterion.property), "\$$paramNumber", operator) } }, (Query.ILike): new CriterionHandler() { @@ -271,7 +271,7 @@ class Neo4jQuery extends Query { int paramNumber = addBuildParameterForCriterion(builder, entity, criterion) String operator = handleLike(criterion, builder, paramNumber, true) String propertyRef = entity.formatProperty(prefix, criterion.property) - String parameterRef = "{$paramNumber}" + String parameterRef = "\$$paramNumber" if(operator != CriterionHandler.OPERATOR_LIKE) { propertyRef = "lower($propertyRef)" parameterRef = "lower($parameterRef)" @@ -284,7 +284,7 @@ class Neo4jQuery extends Query { @CompileStatic CypherExpression handle(GraphPersistentEntity entity, Query.RLike criterion, CypherBuilder builder, String prefix) { int paramNumber = addBuildParameterForCriterion(builder, entity, criterion) - return new CypherExpression(entity.formatProperty(prefix, criterion.property), "{$paramNumber}", CriterionHandler.OPERATOR_LIKE) + return new CypherExpression(entity.formatProperty(prefix, criterion.property), "\$$paramNumber", CriterionHandler.OPERATOR_LIKE) } }, (Query.In): new CriterionHandler() { @@ -313,7 +313,7 @@ class Neo4jQuery extends Query { lhs = graphPersistentEntity.formatProperty(prefix, criterion.property) } builder.replaceParamAt(paramNumber, convertEnumsInList(values)) - return new CypherExpression(lhs, "{$paramNumber}", CriterionHandler.OPERATOR_IN) + return new CypherExpression(lhs, "\$$paramNumber", CriterionHandler.OPERATOR_IN) } }, (Query.IsNull): new CriterionHandler() { @@ -366,7 +366,7 @@ class Neo4jQuery extends Query { Neo4jMappingContext mappingContext = (Neo4jMappingContext)entity.mappingContext int paramNumberFrom = builder.addParam( mappingContext.convertToNative(criterion.from) ) int parmaNumberTo = builder.addParam( mappingContext.convertToNative(criterion.to) ) - new CypherExpression( "{$paramNumberFrom}<=${prefix}.$criterion.property and ${prefix}.$criterion.property<={$parmaNumberTo}") + new CypherExpression( "\$$paramNumberFrom<=${prefix}.$criterion.property and ${prefix}.$criterion.property<=\$$parmaNumberTo") } }, (Query.SizeLessThanEquals): SizeCriterionHandler.LESS_THAN_EQUALS, @@ -772,7 +772,7 @@ class Neo4jQuery extends Query { } } - return new CypherExpression(lhs, "{$paramNumber}", operator) + return new CypherExpression(lhs, "\$$paramNumber", operator) } } @@ -832,7 +832,7 @@ class Neo4jQuery extends Query { int paramNumber = addBuildParameterForCriterion(builder, entity, criterion) Association association = entity.getPropertyByName(criterion.property) as Association builder.addMatch("(${prefix})${RelationshipUtils.matchForAssociation(association)}() WITH ${prefix},count(*) as count") - return new CypherExpression(CriterionHandler.COUNT, "{$paramNumber}", operator) + return new CypherExpression(CriterionHandler.COUNT, "\$$paramNumber", operator) } } diff --git a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/CypherQueryStringSpec.groovy b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/CypherQueryStringSpec.groovy index 54ab6cd8..42465a66 100644 --- a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/CypherQueryStringSpec.groovy +++ b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/CypherQueryStringSpec.groovy @@ -28,8 +28,8 @@ class CypherQueryStringSpec extends GormDatastoreSpec { setupDomain() when: - int result = Club.executeUpdate("MATCH (n) where n.name = {name} SET n.ground = {ground}", [name:'FC Bayern Muenchen', ground:"Alliance Arena"]) - def club = Club.find("MATCH (n) where n.name = {1} RETURN n", 'FC Bayern Muenchen') + int result = Club.executeUpdate("MATCH (n) where n.name = \$name SET n.ground = \$ground", [name:'FC Bayern Muenchen', ground:"Alliance Arena"]) + def club = Club.find("MATCH (n) where n.name = \$1 RETURN n", 'FC Bayern Muenchen') then: result == 1 @@ -50,7 +50,7 @@ class CypherQueryStringSpec extends GormDatastoreSpec { club.teams.size() == 2 when:"A find method is executed with map arguments" - club = Club.find("MATCH (n) where n.name = {name} RETURN n", [name:'FC Bayern Muenchen']) + club = Club.find("MATCH (n) where n.name = \$name RETURN n", [name:'FC Bayern Muenchen']) then:"The result is correct" club instanceof Club @@ -60,7 +60,7 @@ class CypherQueryStringSpec extends GormDatastoreSpec { when:"A find method is executed on the inverse side" session.clear() - def team = Team.find("MATCH (n) where n.name = {name} RETURN n", [name:'FCB Team 1']) + def team = Team.find("MATCH (n) where n.name = \$name RETURN n", [name:'FCB Team 1']) then:"The result is correct" team instanceof Team @@ -95,7 +95,7 @@ class CypherQueryStringSpec extends GormDatastoreSpec { when:"A find method is executed with map arguments" session.clear() - clubs = Club.findAll("MATCH (n) where n.name = {name} RETURN n", [name:'FC Bayern Muenchen']) + clubs = Club.findAll("MATCH (n) where n.name = \$name RETURN n", [name:'FC Bayern Muenchen']) then:"The result is correct" clubs.size() == 1 @@ -128,7 +128,7 @@ class CypherQueryStringSpec extends GormDatastoreSpec { setupDomain() when:"A cypher query is executed" - def result = Club.executeCypher("MATCH (n) where n.name = {name} RETURN n", [name:'FC Bayern Muenchen']) + def result = Club.executeCypher("MATCH (n) where n.name = \$name RETURN n", [name:'FC Bayern Muenchen']) Club club = result as Club then:"the conversion is correct" @@ -138,7 +138,7 @@ class CypherQueryStringSpec extends GormDatastoreSpec { club.teams.size() == 2 when:"A cypher query is executed" - result = Club.executeCypher("MATCH (n) where n.name = {name} RETURN n", [name:'FC Bayern Muenchen']) + result = Club.executeCypher("MATCH (n) where n.name = \$name RETURN n", [name:'FC Bayern Muenchen']) List clubs = result.toList(Club) then:"the conversion is correct" diff --git a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/ManyToManySpec.groovy b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/ManyToManySpec.groovy index eedabe6d..108e05e7 100644 --- a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/ManyToManySpec.groovy +++ b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/ManyToManySpec.groovy @@ -227,7 +227,7 @@ class ManyToManySpec extends GormDatastoreSpec { fetchedFelix.friends.size() == 100 when: "we have 100 relationships" - def result = session.transaction.nativeTransaction.run("MATCH (:BidirectionalFriends {name:{1}})<-[:FRIENDS]-(o) return count(o) as c", ["1":"felix"]) + def result = session.transaction.nativeTransaction.run("MATCH (:BidirectionalFriends {name:\$1})<-[:FRIENDS]-(o) return count(o) as c", ["1":"felix"]) then: IteratorUtil.single(result)["c"].asNumber() == 100 diff --git a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/MiscSpec.groovy b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/MiscSpec.groovy index 9fae7545..30114bfe 100644 --- a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/MiscSpec.groovy +++ b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/MiscSpec.groovy @@ -174,7 +174,7 @@ class MiscSpec extends GormDatastoreSpec { def session = boltDriver.session() def tx = session.beginTransaction() - tx.run("CREATE (n1:Team {props})", [props:[name:"Team $count".toString()]]) + tx.run("CREATE (n1:Team \$props)", [props:[name:"Team $count".toString()]]) tx.commit() session.close() } @@ -342,18 +342,18 @@ class MiscSpec extends GormDatastoreSpec { when: def pet = new Pet(birthDate: new Date(), name: 'Cosima').save(flush: true) then: - IteratorUtil.single(session.transaction.nativeTransaction.run("MATCH (p:Pet {name:{1}}) RETURN p.birthDate as birthDate", ["1":'Cosima'])).birthDate.asNumber() instanceof Long + IteratorUtil.single(session.transaction.nativeTransaction.run("MATCH (p:Pet {name:\$1}) RETURN p.birthDate as birthDate", ["1":'Cosima'])).birthDate.asNumber() instanceof Long } @Issue("https://github.com/SpringSource/grails-data-mapping/issues/52") - @IgnoreIf({System.getenv('TRAVIS')}) // fails randomly on Travis + @IgnoreIf({System.getenv('CI')}) // fails randomly on Travis def "verify backward compatibility, check that date properties stored as string can be read"() { setup: "create a instance with a date property and manually assign a string to it" def date = new Date() def pet = new Pet(birthDate: date, name:'Cosima').save(flush: true) when: "write birthDate as a String" - session.transaction.nativeTransaction.run("MATCH (p:Pet {name:{1}}) SET p.birthDate={2}", + session.transaction.nativeTransaction.run("MATCH (p:Pet {name:\$1}) SET p.birthDate=\$2", ['1':'Cosima', '2':date.time.toString()]) pet = Pet.get(pet.id) then: "the string stored date gets parsed correctly" @@ -365,7 +365,7 @@ class MiscSpec extends GormDatastoreSpec { when: def team = new Team(name: 'name', binaryData: 'abc'.bytes) team.save(flush: true) - def value = IteratorUtil.single(session.transaction.nativeTransaction.run("MATCH (p:Team {name:{1}}) RETURN p.binaryData as binaryData", + def value = IteratorUtil.single(session.transaction.nativeTransaction.run("MATCH (p:Team {name:\$1}) RETURN p.binaryData as binaryData", ["1":'name'])).binaryData then: diff --git a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/OneToManyUpdateSpec.groovy b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/OneToManyUpdateSpec.groovy index 454f1375..5845f039 100644 --- a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/OneToManyUpdateSpec.groovy +++ b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/OneToManyUpdateSpec.groovy @@ -64,7 +64,7 @@ class OneToManyUpdateSpec extends GormDatastoreSpec { tournament = Tournament.get(tournament.id) - def result = Club.cypherStatic('MATCH (from:Tournament)-[r:TEAMS]->(to:Team) WHERE ID(from) = {id} RETURN r', [id:tournament.id]) + def result = Club.cypherStatic('MATCH (from:Tournament)-[r:TEAMS]->(to:Team) WHERE ID(from) = \$id RETURN r', [id:tournament.id]) then: "the relationship is correct and no duplicates are added" tournament != null result.iterator().size() == 2 @@ -79,7 +79,7 @@ class OneToManyUpdateSpec extends GormDatastoreSpec { session.clear() tournament = Tournament.get(tournament.id) - result = Club.cypherStatic('MATCH (from:Tournament)-[r:TEAMS]->(to:Team) WHERE ID(from) = {id} RETURN r', [id:tournament.id]) + result = Club.cypherStatic('MATCH (from:Tournament)-[r:TEAMS]->(to:Team) WHERE ID(from) = \$id RETURN r', [id:tournament.id]) then: "the relationship is correct and no duplicates are added" tournament != null tournament.teams.size() == 1 diff --git a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancySpec.groovy b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancySpec.groovy index e102d158..a1f8bd0b 100644 --- a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancySpec.groovy +++ b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/multitenancy/MultiTenancySpec.groovy @@ -60,7 +60,7 @@ class MultiTenancySpec extends Specification { when:"A cypher query is executed without the tenant id" CompanyC.withNewSession { - CompanyC.find("MATCH (p:CompanyC) WHERE p.name={name} RETURN p", [name:"Foo"]) + CompanyC.find("MATCH (p:CompanyC) WHERE p.name=\$name RETURN p", [name:"Foo"]) } then:"An exception is thrown" @@ -68,7 +68,7 @@ class MultiTenancySpec extends Specification { when:"A cypher query is executed without the tenant id" CompanyC result= CompanyC.withNewSession { - CompanyC.find("MATCH (p:CompanyC) WHERE p.name={name} AND p.parent={tenantId} RETURN p", [name:"Foo"]) + CompanyC.find("MATCH (p:CompanyC) WHERE p.name=\$name AND p.parent=\$tenantId RETURN p", [name:"Foo"]) } then:"The entity is found" diff --git a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/path/PathSpec.groovy b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/path/PathSpec.groovy index 5ee0b681..9fff554e 100644 --- a/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/path/PathSpec.groovy +++ b/grails-datastore-gorm-neo4j/src/test/groovy/grails/gorm/tests/path/PathSpec.groovy @@ -163,7 +163,7 @@ class PathSpec extends Specification { Person.withSession { it.clear() } when: - Path path = Person.findPath('MATCH (from:Person),(to:Person), p = shortestPath((from)-[*..15]-(to)) WHERE from.name = {from} AND to.name = {to} RETURN p', [from:"Fred", to:"Joe"]) + Path path = Person.findPath('MATCH (from:Person),(to:Person), p = shortestPath((from)-[*..15]-(to)) WHERE from.name = \$from AND to.name = \$to RETURN p', [from:"Fred", to:"Joe"]) for(Path.Segment segment in path) { println segment.start().name println segment.end().name diff --git a/grails-datastore-gorm-neo4j/src/test/groovy/org/grails/datastore/gorm/neo4j/ApiExtensionsSpec.groovy b/grails-datastore-gorm-neo4j/src/test/groovy/org/grails/datastore/gorm/neo4j/ApiExtensionsSpec.groovy index 4e9d009a..e60705cc 100644 --- a/grails-datastore-gorm-neo4j/src/test/groovy/org/grails/datastore/gorm/neo4j/ApiExtensionsSpec.groovy +++ b/grails-datastore-gorm-neo4j/src/test/groovy/org/grails/datastore/gorm/neo4j/ApiExtensionsSpec.groovy @@ -50,7 +50,7 @@ class ApiExtensionsSpec extends GormDatastoreSpec { session.clear() when: - def result = team.cypher("MATCH (p:Team)<-[:TEAMS]->(m) WHERE ID(p) = {this} return m") + def result = team.cypher("MATCH (p:Team)<-[:TEAMS]->(m) WHERE ID(p) = \$this return m") then: result.iterator().size() == 1