pggraphql 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/pggraphql/version.rb +1 -1
- data/lib/pggraphql.rb +3 -2
- data/test/test_pggraphql.rb +26 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b016ad8dffbdb2b014ec63cb6b4f2f730a2a514
|
4
|
+
data.tar.gz: 2f99620927aa7043a7130156596dcfd9f1f2d2d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7637666111ab189bcd497da5837d5d06e3baf89c0716839481294c160d6a0ca13531de7c2e4ae71ad7e54f12dd55cbf55578736ffe1fddabefff4743bd11703
|
7
|
+
data.tar.gz: dbbdc73800151b6ac3bf6e3535245d412c38ca7f1843fe8c27eabbe14bdbc57b687229c1edac9bab220d5fa03ae5290e9b1f489dd548695da9898be136e5a901
|
data/lib/pggraphql/version.rb
CHANGED
data/lib/pggraphql.rb
CHANGED
@@ -116,10 +116,11 @@ module PgGraphQl
|
|
116
116
|
@mappings = {}
|
117
117
|
@null_pk = false
|
118
118
|
@pk = ->(ids) do
|
119
|
+
id_column = @mappings[:id] || "id"
|
119
120
|
if ids.is_a?(Array)
|
120
|
-
"
|
121
|
+
"#{id_column} in (" + ids.map{|id| id.is_a?(String) ? "'#{id}'" : id.to_s}.join(',') + ")"
|
121
122
|
else
|
122
|
-
"
|
123
|
+
"#{id_column} = " + (ids.is_a?(String) ? "'#{ids}'" : "#{ids}")
|
123
124
|
end
|
124
125
|
end
|
125
126
|
end
|
data/test/test_pggraphql.rb
CHANGED
@@ -290,6 +290,32 @@ module PgGraphQl
|
|
290
290
|
|
291
291
|
end
|
292
292
|
|
293
|
+
def test_inherit_with_pk
|
294
|
+
res = to_sql({
|
295
|
+
products: {
|
296
|
+
id: 1,
|
297
|
+
clickout__destination_url: nil
|
298
|
+
}
|
299
|
+
}) do |s|
|
300
|
+
s.root :product
|
301
|
+
s.type :product, null_pk: :array, fields: [:type, :clickout__destination_url, :download__download_url] do |t|
|
302
|
+
t.map :id, "products.id"
|
303
|
+
t.subtype :clickout, table: :product_clickouts, fk: "clickout.id = products.id and products.type = 'clickout'"
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
assert_equal token(<<-SQL
|
308
|
+
select 'products'::text as key,
|
309
|
+
(select to_json(x.*)
|
310
|
+
from (select products.id as id,
|
311
|
+
clickout.destination_url as clickout__destination_url
|
312
|
+
from products
|
313
|
+
left join product_clickouts as clickout on (clickout.id = products.id
|
314
|
+
and products.type = 'clickout') where products.id = 1 limit 1) x) as value
|
315
|
+
SQL
|
316
|
+
), token(res)
|
317
|
+
|
318
|
+
end
|
293
319
|
|
294
320
|
#####################
|
295
321
|
# one
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pggraphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Zimmek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|