pggraphql 0.0.12 → 0.0.13

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
  SHA1:
3
- metadata.gz: b04ff239be18d90b85971b13eb3f7722a28de47a
4
- data.tar.gz: 360719c079f33dd65b4ddaebd4fd87bc95782b50
3
+ metadata.gz: 1435a943bfa68882db3826bb0f70561db6ad90cb
4
+ data.tar.gz: 9efca16a8d0c08f171162645661b541248cc70bb
5
5
  SHA512:
6
- metadata.gz: 90fd83702b235304dd8c60981f7a0521e20cecb1e26b3df3b07a5b6d8ef86d56038f201f1d8b9f884975ad24e4d294f85f1c40e3286a7eaf4a675a3d5e3c247b
7
- data.tar.gz: 32d51411460608e6a375d3e198201b43b0c211afbba68bb9c1a7b58edfb63d8ad8824138fd449804cd2755197123b4e69e2eb76031ad3bf6ddc5f15f095feab1
6
+ metadata.gz: 592df918ac04b3f7c4b1201c0c2d7088f5888296a62d968a041a98fd99463a1dac132f466fb1c76ae4e5536595687674aab8082221f91be40fd9a4a88a5bb59f
7
+ data.tar.gz: 4bf4ac82696eb398dba7752a92f2605ebfa5d3c17daf3011fcd895e388ba369565803a29e6de06bddac3554555321aff32bd63cb697b03df59085b4559d77ab5
@@ -1,3 +1,3 @@
1
1
  module Pggraphql
2
- VERSION = "0.0.12"
2
+ VERSION = "0.0.13"
3
3
  end
data/lib/pggraphql.rb CHANGED
@@ -38,8 +38,8 @@ module PgGraphQl
38
38
  def to_sql(query, level=0, params=[], parent=nil, link_name=nil)
39
39
  if level > 0
40
40
  query.map do |e|
41
- link = parent ? parent.links[link_name] : nil
42
- type = link ? link.type : self.types[e[0].to_s.singularize.to_sym]
41
+ link = parent ? parent.links[link_name.to_s.split("@").first.to_sym] : nil
42
+ type = link ? link.type : self.types[e[0].to_s.split("@").first.singularize.to_sym]
43
43
  ids = e[1][:id]
44
44
 
45
45
  raise "found :id with without value on type #{type.name.inspect}" if e[1].key?(:id) && ids.nil?
@@ -58,10 +58,10 @@ module PgGraphQl
58
58
  field_name = f[0]
59
59
 
60
60
  raise "unknown field #{field_name.inspect} on type #{type.name.inspect}" if !f[1].is_a?(Hash) && !type.fields.detect{|f| f[:name] == field_name}
61
- raise "unknown link #{field_name.inspect} on type #{type.name.inspect}" if f[1].is_a?(Hash) && !type.links.include?(field_name)
61
+ raise "unknown link #{field_name.inspect} on type #{type.name.inspect}" if f[1].is_a?(Hash) && !type.links.include?(field_name.to_s.split("@").first.to_sym)
62
62
 
63
63
  if f[1].is_a?(Hash)
64
- "(" + to_sql([f].to_h, level + 1, params, type, nested_link_name) + ") as #{field_name}"
64
+ "(" + to_sql([f].to_h, level + 1, params, type, nested_link_name) + ") as \"#{field_name}\""
65
65
  else
66
66
  field_def = type.fields.detect{|f| f[:name] == field_name}
67
67
 
@@ -382,9 +382,9 @@ module PgGraphQl
382
382
  (select to_json(coalesce(json_agg(x.*), '[]'::json))
383
383
  from (select orders.id
384
384
  from orders
385
- where (user_id = users.id)) x) as orders
385
+ where (user_id = users.id)) x) as "orders"
386
386
  from users
387
- where (id = download.id)) x) as download__users
387
+ where (id = download.id)) x) as "download__users"
388
388
  from products
389
389
  left join product_downloads as download on (download.id = products.id
390
390
  and products.type = 'download')
@@ -444,7 +444,7 @@ module PgGraphQl
444
444
  (select to_json(x.*)
445
445
  from (select addresses.id
446
446
  from addresses
447
- where addresses.id = ? and (id = users.address_id) limit 1) x) as address
447
+ where addresses.id = ? and (id = users.address_id) limit 1) x) as "address"
448
448
  from users
449
449
  where users.id = ? limit 1) x) as value
450
450
  SQL
@@ -469,7 +469,7 @@ module PgGraphQl
469
469
  (select to_json(x.*)
470
470
  from (select addresses.id
471
471
  from addresses
472
- where addresses.id = ? and (id = users.address_id) limit 1) x) as address
472
+ where addresses.id = ? and (id = users.address_id) limit 1) x) as "address"
473
473
  from users
474
474
  where users.id = ? limit 1) x) as value
475
475
  SQL
@@ -492,7 +492,7 @@ module PgGraphQl
492
492
  (select to_json(x.*)
493
493
  from (select addresses.id
494
494
  from addresses
495
- where addresses.id in ? and (id = users.address_id) limit 1) x) as address
495
+ where addresses.id in ? and (id = users.address_id) limit 1) x) as "address"
496
496
  from users
497
497
  where users.id = ? limit 1) x) as value
498
498
  SQL
@@ -517,7 +517,7 @@ module PgGraphQl
517
517
  (select to_json(x.*)
518
518
  from (select addresses.id
519
519
  from addresses
520
- where (id = users.address_id) limit 1) x) as address
520
+ where (id = users.address_id) limit 1) x) as "address"
521
521
  from users
522
522
  where users.id = ? limit 1) x) as value
523
523
  SQL
@@ -555,7 +555,7 @@ module PgGraphQl
555
555
  (select to_json(x.*)
556
556
  from (select addresses.id
557
557
  from addresses
558
- where addresses.id = ? and (id = (select 100)) limit 1) x) as address
558
+ where addresses.id = ? and (id = (select 100)) limit 1) x) as "address"
559
559
  from users
560
560
  where users.id = ? limit 1) x) as value
561
561
  SQL
@@ -580,7 +580,7 @@ module PgGraphQl
580
580
  (select to_json(x.*)
581
581
  from (select addresses.id
582
582
  from addresses
583
- where addresses.id = ? and (user_id = users.id) and (id > 100) limit 1) x) as address
583
+ where addresses.id = ? and (user_id = users.id) and (id > 100) limit 1) x) as "address"
584
584
  from users
585
585
  where users.id = ? limit 1) x) as value
586
586
  SQL
@@ -605,7 +605,7 @@ module PgGraphQl
605
605
  (select to_json(x.*)
606
606
  from (select addresses.id
607
607
  from addresses
608
- where addresses.id = ? and (user_id = users.id) order by id desc limit 1) x) as address
608
+ where addresses.id = ? and (user_id = users.id) order by id desc limit 1) x) as "address"
609
609
  from users
610
610
  where users.id = ? limit 1) x) as value
611
611
  SQL
@@ -639,9 +639,9 @@ module PgGraphQl
639
639
  (select to_json(x.*)
640
640
  from (select countries.id
641
641
  from countries
642
- where (id = addresses.country_id) limit 1) x) as country
642
+ where (id = addresses.country_id) limit 1) x) as "country"
643
643
  from addresses
644
- where (user_id = users.id) limit 1) x) as address
644
+ where (user_id = users.id) limit 1) x) as "address"
645
645
  from users
646
646
  where users.id = ? limit 1) x) as value
647
647
  SQL
@@ -671,7 +671,7 @@ module PgGraphQl
671
671
  (select to_json(coalesce(json_agg(x.*), '[]'::json))
672
672
  from (select addresses.id
673
673
  from addresses
674
- where addresses.id = ? and (user_id = users.id)) x) as address
674
+ where addresses.id = ? and (user_id = users.id)) x) as "address"
675
675
  from users
676
676
  where users.id = ? limit 1) x) as value
677
677
  SQL
@@ -696,7 +696,7 @@ module PgGraphQl
696
696
  (select to_json(coalesce(json_agg(x.*), '[]'::json))
697
697
  from (select addresses.id
698
698
  from addresses
699
- where addresses.id in ? and (user_id = users.id)) x) as address
699
+ where addresses.id in ? and (user_id = users.id)) x) as "address"
700
700
  from users
701
701
  where users.id = ? limit 1) x) as value
702
702
  SQL
@@ -721,7 +721,7 @@ module PgGraphQl
721
721
  (select to_json(coalesce(json_agg(x.*), '[]'::json))
722
722
  from (select addresses.id
723
723
  from addresses
724
- where (user_id = users.id)) x) as address
724
+ where (user_id = users.id)) x) as "address"
725
725
  from users
726
726
  where users.id = ? limit 1) x) as value
727
727
  SQL
@@ -746,7 +746,7 @@ module PgGraphQl
746
746
  (select to_json(coalesce(json_agg(x.*), '[]'::json))
747
747
  from (select addresses.id
748
748
  from addresses
749
- where addresses.id = ? and (user_id = users.id) and (id % 2 = 0)) x) as address
749
+ where addresses.id = ? and (user_id = users.id) and (id % 2 = 0)) x) as "address"
750
750
  from users
751
751
  where users.id = ? limit 1) x) as value
752
752
  SQL
@@ -771,7 +771,7 @@ module PgGraphQl
771
771
  (select to_json(coalesce(json_agg(x.*), '[]'::json))
772
772
  from (select addresses.id
773
773
  from addresses
774
- where addresses.id = ? and (user_id = users.id) order by id desc) x) as address
774
+ where addresses.id = ? and (user_id = users.id) order by id desc) x) as "address"
775
775
  from users
776
776
  where users.id = ? limit 1) x) as value
777
777
  SQL
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.12
4
+ version: 0.0.13
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-04-13 00:00:00.000000000 Z
11
+ date: 2015-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json