The short answer will be No: there is no way to Search for undeclared property values in persisted nodes.
Edited:
They added a Migration like behaviour for the gem that might fit your current needs.
http://neo4jrb.readthedocs.io/en/latest/Migrations.html
Discovery answer:
Nodes should be considered as documents that stores properties inside them. What we are dealing here is with an implementation of the Cypher Query and the Neo4j::ActiveNode
that not only ignores the default values for properties.
This could be easily tested:
class User
include Neo4j::ActiveNode
property :name, type: String
property :email, type: String, default: 'example@example.com'
end
Then create two nodes:
User.create(name: 'John', email: 'john@cena.com'
User.create(name: 'John')
We try to search for undeclared property values:
> User.where(title: 'Mr')
=> #<QueryProxy CYPHER: "MATCH (result_user:`User`) WHERE (result_user.title = {result_user_title})">
We effectively call Cyper
and get results, this means that the property declaration in model is not used at all in the Neo4j::ActiveNode#where
It means is only used to set and get properties, but ignored by the finders.
There might be workarounds, that are actually missing implementations in the Neo4j gem:
You can search by array of values in the Cyper connector, but is not parsing properly the values:
User.where(another_field: nil).count
CYPHER 39ms MATCH (result_user:`User`) WHERE (result_user.another_field IS NULL) RETURN count(result_user) AS result_user
=> 100
User.where(another_field: ['Something', nil]).count
CYPHER 12ms MATCH (result_user:`User`) WHERE (result_user.another_field IN {result_user_another_field}) RETURN count(result_user) AS result_user | {:result_user_another_field=>["Something", nil]}
=> 0
As you can see in the last query, nil
is passed literally. So you can't do this.
I've opened an Issue in the repository in your behalf, and linked this question in order to get a solution.