Closed shu-bc closed 4 years ago
@shu-bc it would be always helpful to have a complete spec. Are you saying that this spec will fail?
it 'does not delete pages on reassignment` do
page = Page.create
book = Book.create(pages: page)
book.page_ids = [page.id]
book.save
expect(book.pages).to be_present
end
Confirming that, this is a issue. If you have a non integer id_property
you get this issue. Thanks for reporting @shu-bc, we are on it.
@klobuczek yes, exactly.
@amitsuryavanshi oh yes, that is the case. Our id is created by SecureRandom.uuid
Suppose a book model
has_many
pages like thisbook.page_ids
can return an array of unique ids of related pages instancesbook.page_ids = [....]; book.save
is supposed to update its relation, as it does in v9.x.But in v10.0, this doesn't work, since it will issue delete queries that delete existing relation only AFTER issuing create queries. This causes trouble if some id in the array is included in the existing relations. In an extreme case, if you pass the exact same id array, then this will completely destroy existing relations.
This can be solved by just reversing the order of relational queries.
Additional information which could be helpful if relevant to your issue:
Code example (inline, gist, or repo)
Runtime information:
Neo4j database version: neo4j 3.4.0
neo4j
gem version: v10.0neo4j-core
gem version: