cowtech-rails 1.7.3.1 → 1.7.4.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -145,7 +145,7 @@ module Cowtech
|
|
145
145
|
parameter = :search unless parameter
|
146
146
|
|
147
147
|
self.crud_query_add_condition(data, "(#{self.crud_get_class(data).table_name}.#{self.crud_get_class(data).deleted_column} = :deleted)", {:deleted => false}) unless data[:skip_deleted]
|
148
|
-
|
148
|
+
|
149
149
|
# GET QUERY
|
150
150
|
args = params[parameter] unless args
|
151
151
|
|
@@ -155,7 +155,7 @@ module Cowtech
|
|
155
155
|
# BUILD QUERY
|
156
156
|
data[:query_params].merge!(parameters)
|
157
157
|
search_query = []
|
158
|
-
fields.each do |field| search_query << "(#{search.gsub("@FIELD@", field.to_s)})" end
|
158
|
+
fields.each do |field| search_query << "(#{search.gsub("@FIELD@", "#{self.crud_get_class(data).table_name}.#{field.to_s}")})" end
|
159
159
|
|
160
160
|
# ADD OPTIONAL DATA
|
161
161
|
if externals then
|
@@ -164,12 +164,12 @@ module Cowtech
|
|
164
164
|
|
165
165
|
unless external[:manual] then
|
166
166
|
external_conds = []
|
167
|
-
external.fetch(:fields, []).each do |external_field| external_conds << "(#{search.gsub("@FIELD@", external_field.to_s)})" end
|
167
|
+
external.fetch(:fields, []).each do |external_field| external_conds << "(#{search.gsub("@FIELD@", "#{external[:table]}.#{external_field.to_s}")})" end
|
168
168
|
external_field = external.fetch(:external_field, "id")
|
169
169
|
external_query = "(#{external.fetch(:field, "id")} IN (SELECT #{external.fetch(:external_field, "id")} FROM #{external[:table]} WHERE #{external_conds.join(" OR ")}))"
|
170
170
|
else
|
171
171
|
external_conds = []
|
172
|
-
external.fetch(:fields, []).each do |external_field| external_conds << "(#{search.gsub("@FIELD@", external_field.to_s)})" end
|
172
|
+
external.fetch(:fields, []).each do |external_field| external_conds << "(#{search.gsub("@FIELD@", "#{external[:table]}.#{external_field.to_s}")})" end
|
173
173
|
external_query = external[:query].gsub("@SEARCH@", external_conds.join(" OR "))
|
174
174
|
end
|
175
175
|
|
data/lib/cowtech/version.rb
CHANGED