binarylogic-searchlogic 2.2.2 → 2.2.3
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== 2.2.3 released 2009-07-31
|
2
|
+
|
3
|
+
* Fixed bug when an associations named scope joins is a string or an array of strings, the joins we add in automatically should also be a string, not a symbol.
|
4
|
+
|
1
5
|
== 2.2.2 released 2009-07-31
|
2
6
|
|
3
7
|
* Fix bug to give priority to local columns.
|
data/VERSION.yml
CHANGED
@@ -61,8 +61,7 @@ module Searchlogic
|
|
61
61
|
# The underlying condition doesn't require any parameters, so let's just create a simple
|
62
62
|
# named scope that is based on a hash.
|
63
63
|
options = scope.scope(:find)
|
64
|
-
options
|
65
|
-
options[:joins] = options[:joins].blank? ? association.name : {association.name => options[:joins]}
|
64
|
+
prepare_named_scope_options(options, association)
|
66
65
|
options
|
67
66
|
else
|
68
67
|
# The underlying condition requires parameters, let's match the parameters it requires
|
@@ -88,13 +87,22 @@ module Searchlogic
|
|
88
87
|
searchlogic_lambda(:#{arg_type}) { |#{proc_args.join(",")}|
|
89
88
|
scope = association.klass.send(association_condition, #{proc_args.join(",")})
|
90
89
|
options = scope ? scope.scope(:find) : {}
|
91
|
-
options
|
92
|
-
options[:joins] = options[:joins].blank? ? association.name : {association.name => options[:joins]}
|
90
|
+
prepare_named_scope_options(options, association)
|
93
91
|
options
|
94
92
|
}
|
95
93
|
end_eval
|
96
94
|
end
|
97
95
|
end
|
96
|
+
|
97
|
+
def prepare_named_scope_options(options, association)
|
98
|
+
options.delete(:readonly)
|
99
|
+
|
100
|
+
if options[:joins].is_a?(String) || array_of_strings?(options[:joins])
|
101
|
+
options[:joins] = [inner_joins(association.name), options[:joins]].flatten
|
102
|
+
else
|
103
|
+
options[:joins] = options[:joins].blank? ? association.name : {association.name => options[:joins]}
|
104
|
+
end
|
105
|
+
end
|
98
106
|
end
|
99
107
|
end
|
100
108
|
end
|
data/searchlogic.gemspec
CHANGED
@@ -125,4 +125,9 @@ describe "Association Conditions" do
|
|
125
125
|
order = user.orders.create(:total => 20, :taxes => 3)
|
126
126
|
Company.users_orders_taxes_lt(50).ascend_by_users_orders_total.all(:include => {:users => :orders}).should == Company.all
|
127
127
|
end
|
128
|
+
|
129
|
+
it "should automatically add string joins if the association condition is using strings" do
|
130
|
+
User.named_scope(:orders_big_id, :joins => User.inner_joins(:orders))
|
131
|
+
Company.users_orders_big_id.proxy_options.should == {:joins=>[" INNER JOIN \"users\" ON users.company_id = companies.id ", " INNER JOIN \"orders\" ON orders.user_id = users.id "]}
|
132
|
+
end
|
128
133
|
end
|