Skip to content

Commit

Permalink
Fix upstream pluck bug where non-integer IDs are incorrectly type-c…
Browse files Browse the repository at this point in the history
…ast.

See rails/rails#28044 for details.
  • Loading branch information
awmichel committed Feb 17, 2017
1 parent 5af1f17 commit c6aa622
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/jsonapi/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1244,9 +1244,10 @@ def preload_included_fragments(resources, records, serializer, options)
def pluck_arel_attributes(relation, *attrs)
conn = relation.connection
quoted_attrs = attrs.map do |attr|
quoted_table = conn.quote_table_name(attr.relation.table_alias || attr.relation.name)
table_name = attr.relation.table_alias || attr.relation.name
quoted_table = conn.quote_table_name(table_name)
quoted_column = conn.quote_column_name(attr.name)
"#{quoted_table}.#{quoted_column}"
"#{quoted_table}.#{quoted_column} as #{table_name}_#{attr.name}"
end
relation.pluck(*quoted_attrs)
end
Expand Down

0 comments on commit c6aa622

Please sign in to comment.