Raise an error if sequence
is defined for attribute with auto-incrementing sequence in the DB
#1585
Labels
sequence
is defined for attribute with auto-incrementing sequence in the DB
#1585
This feature request came from rubocop/rubocop-factory_bot#52 which has an example reproduction of the problem.
Problem this feature will solve
E.g. with a simple factory:
where the post table's
id
is backed by a DB sequence, it is quite easy for the FactoryBotsequence
to get out of sync with the DB sequence and cause duplicate errors, for example with:the second
FactoryBot.create
will error due to a duplicateid
value in the DB.Desired solution
Disallow defining a
sequence
for an attribute that is backed by an auto-incrementing sequence in the database.Alternatives considered
Perhaps the RuboCop check is sufficient, and implementing the check/error in FactoryBot is not possible or deemed worth the effort?
The text was updated successfully, but these errors were encountered: