hyperion-sql 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hyperion/sql/datastore.rb +7 -3
- data/lib/hyperion/sql/query_builder.rb +21 -9
- metadata +6 -22
@@ -66,12 +66,16 @@ module Hyperion
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def pack_key(kind, key)
|
69
|
-
|
70
|
-
|
69
|
+
if key
|
70
|
+
table, id = Key.decompose_key(key)
|
71
|
+
id
|
72
|
+
end
|
71
73
|
end
|
72
74
|
|
73
75
|
def unpack_key(kind, key)
|
74
|
-
|
76
|
+
if key
|
77
|
+
Key.compose_key(kind, key)
|
78
|
+
end
|
75
79
|
end
|
76
80
|
|
77
81
|
private
|
@@ -80,21 +80,33 @@ module Hyperion
|
|
80
80
|
filter_sql = []
|
81
81
|
filter_values = []
|
82
82
|
filters.each do |filter|
|
83
|
-
|
84
|
-
filter_values << filter.value
|
83
|
+
apply_filter(filter, filter_sql, filter_values)
|
85
84
|
end
|
86
85
|
sql_query.append("WHERE #{filter_sql.join(' AND ')}", filter_values)
|
87
86
|
end
|
88
87
|
end
|
89
88
|
|
90
|
-
def
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
def apply_filter(filter, filter_sql, filter_values)
|
90
|
+
column = format_column(filter.field)
|
91
|
+
if filter.operator == '!='
|
92
|
+
if filter.value.nil?
|
93
|
+
filter_sql << "#{column} IS NOT NULL"
|
94
|
+
else
|
95
|
+
filter_sql << "(#{column} != ? OR #{column} IS NULL)"
|
96
|
+
filter_values << filter.value
|
97
|
+
end
|
98
|
+
elsif filter.operator == 'contains?'
|
99
|
+
if filter.value.include?(nil)
|
100
|
+
filter_sql << "(#{column} IN ? OR #{column} IS NULL)"
|
101
|
+
else
|
102
|
+
filter_sql << "#{column} IN ?"
|
103
|
+
end
|
104
|
+
filter_values << filter.value
|
105
|
+
elsif filter.operator == '=' && filter.value.nil?
|
106
|
+
filter_sql << "#{column} IS NULL"
|
96
107
|
else
|
97
|
-
operator
|
108
|
+
filter_sql << "#{column} #{filter.operator} ?"
|
109
|
+
filter_values << filter.value
|
98
110
|
end
|
99
111
|
end
|
100
112
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperion-sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.
|
37
|
+
version: 0.2.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,23 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: uuidtools
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - '='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: 2.1.3
|
54
|
-
type: :runtime
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 2.1.3
|
45
|
+
version: 0.2.0
|
62
46
|
- !ruby/object:Gem::Dependency
|
63
47
|
name: do_sqlite3
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,7 +50,7 @@ dependencies:
|
|
66
50
|
requirements:
|
67
51
|
- - '='
|
68
52
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.10.
|
53
|
+
version: 0.10.10
|
70
54
|
type: :development
|
71
55
|
prerelease: false
|
72
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +58,7 @@ dependencies:
|
|
74
58
|
requirements:
|
75
59
|
- - '='
|
76
60
|
- !ruby/object:Gem::Version
|
77
|
-
version: 0.10.
|
61
|
+
version: 0.10.10
|
78
62
|
description: Shared behavior for Sql databases
|
79
63
|
email:
|
80
64
|
- myles@8thlight.com
|