+
+ if @select
+ # Any ordering columns must be selected when doing select,
+ # otherwise it is an SQL error, so filter out invaliding orderings.
+ @orders.select! { |o|
+ # match select column against order array entry
+ @select.select { |s| /^#{table_name}.#{s}( (asc|desc))?$/.match o }.any?
+ }
+ end
+
+ @distinct = true if (params[:distinct] == true || params[:distinct] == "true")
+ @distinct = false if (params[:distinct] == false || params[:distinct] == "false")