Skip to content

Commit 71f17c2

Browse files
author
James Glover
committed
Unpin json-api-resource and fix associations
The update to jsonapi-resources 0.10.6 broke the loading of tubes for pacbio library and pool resources. This appears to be related to the addition of the configuration option `use_related_resource_records_for_joins` cerebris/jsonapi-resources#1381 This is failing to function correctly in this case. By specifying the relationship explicitly, we disable this behaviour, and everything behaves as expected. I still haven't quite managed to get to the bottom of the problem. It may be we need to disable the behaviour globally.
1 parent db9e226 commit 71f17c2

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ gem 'bunny'
1010
gem 'exception_notification'
1111
# 0.10.5 Results in MySQL syntax error on several tests when run against a MySQL
1212
# There is a 'monkey patch' for this in config/intializers/jsonapi_resources:15-63
13-
gem 'jsonapi-resources', '=0.10.5'
13+
gem 'jsonapi-resources'
1414
gem 'mysql2'
1515
gem 'puma', '~> 4.3' # Use Puma as the app server
1616
gem 'rack-cors' # Use Rack CORS for handling CORS, making cross-origin AJAX possible

Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ GEM
101101
activesupport (>= 5.0)
102102
i18n (1.10.0)
103103
concurrent-ruby (~> 1.0)
104-
jsonapi-resources (0.10.5)
104+
jsonapi-resources (0.10.7)
105105
activerecord (>= 4.1)
106106
concurrent-ruby
107107
railties (>= 4.1)
108108
listen (3.1.5)
109109
rb-fsevent (~> 0.9, >= 0.9.4)
110110
rb-inotify (~> 0.9, >= 0.9.7)
111111
ruby_dep (~> 1.2)
112-
loofah (2.16.0)
112+
loofah (2.17.0)
113113
crass (~> 1.0.2)
114114
nokogiri (>= 1.5.9)
115115
mail (2.7.1)
@@ -265,7 +265,7 @@ DEPENDENCIES
265265
database_cleaner
266266
exception_notification
267267
factory_bot_rails
268-
jsonapi-resources (= 0.10.5)
268+
jsonapi-resources
269269
listen (>= 3.0.5, < 3.2)
270270
mysql2
271271
pry-rails

app/resources/v1/pacbio/library_resource.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ class LibraryResource < JSONAPI::Resource
1010
:insert_size, :created_at, :deactivated_at, :source_identifier
1111

1212
has_one :request, always_include_optional_linkage_data: true
13-
has_one :tube
13+
# If we don't specify the relation_name here, jsonapi-resources
14+
# attempts to use_related_resource_records_for_joins
15+
# In this case I can see it using container_associations
16+
# so seems to be linking the wrong tube relationship.
17+
has_one :tube, relation_name: :tube
1418
has_one :tag, always_include_optional_linkage_data: true
1519
has_one :pool, always_include_optional_linkage_data: true
1620
has_one :source_well, relation_name: :source_well, class_name: 'Well'

app/resources/v1/pacbio/pool_resource.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ module Pacbio
66
class PoolResource < JSONAPI::Resource
77
model_name 'Pacbio::Pool'
88

9-
has_one :tube
9+
# If we don't specify the relation_name here, jsonapi-resources
10+
# attempts to use_related_resource_records_for_joins
11+
# In this case I can see it using container_associations
12+
# so seems to be linking the wrong tube relationship.
13+
has_one :tube, relation_name: :tube
1014
has_many :libraries
1115

1216
attributes :volume, :concentration, :template_prep_kit_box_barcode,

0 commit comments

Comments
 (0)