pg_query 0.11.2 → 0.11.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/ext/pg_query/extconf.rb +2 -2
- data/lib/pg_query/deparse.rb +44 -0
- data/lib/pg_query/node_types.rb +7 -0
- data/lib/pg_query/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a239534a583610c96a6a32facaa233733eadecff
|
4
|
+
data.tar.gz: f1e5a88a394eed863a072fd95c509e03a72c4eda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 686011140d6fb957646700cc78f0e22f7786eadc859e588e19aa0abf4271993684abf27cea0125498923046e35c447409b11c112eadbcb6f4404d558f8f35728
|
7
|
+
data.tar.gz: 4e1ee3b8a8f1f95b852a9966c98bc85278d78812e17c65ddf0391166beb89249e107e83e9377db63ce929f8c80fa7c7971cd1711011d799af5287f58cfbdd512
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.11.3 2016-12-06
|
4
|
+
|
5
|
+
* Update to newest libpg_query version (9.5-1.4.2)
|
6
|
+
* Cut off fingerprints at 100 nodes deep to avoid excessive runtimes/memory
|
7
|
+
* Fix warning on Linux due to missing asprintf include
|
8
|
+
* Improved deparsing [@jcsjcs](https://github.com/jcsjcs)
|
9
|
+
* Float [#54](https://github.com/lfittl/pg_query/pull/54)
|
10
|
+
* BETWEEN [#55](https://github.com/lfittl/pg_query/pull/55)
|
11
|
+
* NULLIF [#56](https://github.com/lfittl/pg_query/pull/56)
|
12
|
+
* SELECT NULL and BooleanTest [#57](https://github.com/lfittl/pg_query/pull/57)
|
13
|
+
* Fix build on BSD systems [#58](https://github.com/lfittl/pg_query/pull/58) [@myfreeweb](https://github.com/myfreeweb)
|
14
|
+
|
15
|
+
|
3
16
|
## 0.11.2 2016-06-27
|
4
17
|
|
5
18
|
* Update to newest libpg_query version (9.5-1.4.1)
|
data/ext/pg_query/extconf.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'mkmf'
|
4
4
|
require 'open-uri'
|
5
5
|
|
6
|
-
LIB_PG_QUERY_TAG = '9.5-1.4.
|
6
|
+
LIB_PG_QUERY_TAG = '9.5-1.4.2'
|
7
7
|
|
8
8
|
workdir = Dir.pwd
|
9
9
|
libdir = File.join(workdir, 'libpg_query-' + LIB_PG_QUERY_TAG)
|
@@ -24,7 +24,7 @@ end
|
|
24
24
|
|
25
25
|
unless Dir.exist?(libfile)
|
26
26
|
# Build libpg_query (and parts of PostgreSQL)
|
27
|
-
system("cd #{libdir}; make build")
|
27
|
+
system("cd #{libdir}; #{ENV['MAKE'] || (RUBY_PLATFORM =~ /bsd/ ? 'gmake' : 'make')} build")
|
28
28
|
end
|
29
29
|
|
30
30
|
# Copy test files (this intentionally overwrites existing files!)
|
data/lib/pg_query/deparse.rb
CHANGED
@@ -38,6 +38,10 @@ class PgQuery
|
|
38
38
|
deparse_aexpr_in(node)
|
39
39
|
when CONSTR_TYPE_FOREIGN
|
40
40
|
deparse_aexpr_like(node)
|
41
|
+
when AEXPR_BETWEEN, AEXPR_NOT_BETWEEN, AEXPR_BETWEEN_SYM, AEXPR_NOT_BETWEEN_SYM
|
42
|
+
deparse_aexpr_between(node)
|
43
|
+
when AEXPR_NULLIF
|
44
|
+
deparse_aexpr_nullif(node)
|
41
45
|
else
|
42
46
|
fail format("Can't deparse: %s: %s", type, node.inspect)
|
43
47
|
end
|
@@ -68,6 +72,8 @@ class PgQuery
|
|
68
72
|
when BOOL_EXPR_NOT
|
69
73
|
deparse_bool_expr_not(node)
|
70
74
|
end
|
75
|
+
when BOOLEAN_TEST
|
76
|
+
deparse_boolean_test(node)
|
71
77
|
when CASE_EXPR
|
72
78
|
deparse_case(node)
|
73
79
|
when COALESCE_EXPR
|
@@ -150,6 +156,10 @@ class PgQuery
|
|
150
156
|
end
|
151
157
|
when INTEGER
|
152
158
|
node['ival'].to_s
|
159
|
+
when FLOAT
|
160
|
+
node['str']
|
161
|
+
when NULL
|
162
|
+
'NULL'
|
153
163
|
else
|
154
164
|
fail format("Can't deparse: %s: %s", type, node.inspect)
|
155
165
|
end
|
@@ -326,6 +336,18 @@ class PgQuery
|
|
326
336
|
format('NOT %s', deparse_item(node['args'][0]))
|
327
337
|
end
|
328
338
|
|
339
|
+
BOOLEAN_TEST_TYPE_TO_STRING = {
|
340
|
+
BOOLEAN_TEST_TRUE => ' IS TRUE',
|
341
|
+
BOOLEAN_TEST_NOT_TRUE => ' IS NOT TRUE',
|
342
|
+
BOOLEAN_TEST_FALSE => ' IS FALSE',
|
343
|
+
BOOLEAN_TEST_NOT_FALSE => ' IS NOT FALSE',
|
344
|
+
BOOLEAN_TEST_UNKNOWN => ' IS UNKNOWN',
|
345
|
+
BOOLEAN_TEST_NOT_UNKNOWN => ' IS NOT UNKNOWN'
|
346
|
+
}.freeze
|
347
|
+
def deparse_boolean_test(node)
|
348
|
+
deparse_item(node['arg']) + BOOLEAN_TEST_TYPE_TO_STRING[node['booltesttype']]
|
349
|
+
end
|
350
|
+
|
329
351
|
def deparse_range_function(node)
|
330
352
|
output = []
|
331
353
|
output << 'LATERAL' if node['lateral']
|
@@ -375,6 +397,28 @@ class PgQuery
|
|
375
397
|
output.join(' ' + deparse_item(node['name'][0], :operator) + ' ')
|
376
398
|
end
|
377
399
|
|
400
|
+
def deparse_aexpr_between(node)
|
401
|
+
between = case node['kind']
|
402
|
+
when AEXPR_BETWEEN
|
403
|
+
' BETWEEN '
|
404
|
+
when AEXPR_NOT_BETWEEN
|
405
|
+
' NOT BETWEEN '
|
406
|
+
when AEXPR_BETWEEN_SYM
|
407
|
+
' BETWEEN SYMMETRIC '
|
408
|
+
when AEXPR_NOT_BETWEEN_SYM
|
409
|
+
' NOT BETWEEN SYMMETRIC '
|
410
|
+
end
|
411
|
+
name = deparse_item(node['lexpr'])
|
412
|
+
output = node['rexpr'].map { |n| deparse_item(n) }
|
413
|
+
name << between << output.join(' AND ')
|
414
|
+
end
|
415
|
+
|
416
|
+
def deparse_aexpr_nullif(node)
|
417
|
+
lexpr = deparse_item(node['lexpr'])
|
418
|
+
rexpr = deparse_item(node['rexpr'])
|
419
|
+
format('NULLIF(%s, %s)', lexpr, rexpr)
|
420
|
+
end
|
421
|
+
|
378
422
|
def deparse_joinexpr(node)
|
379
423
|
output = []
|
380
424
|
output << deparse_item(node['larg'])
|
data/lib/pg_query/node_types.rb
CHANGED
@@ -113,6 +113,13 @@ class PgQuery
|
|
113
113
|
BOOL_EXPR_OR = 1
|
114
114
|
BOOL_EXPR_NOT = 2
|
115
115
|
|
116
|
+
BOOLEAN_TEST_TRUE = 0
|
117
|
+
BOOLEAN_TEST_NOT_TRUE = 1
|
118
|
+
BOOLEAN_TEST_FALSE = 2
|
119
|
+
BOOLEAN_TEST_NOT_FALSE = 3
|
120
|
+
BOOLEAN_TEST_UNKNOWN = 4
|
121
|
+
BOOLEAN_TEST_NOT_UNKNOWN = 5
|
122
|
+
|
116
123
|
AEXPR_OP = 0 # normal operator
|
117
124
|
AEXPR_OP_ANY = 1 # scalar op ANY (array)
|
118
125
|
AEXPR_OP_ALL = 2 # scalar op ALL (array)
|
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.11.
|
4
|
+
version: 0.11.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Fittl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.5.1
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: PostgreSQL query parsing and normalization library
|