Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added avg, count, and sum modifiers.

  • Loading branch information...
commit 92a6797a40f936dd4fcf940c4eb1f97a79aa3ebe 1 parent 52022c4
@binarylogic binarylogic authored
View
8 CHANGELOG.rdoc
@@ -1,3 +1,11 @@
+== 1.6.3 released 2008-12-13
+
+* Added in avg, count, and sum modifiers for SQLite and Postgres
+
+== 1.6.2 released 2008-12-13
+
+* Remove duplicate joins at a lower level for a cleaner and less brittle approach.
+
== 1.6.1 released 2008-12-8
* Group multi faceted conditions since we allow for the mix of "and" and "or"
View
2  lib/searchlogic/active_record/connection_adapters/mysql_adapter.rb
@@ -110,7 +110,7 @@ def cot_sql(column_name)
end
def count_sql(column_name)
- "COUNT(#{colun_name})"
+ "COUNT(#{column_name})"
end
def degrees_sql(column_name)
View
12 lib/searchlogic/active_record/connection_adapters/postgresql_adapter.rb
@@ -93,6 +93,10 @@ def atan_sql(column_name)
"atan(#{column_name})"
end
+ def avg_sql(column_name)
+ "AVG(#{column_name})"
+ end
+
def ceil_sql(column_name)
"ceil(#{column_name})"
end
@@ -105,6 +109,10 @@ def cot_sql(column_name)
"cot(#{column_name})"
end
+ def count_sql(column_name)
+ "COUNT(#{column_name})"
+ end
+
def degrees_sql(column_name)
"degrees(#{column_name})"
end
@@ -157,6 +165,10 @@ def square_root_sql(column_name)
"sqrt(#{column_name})"
end
+ def sum_sql(column_name)
+ "SUM(#{column_name})"
+ end
+
def tan_sql(column_name)
"tan(#{column_name})"
end
View
13 lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb
@@ -47,6 +47,19 @@ def year_sql(column_name)
"(strftime('%Y', #{column_name}) * 1)"
end
+ # Number functions
+ def avg_sql(column_name)
+ "AVG(#{column_name})"
+ end
+
+ def count_sql(column_name)
+ "COUNT(#{column_name})"
+ end
+
+ def sum_sql(column_name)
+ "SUM(#{column_name})"
+ end
+
# String functions
def lower_sql(column_name)
"lower(#{column_name})"
View
2  lib/searchlogic/config/helpers.rb
@@ -11,7 +11,7 @@ class Helpers
class << self
# Which hidden fields to automatically include when creating a form with a Searchlogic object. See Searchlogic::Helpers::Form for more info.
#
- # * <tt>Default:</tt> [:order_by, :order_as, :per_page]
+ # * <tt>Default:</tt> [:order_by, :order_as, :priority_order_by, :priority_order_as, :per_page]
# * <tt>Accepts:</tt> Array, nil, false
def hidden_fields
@hidden_fields ||= (Searchlogic::Search::Base::SPECIAL_FIND_OPTIONS - [:page, :priority_order])
View
1  lib/searchlogic/helpers/form.rb
@@ -121,7 +121,6 @@ def insert_searchlogic_fields(args, search_object, search_options, &block)
return unless search_object.is_a?(Search::Base)
name = args.first
options = args.extract_options!
- options
search_options[:hidden_fields].each do |field|
html = hidden_field(name, field, :object => search_object, :id => "#{name}_#{field}_#{options.object_id}", :value => (field == :order_by ? searchlogic_base64_value(search_object.order_by) : search_object.send(field)))
View
2  lib/searchlogic/version.rb
@@ -67,7 +67,7 @@ def to_a
MAJOR = 1
MINOR = 6
- TINY = 1
+ TINY = 2
# The current version as a Version instance
CURRENT = new(MAJOR, MINOR, TINY)
Please sign in to comment.
Something went wrong with that request. Please try again.