Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Cypher seems to not like nil values on properties? #222

cfitz opened this Issue Nov 7, 2012 · 2 comments


None yet
2 participants

cfitz commented Nov 7, 2012


Seem to have run into something odd while working on the updated devise-neo4j....

class DumbUser < Neo4j::Rails::Model
property :a_token

jruby-1.7.0 :136 > DumbUser.to_adapter.find_first( { "a_token" => "kkk" } )
=> nil

jruby-1.7.0 :139 > d = DumbUser.create!
=> #<DumbUser:0x440e66e8 @errors=#<ActiveModel::Errors:0xd862c40 @base=#<DumbUser:0x440e66e8 ...>, @messages={}>, @_properties={"_classname"=>"DumbUser"}, @_relationships={}, @changed_attributes={}, @_java_node=#Java::OrgNeo4jKernelImplCore::NodeProxy:0x55b2fcac, @_create_or_updating=nil, @_properties_before_type_cast={}, @previously_changed={"_classname"=>["DumbUser", "DumbUser"]}, @validation_context=nil>

jruby-1.7.0 :140 > d.a_token
=> nil

jruby-1.7.0 :141 > DumbUser.to_adapter.find_first( { "a_token" => "kkk" } )
Java::OrgNeo4jCypher::EntityNotFoundException: The property 'a_token' does not exist on Node[10971]
from org.neo4j.cypher.internal.commands.Property.compute(Expression.scala:221)
from org.neo4j.cypher.internal.commands.Expression$$anonfun$apply$1.apply(Expression.scala:30)
from scala.collection.MapLike$class.getOrElse(MapLike.scala:122)
from scala.collection.JavaConversions$JMapWrapper.getOrElse(JavaConversions.scala:792)
from org.neo4j.cypher.internal.commands.Expression.apply(Expression.scala:30)
from org.neo4j.cypher.internal.commands.Equals.isMatch(ComparablePredicate.scala:51)
from org.neo4j.cypher.internal.pipes.matching.SimplePatternMatcherBuilder$$anonfun$getMatches$1$$anonfun$apply$3.apply(SimplePatternMatcherBuilder.scala:93)
from org.neo4j.cypher.internal.pipes.matching.SimplePatternMatcherBuilder$$anonfun$getMatches$1$$anonfun$apply$3.apply(SimplePatternMatcherBuilder.scala:93)
from scala.collection.LinearSeqOptimized$class.forall(LinearSeqOptimized.scala:69)

Looks like if one of the objects has a nil value, it causes the cypher query to stop. Maybe it's a type conversion between ruby nil and java null ?


andreasronge commented Nov 8, 2012

If there is no index declared on the property it will use Cypher. According to the stacktrace it tries to perform a cypher query. I should really change that the property must not be required on each node for the cypher query (a new Issue ?)

Try to change the line: https://github.com/andreasronge/neo4j/blob/master/lib/neo4j/rails/finders.rb#L302

so that it instead make the key optionally.

    cypher["#{k}?"] == v 

cfitz commented Nov 9, 2012

ah ok...so I think that putting a index on the properties is the way to do...issue now is that devise is expecting a nil value..... looks like if the value is nil after a new model is initialized, but if it's change then deleted, it return a "" string. i've fixed this by making a NilClass type converter, so that empty strings are converted to nil. Would this be something to add to the neo4j orm?

-ps i think this ticket is irrelevant now...close it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment