-
-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Non-integer primary keys are forced to the model's id
during make/build
#220
Comments
hmm .. this is a puzzler you want factoryGuy to build a fixture, you and whoever does this are responsible that id ( value in your case ) is created and is unique .. is that right? |
Agreed (I think): If a fixture has a definition for the ID field, I think it would be the responsibility of the fixture owner to make it unique the value be unique |
Hmm .. this brings up the issue where you probably don't need the id for an id .. but is nice to have for ability to make fixture data like // tests/factories/some-model.js
FactoryGuy.define('some-model', {
default: {
value: (f) => `custom_string_id${f.id}`,
label: faker.lorem.word()
}
}); but really you are using it as an index .. or a sequence number so you don't have to generate a sequence object. let me ponder this to see if I can call it num so you can use it like f.num or maybe f.idx and it is clear it is just a free index number and NOT the id thoughts? |
@danielspaniel Yeah that sounds good --- also don't mind the usage of faker above, I'm not deadset on it, just using it as sample code. |
Sure thing @mdentremont ... I was showing how the id is so useful when making fixtures and was tying to show how even without an id field it is still useful for making fake data. |
@mdentremont , v2.7.1 has this new and improved edge case covered |
Given:
When generating the model with factory guy, the primary key attribute which should be a string is replaced by the integer id.
Code:
I believe there to be two issues here:
DS.attr('string')
Some investigation shows that this is likely due to
addPrimaryKey
being called as the last step for make/build. This function does not check for the primary key's type, and also does not check to see if it is already set:The text was updated successfully, but these errors were encountered: