pg_query 0.6.4 → 0.7.0

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.
@@ -88,6 +88,8 @@ class PgQuery
88
88
  deparse_insert_into(node)
89
89
  when 'JOINEXPR'
90
90
  deparse_joinexpr(node)
91
+ when 'LOCKINGCLAUSE'
92
+ deparse_lockingclause(node)
91
93
  when 'NULLTEST'
92
94
  deparse_nulltest(node)
93
95
  when 'PARAMREF'
@@ -281,7 +283,8 @@ class PgQuery
281
283
 
282
284
  def deparse_aexpr_in(node)
283
285
  rexpr = Array(node['rexpr']).map { |arg| deparse_item(arg) }
284
- format('%s IN (%s)', deparse_item(node['lexpr']), rexpr.join(', '))
286
+ operator = node['name'] == ['='] ? 'IN' : 'NOT IN'
287
+ format('%s %s (%s)', deparse_item(node['lexpr']), operator, rexpr.join(', '))
285
288
  end
286
289
 
287
290
  def deparse_aexpr_not(node)
@@ -345,6 +348,24 @@ class PgQuery
345
348
  output.join(' ')
346
349
  end
347
350
 
351
+ LOCK_CLAUSE_STRENGTH = [
352
+ 'FOR KEY SHARE',
353
+ 'FOR SHARE',
354
+ 'FOR NO KEY UPDATE',
355
+ 'FOR UPDATE'
356
+ ]
357
+ def deparse_lockingclause(node)
358
+ output = []
359
+ output << LOCK_CLAUSE_STRENGTH[node['strength']]
360
+ if node['lockedRels']
361
+ output << 'OF'
362
+ output << node['lockedRels'].map do |item|
363
+ deparse_item(item)
364
+ end.join(', ')
365
+ end
366
+ output.join(' ')
367
+ end
368
+
348
369
  def deparse_sortby(node)
349
370
  output = []
350
371
  output << deparse_item(node['node'])
@@ -464,6 +485,8 @@ class PgQuery
464
485
 
465
486
  output << 'TABLE'
466
487
 
488
+ output << 'IF NOT EXISTS' if node['if_not_exists']
489
+
467
490
  output << deparse_item(node['relation'])
468
491
 
469
492
  output << '(' + node['tableElts'].map do |item|
@@ -557,6 +580,11 @@ class PgQuery
557
580
  end.join(', ')
558
581
  end
559
582
 
583
+ if node['havingClause']
584
+ output << 'HAVING'
585
+ output << deparse_item(node['havingClause'])
586
+ end
587
+
560
588
  if node['sortClause']
561
589
  output << 'ORDER BY'
562
590
  output << node['sortClause'].map do |item|
@@ -574,6 +602,12 @@ class PgQuery
574
602
  output << deparse_item(node['limitOffset'])
575
603
  end
576
604
 
605
+ if node['lockingClause']
606
+ node['lockingClause'].map do |item|
607
+ output << deparse_item(item)
608
+ end
609
+ end
610
+
577
611
  output.join(' ')
578
612
  end
579
613
 
@@ -1,3 +1,3 @@
1
1
  class PgQuery
2
- VERSION = '0.6.4'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_query
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Fittl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -94,6 +94,9 @@ files:
94
94
  - README.md
95
95
  - Rakefile
96
96
  - ext/pg_query/extconf.rb
97
+ - ext/pg_query/patches/01_output_nodes_as_json.patch
98
+ - ext/pg_query/patches/02_parse_replacement_char.patch
99
+ - ext/pg_query/patches/03_regenerate_bison_flex_files.patch
97
100
  - ext/pg_query/pg_polyfills.c
98
101
  - ext/pg_query/pg_query.c
99
102
  - ext/pg_query/pg_query.h