Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upBelongs_to association should not be included automatically into save transactions #302
Conversation
Belongs_to association should not be included automatically into save transactions
records with equal non-nil id's are be equal, but if both id's are nil, we need to compare attributes
* ActiveRecord does not ignore primary key on an instance initialization, and if the primary key is present, the records has been saved with that key. * While creating new instance of ActiveRecord, we do not need to load any data. * The assignment of the attributes provided in the new arguments needs no conversion in the initilizer, the conversion should be done by setters themselves. * The assignment of the attributes in the initializer has been rewritten using #assign_attributes
fixed #101 when ServerOp transmits errors to the client
the location, history, and match props provided by Router are needed to be received directly from the native element so the components could use them in all the situation - whether they are route children, a component prop, or are rendered in the withRoute() context
The problem case example:
We have a class Note with
belongs_to: :user, and User withhas_many: :note.A browser app creates some invalid Note object,
note1, associates it with a user vianote1.user = user, runsnote1.saveand gets some validation error. Then the app creates another Note object,note2, a normal one, associates it with the user vianote2.user = userand runsnote2.save. It gets a confusing state: the reactive_record tries to save bothnote1andnote2in a single transaction, fails with rollback due invalidnote1and also refuses to save thenote2.A similar problem if we create and edit several Note objects associate to a user and save one of them - the backend will save them all.
It's an unexpected behavior, and accroding to https://guides.rubyonrails.org/association_basics.html: "Assigning an object to a belongs_to association does not automatically save the object. It does not save the associated object either."