searchlogic 2.2.2 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 2
2
+ :patch: 3
3
3
  :major: 2
4
4
  :minor: 2
@@ -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.delete(:readonly)
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.delete(:readonly)
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{searchlogic}
5
- s.version = "2.2.2"
5
+ s.version = "2.2.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ben Johnson of Binary Logic"]
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: searchlogic
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Johnson of Binary Logic