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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fea48a5522b0f0f471725feb12317d463f78cd6
4
- data.tar.gz: f9475b2bb5ee21271dd7b3695cde9ca35f0b2f32
3
+ metadata.gz: 4b016ad8dffbdb2b014ec63cb6b4f2f730a2a514
4
+ data.tar.gz: 2f99620927aa7043a7130156596dcfd9f1f2d2d1
5
5
  SHA512:
6
- metadata.gz: eb7ac6feeff8448154dd3b4dbde792e9df29e901d2756f459e2325027857d9d783ea11f84b6ccb6e2988c4cec6fc1a78dd0c36b29406a80b79e1eb41e7ae771a
7
- data.tar.gz: a050ca27622558a21c81e9199922bee8c2efef2ff2343dda8d735ad95d668ad430b8224f91a366ad6e548e4c8118bd3af1b02b88f39b036763533fd0c9e62432
6
+ metadata.gz: d7637666111ab189bcd497da5837d5d06e3baf89c0716839481294c160d6a0ca13531de7c2e4ae71ad7e54f12dd55cbf55578736ffe1fddabefff4743bd11703
7
+ data.tar.gz: dbbdc73800151b6ac3bf6e3535245d412c38ca7f1843fe8c27eabbe14bdbc57b687229c1edac9bab220d5fa03ae5290e9b1f489dd548695da9898be136e5a901
@@ -1,3 +1,3 @@
1
1
  module Pggraphql
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
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
- "id in (" + ids.map{|id| id.is_a?(String) ? "'#{id}'" : id.to_s}.join(',') + ")"
121
+ "#{id_column} in (" + ids.map{|id| id.is_a?(String) ? "'#{id}'" : id.to_s}.join(',') + ")"
121
122
  else
122
- "id = " + (ids.is_a?(String) ? "'#{ids}'" : "#{ids}")
123
+ "#{id_column} = " + (ids.is_a?(String) ? "'#{ids}'" : "#{ids}")
123
124
  end
124
125
  end
125
126
  end
@@ -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.7
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-12 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json