-
Notifications
You must be signed in to change notification settings - Fork 62
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
How to handle JSONB columns on name-spaced tables? #49
Comments
I also tried naming the table Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/jack/code/PROJECT/spec/fixtures/admin/users.yml
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:151:in `initialize'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:151:in `open'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:151:in `write_fixture_file'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:90:in `block in dump_empty_fixtures_for_all_tables'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:89:in `each'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:89:in `dump_empty_fixtures_for_all_tables'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:65:in `write_data_to_files'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/builder.rb:17:in `generate!'
/Users/jack/.rvm/gems/ruby-2.5.0/gems/fixture_builder-0.5.1/lib/fixture_builder/configuration.rb:34:in `factory' |
Ahh.. I think I am running into this issue with the audited gem. Because the table class is Hmm, based on the issue, I think a hacky workaround might be to just add define the un-namespaced class somewhere appropriate to get FixtureBuilder to find the right class. I put it in my fixture builder block and it seems to resolve the issue without affecting other places. Though this may not be possible if the un-namespaced class already exists. But e.g. Audit = Audited::Audit |
@jackkinsella @ibrahima As anyone who knows me will attest I'm a fan of namespaces, so I've run into this issue a number of times. The problem, as you've no doubt determined, is FixtureBuilder trying to determine the class from the table name. In the example of the Audited gem (which I also use and quite like), the table name is table_klass = table_name.classify.constantize rescue nil
# "audits".classify => "Audit"
# "Audit".contantize => *BOOM* since Audit is not a top-level constant
# rescue nil => nil I've worked around it by adding an explicit builder.factory do
builder.configure_tables(
audits: { class: "Audited::Audit", file: 'audited/audits' }
)
end I hope to merge this functionality into the gem (I've spoken with the maintainers, and they're amendable; I just haven't gotten around to it, so the delay is entirely my fault), but in the meantime I've been using my fork for the past year or so without any problems. I hope this helps. |
Here's the situation: Imagine you have a name-spaced table, e.g.
admin_users
, representing the modelAdmin::User
, and this table has a JSONB column, saydetails
.The
fixture_builder
gem won't ever callserialized_value_if_needed
. The key method isdump_tables
inbuilder.rb
, which calculates the class name with the following code:The trace is as follows:
Any ideas how to handle this?
The text was updated successfully, but these errors were encountered: