factory_bot
factory_bot copied to clipboard
build_stubbed does not fill id for uuid column type with SQLServer
Description
When using SQLServer and 'uuid' as the primary key type, they 'build_stubbed' method does not automatically fill the id column. I would assume that this is filled independent of the column type.
https://github.com/thoughtbot/factory_bot/blob/0521d914974f6fecf5a3f77b60a86ae4f057f787/lib/factory_bot/strategy/stub.rb#L91-L96 I'm thinking the code here is the problem.
In SQLServer, the column.sql_type seems to be "uniqueidentifier".
I think it might work if I use column.type, but I don't know if this is a problem in other databases, so I've raised an issue.
Reproduction Steps
Sample code → https://github.com/vividmuimui/sqlserver-factorybot/commits/main/
Expected behavior
When you use build_stubbed, the primary key is always set. Also if you use the uuid type.
Actual behavior
The id of the generated instance is nil.
System configuration
factory_bot version: 6.4.5 rails version: 7.1.3 ruby version: v3.3.0