hotdog 0.17.0 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hotdog/expression/semantics.rb +34 -18
- data/lib/hotdog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd0467d9928ac5366eec849cb7def564dd0d8ae3
|
4
|
+
data.tar.gz: 9588371163cbb077511b8b094360bb4ac4c7573d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f7f359862f6d3b7b79a89d03b04406e3a4efb07655084f9526346c1db88601b45252918a910e5c2081bafff8b8ef334d9555e37b12c2db73915dda1a2c1b748
|
7
|
+
data.tar.gz: cd802bb419145c53342d0409aa1623e376b7577aaa09be595f2474c13bae62a2b96470d258839b0e9c12f69c002dda5b7e98204c1b81b9a75342fc30a337663c
|
@@ -437,10 +437,6 @@ module Hotdog
|
|
437
437
|
@args = args
|
438
438
|
end
|
439
439
|
|
440
|
-
def optimize(options={})
|
441
|
-
self
|
442
|
-
end
|
443
|
-
|
444
440
|
def dump(options={})
|
445
441
|
args = @args.map { |arg|
|
446
442
|
if ExpressionNode === arg
|
@@ -452,6 +448,38 @@ module Hotdog
|
|
452
448
|
{funcall: @function.to_s, args: args}
|
453
449
|
end
|
454
450
|
|
451
|
+
def optimize(options={})
|
452
|
+
case function
|
453
|
+
when :HEAD
|
454
|
+
@args[0] = @args[0].optimize(options)
|
455
|
+
when :GROUP_BY
|
456
|
+
@args[0] = @args[0].optimize(options)
|
457
|
+
if TagExpressionNode === args[1]
|
458
|
+
# workaround for expressions like `ORDER_BY((environment:development),role)`
|
459
|
+
@args[1] = @args[1].tag_name
|
460
|
+
else
|
461
|
+
@args[1] = @args[1]
|
462
|
+
end
|
463
|
+
when :ORDER_BY
|
464
|
+
@args[0] = @args[0].optimize(options)
|
465
|
+
if @args[1]
|
466
|
+
if TagExpressionNode === @args[1]
|
467
|
+
# workaround for expressions like `ORDER_BY((environment:development),role)`
|
468
|
+
@args[1] = @args[1].tag_name
|
469
|
+
else
|
470
|
+
@args[1] = @args[1]
|
471
|
+
end
|
472
|
+
end
|
473
|
+
when :REVERSE
|
474
|
+
@args[0] = @args[0].optimize(options)
|
475
|
+
when :SHUFFLE
|
476
|
+
@args[0] = @args[0].optimize(options)
|
477
|
+
when :TAIL
|
478
|
+
@args[0] = @args[0].optimize(options)
|
479
|
+
end
|
480
|
+
self
|
481
|
+
end
|
482
|
+
|
455
483
|
def evaluate(environment, options={})
|
456
484
|
case function
|
457
485
|
when :HEAD
|
@@ -462,27 +490,15 @@ module Hotdog
|
|
462
490
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
463
491
|
"WHERE tags.name = ? AND hosts_tags.host_id IN (%s) " \
|
464
492
|
"GROUP BY tags.value;" % intermediate.map { "?" }.join(", ")
|
465
|
-
|
466
|
-
# workaround for expressions like `ORDER_BY((environment:development),role)`
|
467
|
-
args1 = args[1].tag_name
|
468
|
-
else
|
469
|
-
args1 = args[1]
|
470
|
-
end
|
471
|
-
QueryExpressionNode.new(q, [args1] + intermediate, fallback: nil).evaluate(environment, options)
|
493
|
+
QueryExpressionNode.new(q, [args[1]] + intermediate, fallback: nil).evaluate(environment, options)
|
472
494
|
when :ORDER_BY
|
473
495
|
intermediate = args[0].evaluate(environment, options)
|
474
496
|
if args[1]
|
475
|
-
if TagExpressionNode === args[1]
|
476
|
-
# workaround for expressions like `ORDER_BY((environment:development),role)`
|
477
|
-
args1 = args[1].tag_name
|
478
|
-
else
|
479
|
-
args1 = args[1]
|
480
|
-
end
|
481
497
|
q = "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags " \
|
482
498
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
483
499
|
"WHERE tags.name = ? AND hosts_tags.host_id IN (%s) " \
|
484
500
|
"ORDER BY tags.value;" % intermediate.map { "?" }.join(", ")
|
485
|
-
QueryExpressionNode.new(q, [
|
501
|
+
QueryExpressionNode.new(q, [args[1]] + intermediate, fallback: nil).evaluate(environment, options)
|
486
502
|
else
|
487
503
|
q = "SELECT DISTINCT hosts_tags.host_id FROM hosts_tags " \
|
488
504
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
data/lib/hotdog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotdog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|