Attributes set at create-time are always changed
See original GitHub issueConsider the model:
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
export default Model.extend({
country: attr('string'), // e.g. US
region: attr('string'), // e.g. Illinois
locality: attr('string'), // e.g. Chicago
street: attr('string'), // e.g. 1060 W Addison St
postalCode: attr('string') // e.g. 60613
});
What I’m finding is that any attributes that are set at create-time are always changed, even if auto
is set to false
, e.g.:
let address = store.createRecord('address', { country: 'AR' });
address.didChange('country'); // => true
I would expect the tracker to start after the record is created when auto
is true
. Even more frustrating, I can’t set auto
to false
and call address.startTrack()
after createRecord()
to do it manually.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Setting/changing the ctime or "Change time" attribute on a file
1st Method: Changing the kernel. The notify_change function is executed after a file has been changed, where the time metadata needs to be ......
Read more >How to persist creation and update timestamps with Hibernate
When a new entity gets persisted, Hibernate gets the current timestamp from the VM and sets it as the value of the attribute...
Read more >11.2.5 Automatic Initialization and Updating for TIMESTAMP ...
TIMESTAMP and DATETIME columns can be automatically initialized and updated to the current date and time (that is, the current timestamp).
Read more >Can a file appear to be modified before it was created?
The most important thing to note here is that file modification time isn't really special - it's stored just like any other data....
Read more >How To Change A File/Folder Date Timestamp Using ...
Clicking Change Attributes will open the Attribute Changer in a new window showing the details of the item that you have selected. In...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
How’s that?
Your welcome Mike, and I realized the other day that I actually could do the thing where create attributes are set up for new record the way you want them to ( they would be not be considered changed ) etc.
The thing is that this is different than what ember data default does. So it would be a special mode ( I am thinking )
where you would create record and call => model.startTrack() and if the model is new … it would wipe the slate and call current attributes the current state ( and ignore what ember data “changedAttributes” say )
created records can’t be rolled back , so it would not cause an trouble there.
anyway … this would solve a huge headache ( and all the ridiculous hocus pokus from the hacking I showed a few messages above this one )
I don’t really need this but if you need it we can ponder the goodness or badness of such a concept.