
Changing attributes after persistance should not write directly to the DB unless specifically saved
Reported by Ben Jackson | November 15th, 2010 @ 04:14 PM | in 1.0.0.beta.21
Currently, when a Neo4j Model is saved, a Java Node is created and that replaces the proxy 'Value' object that handled holding properties and relationships before validation and callbacks allow the data to be saved permanently. After being saved, any attribute can be changed and will be immediately written to the DB.
To solve this, I need to refactor the code to make it so that attribute assigning never goes straight to the DB, but specifically requires a #save, like ActiveRecord.
At the same time, some refactoring will be done to make sure that transactions and type conversions are only ever used when necessary, e.g. when saving and not when validating.
Comments and changes to this ticket
-
Andreas Ronge November 16th, 2010 @ 10:55 AM
- Milestone set to 1.0.0.beta.21
- Milestone order changed from 1 to 0
-
Ben Jackson November 18th, 2010 @ 11:32 AM
This change is ready and in a branch on my fork: https://github.com/benjackson/neo4j/tree/devise. It's the 'devise' branch because these changes were needed really to make Devise authentication tests pass (it was a bit of a big security flaw!).
HOWEVER It totally breaks the ability to use nested attributes to create related models and relationships can only be created for persisted models. To get that stuff to work properly is going to be immensely complicated and so might not get done for the 1.0.0.beta.21 milestone.
What do you think we should do in that case? I think there's a lot of good refactoring and tidying that came from this fix - a lot of functionality has been separated out into their own modules to make things much easier to understand and it does correctly pass the tons of Devise tests thrown at it...
Let me know what you think.
-
Andreas Ronge November 18th, 2010 @ 11:43 AM
Well done !!
I just want to make sure that it's still possible to reimplement nested attributes in the next release beta.22
Will have a look at the code. -
Andreas Ronge November 18th, 2010 @ 06:45 PM
- State changed from new to resolved
-
Andreas Ronge January 27th, 2012 @ 02:40 PM
(from [4aa29d193a4b3b923d1c6836bc7e6d1151a98e8f]) Getting it to work with ActiveModel 3.2 closes #131
-
Look like the specs runs faster with ActiveModel 3.2.
-
There is small change on how the dirty activemodel feature works. The previous value is now only available after the model hasn been saved. This is probably the reason why one versioning spec did not work (set to pending). https://github.com/andreasronge/neo4j/commit/4aa29d193a4b3b923d1c68...
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
Neo4j.rb is a graph database framework for JRuby.
It provides:
* Mapping of ruby objects to nodes in networks rather than in tables.
* Storage of ruby object to a file system.
* Fast traversal of relationships between nodes in a hugh node space.
* Transaction with rollbacks support.
* Indexing and quering of ruby objects.
* Integration with Rails