cowtech-rails 2.7.0.0 → 2.7.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -122,21 +122,25 @@ module Cowtech
122
122
  expr = self.mongo_parse_search(search_query)
123
123
 
124
124
  # Build the query
125
+ or_query = []
125
126
  (args[:fields] || []).each do |field|
126
- @mongo_query = @mongo_query.any_of(field.to_sym => Regexp.new(expr, Regexp::EXTENDED | Regexp::MULTILINE | Regexp::IGNORECASE))
127
+ or_query << {field.to_sym => Regexp.new(expr, Regexp::EXTENDED | Regexp::MULTILINE | Regexp::IGNORECASE)}
127
128
  end
128
129
 
129
130
  # Now add external fields
130
131
  # TODO: Can we enhance this?
131
132
  (args[:external] || []).each do |external|
132
133
  external_query = external[:class].not_deleted
134
+ eor_query = []
133
135
  (external[:fields] || []).each do |field|
134
- external_query = external_query.any_of(field.to_sym => Regexp.new(expr, Regexp::EXTENDED | Regexp::MULTILINE | Regexp::IGNORECASE))
136
+ eor_query << {field.to_sym => Regexp.new(expr, Regexp::EXTENDED | Regexp::MULTILINE | Regexp::IGNORECASE)}
135
137
  end
136
138
 
137
- ids = external_query.only(:id).all.collect {|r| r.id }
138
- @mongo_query = @mongo_query.any_of(:cliente_id.in => ids) if ids.count > 0
139
+ ids = external_query.any_of(eor_query).only(:id).all.collect {|r| r.id }
140
+ or_query << {external[:foreign_key].in => ids} if ids.count > 0
139
141
  end
142
+
143
+ @mongo_query = @mongo_query.any_of(or_query)
140
144
  end
141
145
 
142
146
  @mongo_query
@@ -9,7 +9,7 @@ module Cowtech
9
9
  module Version
10
10
  MAJOR = 2
11
11
  MINOR = 7
12
- PATCH = 0
12
+ PATCH = 1
13
13
  BUILD = 0
14
14
 
15
15
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cowtech-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0.0
4
+ version: 2.7.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-04 00:00:00.000000000Z
12
+ date: 2012-01-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cowtech-extensions
16
- requirement: &70308162700160 !ruby/object:Gem::Requirement
16
+ requirement: &70220120113560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70308162700160
24
+ version_requirements: *70220120113560
25
25
  description: A general purpose Rails utility plugin.
26
26
  email: shogun_panda@me.com
27
27
  executables: []