Skip to content
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

Inconsistent behaviour with default schema values in factories #68

Open
trafium opened this issue Jul 2, 2021 · 1 comment
Open

Inconsistent behaviour with default schema values in factories #68

trafium opened this issue Jul 2, 2021 · 1 comment

Comments

@trafium
Copy link

trafium commented Jul 2, 2021

Describe the bug

I am using rom-rb with rom-sql and rom-factory.
In short, a struct creation via factory (Factory.structs[:foo]) is not using default type value unless schema also has unrelated jsonb type field.
Took me forever to isolate the source of issue to that jsonb type column 😅

To Reproduce

Example repo:
https://github.com/trafium/rom_factory_bug

To run:

bundle exec rake db:create
bundle exec rake db:migrate
ruby test.rb

The output is:

#<Entities::Foo column_with_default=nil id=1 random_column=nil>
#<Entities::Bar column_with_default="default" id=1 random_column=nil>

Expected behavior

#<Entities::Foo column_with_default="default" id=1 random_column=nil>
#<Entities::Bar column_with_default="default" id=1 random_column=nil>

I am not sure what is the expected behaviour for rom-factory, but I would expect it should always use default values for factory structs creation.

My environment

  • Affects my production application: Not yet
  • Ruby version: 2.6.6
  • OS: MacOS 11.2.3
@trafium trafium changed the title Inconsistent behaviour with default values in factories Inconsistent behaviour with default schema values in factories Jul 2, 2021
@solnic
Copy link
Member

solnic commented Jul 19, 2021

Thanks for reporting and isolating the issue. I'm working on rom 6.0 at the moment but rom-factory will be greatly improved and upgraded along with rom 6.0. I will make sure all known issues are addressed, including this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants