rquerypad 0.1.21 → 0.1.22
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.
- data/CHANGELOG +3 -0
- data/README +2 -2
- data/Rakefile +1 -1
- data/lib/rquerypad.rb +19 -53
- metadata +7 -7
data/CHANGELOG
CHANGED
data/README
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Rquerypad
|
1
|
+
Rquerypad
|
2
2
|
=========
|
3
3
|
Simplify query options with association automation and improve inner join for activerecord of rails
|
4
4
|
|
@@ -41,7 +41,7 @@ $RQUERYPAD_DEBUG = true
|
|
41
41
|
|
42
42
|
Test
|
43
43
|
=======
|
44
|
-
Note: current migrate script works only in rails 2.0
|
44
|
+
Note: current migrate script works only in rails 2.0 or later
|
45
45
|
|
46
46
|
1.Prepare
|
47
47
|
|
data/Rakefile
CHANGED
data/lib/rquerypad.rb
CHANGED
@@ -98,25 +98,7 @@ class Rquerypad
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
}
|
101
|
-
|
102
|
-
Hash.class_eval do
|
103
|
-
def single_lt?(other)
|
104
|
-
return false if self == other
|
105
|
-
return true if self.size == 0
|
106
|
-
return false unless other.is_a?(Hash)
|
107
|
-
return false if other.nil? || other.size < self.size
|
108
|
-
return false if self.size != other.size || self.size > 1
|
109
|
-
a = self.to_a[0]
|
110
|
-
o = other.to_a[0]
|
111
|
-
return false if a[0] != o[0]
|
112
|
-
return true unless a[1].is_a?(Hash)
|
113
|
-
a[1].single_lt?(o[1])
|
114
|
-
end
|
115
|
-
def single_gt?(other)
|
116
|
-
return false if self == other
|
117
|
-
return !(single_lt?(other))
|
118
|
-
end
|
119
|
-
end
|
101
|
+
|
120
102
|
end
|
121
103
|
|
122
104
|
def process_inner_join(sql, inner_joins)
|
@@ -163,48 +145,32 @@ class Rquerypad
|
|
163
145
|
return new_options if @new_include.empty?
|
164
146
|
# #generate new include
|
165
147
|
|
166
|
-
|
148
|
+
|
167
149
|
unless @new_include.nil?
|
168
150
|
new_options[:include] ||= []
|
151
|
+
new_options[:include] = [new_options[:include] ] unless new_options[:include] .is_a?(Array)
|
169
152
|
new_options[:include] += @new_include
|
170
|
-
new_options[:include].uniq!
|
171
153
|
end
|
154
|
+
new_options[:include] = remove_dup_includes(new_options[:include])
|
155
|
+
|
172
156
|
new_options[:inner_joins] = @inner_joins unless @inner_joins.empty?
|
173
157
|
new_options
|
174
158
|
end
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
final_includes << ni
|
189
|
-
end
|
190
|
-
elsif ni.entries[0][0].to_s == final_includes[i].to_s
|
191
|
-
final_includes[i] = ni
|
192
|
-
else
|
193
|
-
final_includes << ni
|
194
|
-
end
|
195
|
-
else
|
196
|
-
if final_includes[i].is_a?(Hash)
|
197
|
-
final_includes << ni if final_includes[i].entries[0][0].to_s != ni.to_s
|
198
|
-
else
|
199
|
-
final_includes << ni if final_includes[i].to_s != ni.to_s
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
else
|
204
|
-
final_includes << ni
|
205
|
-
end
|
159
|
+
|
160
|
+
#suppose {:a => :b} {:a => {:b => :c} }, will remove {:a => :b}
|
161
|
+
def remove_dup_includes(options)
|
162
|
+
result = {}
|
163
|
+
options.each {|o| result[o.inspect.gsub(/[\{\}\":]/, '') + "=>"] = o}
|
164
|
+
result = result.sort.reverse
|
165
|
+
keep_keys = []
|
166
|
+
options = []
|
167
|
+
result.each do |o|
|
168
|
+
skip = false
|
169
|
+
keep_keys.each {|k| skip = true if (k.index(o[0]) == 0)}
|
170
|
+
options << o[1] unless skip
|
171
|
+
keep_keys << o[0]
|
206
172
|
end
|
207
|
-
|
173
|
+
options
|
208
174
|
end
|
209
175
|
|
210
176
|
def improve_conditions(options)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rquerypad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leon Li
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-04-
|
12
|
+
date: 2009-04-30 00:00:00 +08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: Simplify query options with association automation and improve inner join for ActiveRecord of rails by providing a compact and OO query language instead of writing some explicit join
|
16
|
+
description: " Simplify query options with association automation and improve inner join for ActiveRecord of rails by providing a compact and OO query language instead of writing some explicit join\n"
|
17
17
|
email: scorpio_leon@hotmail.com
|
18
18
|
executables: []
|
19
19
|
|
@@ -31,16 +31,16 @@ files:
|
|
31
31
|
- test/test_helper.rb
|
32
32
|
- test/rquerypad_test.rb
|
33
33
|
- test/model.rb
|
34
|
-
- test/fixtures
|
35
34
|
- test/fixtures/forum_replies.yml
|
36
35
|
- test/fixtures/users.yml
|
37
36
|
- test/fixtures/forum_threads.yml
|
38
|
-
- test/migrate
|
39
37
|
- test/migrate/003_create_replies.rb
|
40
38
|
- test/migrate/001_create_users.rb
|
41
39
|
- test/migrate/002_create_threads.rb
|
42
40
|
has_rdoc: false
|
43
41
|
homepage: http://rquerypad.rubyforge.org/
|
42
|
+
licenses: []
|
43
|
+
|
44
44
|
post_install_message:
|
45
45
|
rdoc_options: []
|
46
46
|
|
@@ -61,9 +61,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
requirements: []
|
62
62
|
|
63
63
|
rubyforge_project: Rquerypad
|
64
|
-
rubygems_version: 1.3.
|
64
|
+
rubygems_version: 1.3.2
|
65
65
|
signing_key:
|
66
|
-
specification_version:
|
66
|
+
specification_version: 3
|
67
67
|
summary: Simplify query with OO way and improve inner join for ActiveRecord
|
68
68
|
test_files: []
|
69
69
|
|