activecube 0.1.30 → 0.1.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/activecube/query/item.rb +30 -0
- data/lib/activecube/query/measure.rb +2 -0
- data/lib/activecube/query/selector.rb +1 -0
- data/lib/activecube/query/slice.rb +2 -0
- data/lib/activecube/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c706faf950e642b3216ee5bce134ae45c9ad1047395825426897961a2bf357e
|
4
|
+
data.tar.gz: eb49f277b4fe9ade7817fd9b3d69389ec0879ae3a92004c5d2fa85a2a19a1d70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5754c7e2658c9456bee51c66f21ca42da0f7198bf155b06386e845745da098c282a89cd4c388d3581421d0c9e89704accd2249c45b3c30ff32e72744d0b52fbe
|
7
|
+
data.tar.gz: e5ff2a9a0ac8706dae669b7c0355f2e04ff5f6bb2ca7415253ada1fe76d1036dbdcd8d5b9202b3c10cd19996184b52498fecd7debf4be4547af01f3b27a0e36b
|
data/Gemfile.lock
CHANGED
@@ -22,5 +22,35 @@ module Activecube::Query
|
|
22
22
|
"#{definition.class.name}(#{key})"
|
23
23
|
end
|
24
24
|
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def append_with! model, cube_query, table, query
|
29
|
+
|
30
|
+
if definition.respond_to?(:with_expression) &&
|
31
|
+
(with_expression = definition.with_expression(model, cube_query, table, query))
|
32
|
+
with_expression.each_pair do |key, expr|
|
33
|
+
query = try_append_with(query, key, expr)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
query
|
37
|
+
end
|
38
|
+
|
39
|
+
def try_append_with(query, key, expr)
|
40
|
+
expr = Arel.sql(expr) if expr.kind_of?(String)
|
41
|
+
if (with = query.ast.with)
|
42
|
+
existing = with.expr.detect{|expr| expr.right==key }
|
43
|
+
if existing
|
44
|
+
raise "Key #{key} defined twice in WITH statement, with different expressions #{expr.to_sql} AND #{existing.left}" if existing.left!=expr.to_s
|
45
|
+
query
|
46
|
+
else
|
47
|
+
query.with(with.expr + [expr.as(key)])
|
48
|
+
end
|
49
|
+
else
|
50
|
+
query.with(expr.as(key))
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
25
55
|
end
|
26
56
|
end
|
@@ -36,6 +36,7 @@ module Activecube::Query
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def append_query model, cube_query, table, query
|
39
|
+
query = append_with!(model, cube_query, table, query)
|
39
40
|
attr_alias = "`#{key.to_s}`"
|
40
41
|
expr = definition.expression model, table, self, cube_query
|
41
42
|
query.project expr.as(attr_alias)
|
@@ -53,6 +54,7 @@ module Activecube::Query
|
|
53
54
|
|
54
55
|
private
|
55
56
|
|
57
|
+
|
56
58
|
def modifier_methods!
|
57
59
|
definition.class.modifiers.each_pair do |key, modifier|
|
58
60
|
define_singleton_method key do |*args|
|
@@ -60,6 +60,8 @@ module Activecube::Query
|
|
60
60
|
|
61
61
|
def append_query model, cube_query, table, query
|
62
62
|
|
63
|
+
query = append_with!(model, cube_query, table, query)
|
64
|
+
|
63
65
|
attr_alias = "`#{key.to_s}`"
|
64
66
|
expr = (parent || definition.respond_to?(:expression)) ?
|
65
67
|
Arel.sql(definition.expression( model, table, self, cube_query) ) :
|
data/lib/activecube/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activecube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aleksey Studnev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|