sparkql 1.1.4 → 1.1.5
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 +8 -8
- data/CHANGELOG.md +5 -1
- data/VERSION +1 -1
- data/lib/sparkql/parser_tools.rb +13 -8
- data/test/unit/parser_test.rb +40 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzQ3MzkyNGE3ZDhjMTMxNDBjY2EwODcxMzE0OWMwZjQ3MWJhNzE3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTYxYzJjMjY5NDI0YTc2MTAwZWZlY2NiNGI1ZjQzZWVkMzUzNmU4Mw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjgyNGU2ZGM4YjIxZTBjODI2YmY0MjhkY2ZkZjE1ZjM1NDdjOTkyY2MxMDVh
|
10
|
+
NjAyOTVkNTg1MGY1ODgxYzMyNjRlNTVhYTRmNDBkYzMxODliOTFiOGE5NzJl
|
11
|
+
Y2JjMWNkODEyYmYwMDEwMWRjNThiMzgzMDM2ODkxMjZhOWNjOWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODE3MTcxNzI1MDg0M2EyZDhlZTk1MzYwYmNkNTE3OTE0YTE5NDJiMjY4YzQz
|
14
|
+
YjJiYzQ1MDI0NzQyYzYzZTYxNTNhZDY4YTY4NzU0NjBlNTgwYTZkYzA1MDM2
|
15
|
+
M2E0MzhiZDdkNGM0YmJkNTMxNzAwOWZhMjUzNmM4OTljMzlmYmU=
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
+
v1.1.4, 2016-11-11 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.4...v1.1.5))
|
2
|
+
-------------------
|
3
|
+
* [BUGFIX] Corrected levels for unary and conjunction elements of an expression
|
4
|
+
|
1
5
|
v1.1.4, 2016-11-11 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.3...v1.1.4))
|
2
6
|
-------------------
|
3
7
|
* [IMPROVEMENT] New functions: contains(), startswith(), endswith()
|
4
8
|
|
5
9
|
v1.1.3, 2016-11-10 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.2...v1.1.3))
|
6
10
|
-------------------
|
7
|
-
* [IMPROVEMENT] New functions: tolower() and toupper()
|
11
|
+
* [IMPROVEMENT] New functions: tolower() and toupper()
|
8
12
|
|
9
13
|
v1.1.2, 2016-11-08 ([changes](https://github.com/sparkapi/sparkql/compare/v1.1.1...v1.1.2))
|
10
14
|
-------------------
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.5
|
data/lib/sparkql/parser_tools.rb
CHANGED
@@ -40,8 +40,10 @@ module Sparkql::ParserTools
|
|
40
40
|
end
|
41
41
|
custom_field = field.start_with?('"')
|
42
42
|
block_group = (@lexer.level == 0) ? 0 : @lexer.block_group_identifier
|
43
|
-
expression = {:field => field, :operator => operator, :conjunction => 'And',
|
44
|
-
:
|
43
|
+
expression = {:field => field, :operator => operator, :conjunction => 'And',
|
44
|
+
:conjunction_level => 0, :level => @lexer.level,
|
45
|
+
:block_group => block_group, :custom_field => custom_field}.
|
46
|
+
merge!(field_args)
|
45
47
|
expression = val.merge(expression) unless val.nil?
|
46
48
|
expression[:condition] ||= expression[:value]
|
47
49
|
validate_level_depth expression
|
@@ -63,13 +65,16 @@ module Sparkql::ParserTools
|
|
63
65
|
# Handles the case when a SparkQL filter string
|
64
66
|
# begins with a unary operator, and is nested, such as:
|
65
67
|
# Not (Not Field Eq 1)
|
66
|
-
# In this instance we treat the outer unary as a conjunction.
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
# In this instance we treat the outer unary as a conjunction. With any other
|
69
|
+
# expression this would be the case, so that should make processing
|
70
|
+
# consistent.
|
71
|
+
if exp.first[:unary] && @lexer.level == 0
|
72
|
+
exp.first[:conjunction] = conj
|
73
|
+
exp.first[:conjunction_level] = @lexer.level
|
74
|
+
else
|
75
|
+
exp.first[:unary] = conj
|
76
|
+
exp.first[:unary_level] = @lexer.level
|
70
77
|
end
|
71
|
-
exp.first[:unary] = conj
|
72
|
-
exp.first[:unary_level] = @lexer.level
|
73
78
|
|
74
79
|
exp
|
75
80
|
end
|
data/test/unit/parser_test.rb
CHANGED
@@ -494,10 +494,15 @@ class ParserTest < Test::Unit::TestCase
|
|
494
494
|
e3 = expressions[2]
|
495
495
|
e4 = expressions[3]
|
496
496
|
|
497
|
+
assert_equal 1, e1[:level]
|
497
498
|
assert_equal "Not", e1[:unary]
|
499
|
+
assert_equal 1, e1[:unary_level]
|
498
500
|
assert_equal "Not", e1[:conjunction]
|
501
|
+
assert_equal 0, e1[:conjunction_level]
|
499
502
|
assert_equal "Not", e2[:unary]
|
503
|
+
assert_equal 1, e2[:unary_level]
|
500
504
|
assert_equal "Not", e2[:conjunction]
|
505
|
+
assert_equal 0, e2[:conjunction_level]
|
501
506
|
assert_equal "Not", e3[:unary]
|
502
507
|
assert_equal "And", e3[:conjunction]
|
503
508
|
assert_nil e4[:unary]
|
@@ -512,7 +517,42 @@ class ParserTest < Test::Unit::TestCase
|
|
512
517
|
e1 = expressions.first
|
513
518
|
|
514
519
|
assert_equal "Not", e1[:unary]
|
520
|
+
assert_equal 0, e1[:unary_level]
|
515
521
|
assert_equal "And", e1[:conjunction]
|
522
|
+
assert_equal 0, e1[:conjunction_level]
|
523
|
+
|
524
|
+
filter = "(Not ListPrice Eq 1)"
|
525
|
+
|
526
|
+
@parser = Parser.new
|
527
|
+
expressions = @parser.parse(filter)
|
528
|
+
assert !@parser.errors?, @parser.inspect
|
529
|
+
|
530
|
+
e1 = expressions.first
|
531
|
+
|
532
|
+
assert_equal "Not", e1[:unary]
|
533
|
+
assert_equal 1, e1[:unary_level]
|
534
|
+
assert_equal "And", e1[:conjunction]
|
535
|
+
assert_equal 0, e1[:conjunction_level]
|
536
|
+
|
537
|
+
filter = "Not (Not ListPrice Eq 1 Not BathsTotal Eq 2)"
|
538
|
+
|
539
|
+
@parser = Parser.new
|
540
|
+
expressions = @parser.parse(filter)
|
541
|
+
assert !@parser.errors?, @parser.inspect
|
542
|
+
|
543
|
+
e1 = expressions.first
|
544
|
+
e2 = expressions[1]
|
545
|
+
|
546
|
+
assert_equal "Not", e1[:unary]
|
547
|
+
assert_equal 1, e1[:unary_level]
|
548
|
+
assert_equal "Not", e1[:conjunction]
|
549
|
+
assert_equal 0, e1[:conjunction_level]
|
550
|
+
assert_nil e2[:unary]
|
551
|
+
assert_nil e2[:unary_level]
|
552
|
+
assert_equal 1, e2[:level]
|
553
|
+
assert_equal "Not", e2[:conjunction]
|
554
|
+
assert_equal 1, e2[:conjunction_level]
|
555
|
+
|
516
556
|
end
|
517
557
|
|
518
558
|
def test_expression_conditions_attribute
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sparkql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wade McEwen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: georuby
|