pg_query 0.6.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +5 -6
- data/ext/pg_query/extconf.rb +22 -14
- data/ext/pg_query/patches/01_output_nodes_as_json.patch +4626 -0
- data/ext/pg_query/patches/02_parse_replacement_char.patch +370 -0
- data/ext/pg_query/patches/03_regenerate_bison_flex_files.patch +67225 -0
- data/lib/pg_query/deparse.rb +35 -1
- data/lib/pg_query/version.rb +1 -1
- metadata +5 -2
data/lib/pg_query/deparse.rb
CHANGED
@@ -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
|
-
|
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
|
|
data/lib/pg_query/version.rb
CHANGED
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.
|
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-
|
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
|