pg_serializable 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1909d56bad3b23411c7ce220bcf850489f64a20a653d064b3029a85ded8b063
4
- data.tar.gz: 8a677cf086f7365a1984ba756d81360b731e38e543ec9ee512d6a7631af40bce
3
+ metadata.gz: 648a712ad1604caafa1ce54620bde306d99f38fba5b3897b707bce2302ac15de
4
+ data.tar.gz: 00e8956c9bc8c41bb967e3340cf6a51b642a06061dd9d736e586696c7662a438
5
5
  SHA512:
6
- metadata.gz: d78dc887bf5a0b79514befdd4bd6ca34621a26340e62756ccd60e45d076d226f135d6777dab4ade5ef02eaa4f5346209b305b6967cac511392030f95799b8348
7
- data.tar.gz: 9b71a136e79e0b768ef7f113ea8a570c3edaab932eccd60ba8ad920f819630c61fac7501e0f92d2da2fd9e0a5914b8f41e469a7294c69aabcba0a72f5b06b244
6
+ metadata.gz: fd39bd3c82b9732015cad9776b36c45e828fb890e2104c739ad250ee9ecf7aa913d6b328c358286f3f99e315d2b3bb8d63284ff3b679dfe0d0b89e079eaed019
7
+ data.tar.gz: fa604b60406ff47e4b1b7795f85481c1c10626ca9de59b221e94ba2bd20e70a9e75566ea464e184afbd03557ac916f240f84374326269f4b7de84926cd4a49b2
@@ -1,3 +1,3 @@
1
1
  module PgSerializable
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -91,12 +91,19 @@ module PgSerializable
91
91
  association = subject.association
92
92
  through = association.through_reflection
93
93
  source = association.source_reflection
94
+ join_name = source.collection? ? through.plural_name.to_sym : through.name
95
+ where_clause = begin
96
+ if through.belongs_to?
97
+ "#{table_alias}.#{through.join_foreign_key}=#{through.table_name}.#{subject.foreign_key}"
98
+ else
99
+ "#{through.table_name}.#{through.join_foreign_key}=#{table_alias}.#{subject.foreign_key}"
100
+ end
101
+ end
94
102
 
95
103
  query = visit(association
96
104
  .klass
97
- .select("#{source.table_name}.*, #{through.table_name}.#{source.join_foreign_key}, #{through.table_name}.#{through.join_primary_key}")
98
- .joins(through.name), table_alias: current_alias)
99
- .where("#{current_alias}.#{through.join_primary_key}=#{table_alias}.#{subject.foreign_key}")
105
+ .joins(join_name)
106
+ .where(where_clause), table_alias: current_alias)
100
107
  .to_sql
101
108
 
102
109
  "\'#{subject.label}\', (#{query})"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_serializable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - matthewjf
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-12 00:00:00.000000000 Z
11
+ date: 2019-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler