activetokyocabinet 0.1.4 → 0.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.
|
@@ -23,25 +23,25 @@ module ActiveRecord
|
|
|
23
23
|
tdbopen(parsed_sql) do |tdb|
|
|
24
24
|
select_list = parsed_sql[:select_list]
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
if (count = parsed_sql[:count])
|
|
27
|
+
rows = [{count => count_rkey(tdb, parsed_sql)}]
|
|
28
|
+
else
|
|
29
|
+
rkeys(tdb, parsed_sql).each do |rkey|
|
|
30
|
+
rcols = tdb.get(rkey)
|
|
31
|
+
next if rcols.nil?
|
|
32
|
+
|
|
33
|
+
unless select_list.nil? or select_list.empty?
|
|
34
|
+
rcols = select_list.each do |k|
|
|
35
|
+
k = k.split('.').last
|
|
36
|
+
r[k] = rcols[k]
|
|
37
|
+
end
|
|
34
38
|
end
|
|
39
|
+
|
|
40
|
+
rcols['id'] = rkey.to_i
|
|
41
|
+
rows << rcols
|
|
35
42
|
end
|
|
36
|
-
|
|
37
|
-
rcols['id'] = rkey.to_i
|
|
38
|
-
rows << rcols
|
|
39
43
|
end
|
|
40
44
|
end
|
|
41
|
-
|
|
42
|
-
if (count = parsed_sql[:count])
|
|
43
|
-
rows = [{count => rows.length}]
|
|
44
|
-
end
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
return rows
|
|
@@ -125,13 +125,19 @@ module ActiveRecord
|
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
def rkeys(tdb, parsed_sql)
|
|
128
|
-
condition
|
|
129
|
-
condition ||= []
|
|
128
|
+
condition = parsed_sql[:condition] || []
|
|
130
129
|
|
|
131
130
|
unless condition.kind_of?(Array) and condition.all? {|i| i.kind_of?(Hash) }
|
|
132
|
-
return [
|
|
131
|
+
return [condition].flatten
|
|
133
132
|
end
|
|
134
133
|
|
|
134
|
+
query(tdb, parsed_sql).search
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def query(tdb, parsed_sql)
|
|
138
|
+
condition, order, limit, offset = parsed_sql.values_at(:condition, :order, :limit, :offset)
|
|
139
|
+
condition ||= []
|
|
140
|
+
|
|
135
141
|
qry = @query_klass::new(tdb)
|
|
136
142
|
|
|
137
143
|
condition.each do |cond|
|
|
@@ -152,9 +158,9 @@ module ActiveRecord
|
|
|
152
158
|
qry.setlimit(limit || 0, offset || 0)
|
|
153
159
|
end
|
|
154
160
|
|
|
155
|
-
return qry
|
|
161
|
+
return qry
|
|
156
162
|
end
|
|
157
|
-
private :
|
|
163
|
+
private :query
|
|
158
164
|
end
|
|
159
165
|
end
|
|
160
166
|
end
|
|
@@ -67,6 +67,11 @@ module ActiveRecord
|
|
|
67
67
|
end
|
|
68
68
|
private :tdbopen
|
|
69
69
|
|
|
70
|
+
def count_rkey(tdb, parsed_sql)
|
|
71
|
+
query(tdb, parsed_sql).searchcount
|
|
72
|
+
end
|
|
73
|
+
private :count_rkey
|
|
74
|
+
|
|
70
75
|
def setindex(table_name, name, type)
|
|
71
76
|
type = {
|
|
72
77
|
:lexical => TokyoTyrant::RDBTBL::ITLEXICAL,
|
data/spec/tcspec2ttspec.sh
CHANGED
|
File without changes
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activetokyocabinet
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- winebarrel
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-01-
|
|
12
|
+
date: 2010-01-11 00:00:00 +09:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|