searchlogic 1.6.6 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/CHANGELOG.rdoc +17 -0
- data/{MIT-LICENSE → LICENSE} +2 -2
- data/README.rdoc +128 -379
- data/Rakefile +56 -20
- data/VERSION.yml +4 -0
- data/init.rb +1 -1
- data/lib/searchlogic.rb +18 -98
- data/lib/searchlogic/core_ext/object.rb +33 -13
- data/lib/searchlogic/core_ext/proc.rb +11 -0
- data/lib/searchlogic/named_scopes/alias_scope.rb +63 -0
- data/lib/searchlogic/named_scopes/associations.rb +126 -0
- data/lib/searchlogic/named_scopes/conditions.rb +215 -0
- data/lib/searchlogic/named_scopes/ordering.rb +53 -0
- data/lib/searchlogic/rails_helpers.rb +69 -0
- data/lib/searchlogic/search.rb +146 -0
- data/rails/init.rb +1 -0
- data/searchlogic.gemspec +69 -0
- data/spec/core_ext/object_spec.rb +7 -0
- data/spec/core_ext/proc_spec.rb +9 -0
- data/spec/named_scopes/alias_scope_spec.rb +15 -0
- data/spec/named_scopes/associations_spec.rb +120 -0
- data/spec/named_scopes/conditions_spec.rb +253 -0
- data/spec/named_scopes/ordering_spec.rb +23 -0
- data/spec/search_spec.rb +283 -0
- data/spec/spec_helper.rb +78 -0
- metadata +40 -231
- data/Manifest.txt +0 -158
- data/TODO.rdoc +0 -4
- data/lib/searchlogic/active_record/associations.rb +0 -52
- data/lib/searchlogic/active_record/base.rb +0 -224
- data/lib/searchlogic/active_record/connection_adapters/mysql_adapter.rb +0 -176
- data/lib/searchlogic/active_record/connection_adapters/postgresql_adapter.rb +0 -172
- data/lib/searchlogic/active_record/connection_adapters/sqlite_adapter.rb +0 -80
- data/lib/searchlogic/condition/base.rb +0 -165
- data/lib/searchlogic/condition/begins_with.rb +0 -17
- data/lib/searchlogic/condition/blank.rb +0 -24
- data/lib/searchlogic/condition/child_of.rb +0 -11
- data/lib/searchlogic/condition/descendant_of.rb +0 -11
- data/lib/searchlogic/condition/ends_with.rb +0 -17
- data/lib/searchlogic/condition/equals.rb +0 -33
- data/lib/searchlogic/condition/greater_than.rb +0 -15
- data/lib/searchlogic/condition/greater_than_or_equal_to.rb +0 -15
- data/lib/searchlogic/condition/inclusive_descendant_of.rb +0 -10
- data/lib/searchlogic/condition/keywords.rb +0 -52
- data/lib/searchlogic/condition/less_than.rb +0 -15
- data/lib/searchlogic/condition/less_than_or_equal_to.rb +0 -15
- data/lib/searchlogic/condition/like.rb +0 -15
- data/lib/searchlogic/condition/nested_set.rb +0 -17
- data/lib/searchlogic/condition/nil.rb +0 -21
- data/lib/searchlogic/condition/not_begin_with.rb +0 -20
- data/lib/searchlogic/condition/not_blank.rb +0 -19
- data/lib/searchlogic/condition/not_end_with.rb +0 -20
- data/lib/searchlogic/condition/not_equal.rb +0 -27
- data/lib/searchlogic/condition/not_have_keywords.rb +0 -20
- data/lib/searchlogic/condition/not_like.rb +0 -20
- data/lib/searchlogic/condition/not_nil.rb +0 -19
- data/lib/searchlogic/condition/sibling_of.rb +0 -14
- data/lib/searchlogic/conditions/any_or_all.rb +0 -42
- data/lib/searchlogic/conditions/base.rb +0 -244
- data/lib/searchlogic/conditions/groups.rb +0 -74
- data/lib/searchlogic/conditions/magic_methods.rb +0 -286
- data/lib/searchlogic/conditions/multiparameter_attributes.rb +0 -105
- data/lib/searchlogic/conditions/protection.rb +0 -36
- data/lib/searchlogic/config.rb +0 -31
- data/lib/searchlogic/config/helpers.rb +0 -338
- data/lib/searchlogic/config/search.rb +0 -53
- data/lib/searchlogic/core_ext/hash.rb +0 -75
- data/lib/searchlogic/helpers/control_types/link.rb +0 -310
- data/lib/searchlogic/helpers/control_types/links.rb +0 -242
- data/lib/searchlogic/helpers/control_types/remote_link.rb +0 -87
- data/lib/searchlogic/helpers/control_types/remote_links.rb +0 -72
- data/lib/searchlogic/helpers/control_types/remote_select.rb +0 -36
- data/lib/searchlogic/helpers/control_types/select.rb +0 -82
- data/lib/searchlogic/helpers/form.rb +0 -208
- data/lib/searchlogic/helpers/utilities.rb +0 -197
- data/lib/searchlogic/modifiers/absolute.rb +0 -15
- data/lib/searchlogic/modifiers/acos.rb +0 -11
- data/lib/searchlogic/modifiers/asin.rb +0 -11
- data/lib/searchlogic/modifiers/atan.rb +0 -11
- data/lib/searchlogic/modifiers/avg.rb +0 -15
- data/lib/searchlogic/modifiers/base.rb +0 -27
- data/lib/searchlogic/modifiers/ceil.rb +0 -15
- data/lib/searchlogic/modifiers/char_length.rb +0 -15
- data/lib/searchlogic/modifiers/cos.rb +0 -15
- data/lib/searchlogic/modifiers/cot.rb +0 -15
- data/lib/searchlogic/modifiers/count.rb +0 -11
- data/lib/searchlogic/modifiers/day_of_month.rb +0 -15
- data/lib/searchlogic/modifiers/day_of_week.rb +0 -15
- data/lib/searchlogic/modifiers/day_of_year.rb +0 -15
- data/lib/searchlogic/modifiers/degrees.rb +0 -11
- data/lib/searchlogic/modifiers/exp.rb +0 -15
- data/lib/searchlogic/modifiers/floor.rb +0 -15
- data/lib/searchlogic/modifiers/hex.rb +0 -11
- data/lib/searchlogic/modifiers/hour.rb +0 -11
- data/lib/searchlogic/modifiers/log.rb +0 -15
- data/lib/searchlogic/modifiers/log10.rb +0 -11
- data/lib/searchlogic/modifiers/log2.rb +0 -11
- data/lib/searchlogic/modifiers/lower.rb +0 -15
- data/lib/searchlogic/modifiers/ltrim.rb +0 -15
- data/lib/searchlogic/modifiers/md5.rb +0 -11
- data/lib/searchlogic/modifiers/microseconds.rb +0 -11
- data/lib/searchlogic/modifiers/milliseconds.rb +0 -11
- data/lib/searchlogic/modifiers/minute.rb +0 -15
- data/lib/searchlogic/modifiers/month.rb +0 -15
- data/lib/searchlogic/modifiers/octal.rb +0 -15
- data/lib/searchlogic/modifiers/radians.rb +0 -11
- data/lib/searchlogic/modifiers/round.rb +0 -11
- data/lib/searchlogic/modifiers/rtrim.rb +0 -15
- data/lib/searchlogic/modifiers/second.rb +0 -15
- data/lib/searchlogic/modifiers/sign.rb +0 -11
- data/lib/searchlogic/modifiers/sin.rb +0 -11
- data/lib/searchlogic/modifiers/square_root.rb +0 -15
- data/lib/searchlogic/modifiers/sum.rb +0 -11
- data/lib/searchlogic/modifiers/tan.rb +0 -15
- data/lib/searchlogic/modifiers/trim.rb +0 -15
- data/lib/searchlogic/modifiers/upper.rb +0 -15
- data/lib/searchlogic/modifiers/week.rb +0 -11
- data/lib/searchlogic/modifiers/year.rb +0 -11
- data/lib/searchlogic/search/base.rb +0 -148
- data/lib/searchlogic/search/conditions.rb +0 -53
- data/lib/searchlogic/search/ordering.rb +0 -244
- data/lib/searchlogic/search/pagination.rb +0 -121
- data/lib/searchlogic/search/protection.rb +0 -89
- data/lib/searchlogic/search/searching.rb +0 -32
- data/lib/searchlogic/shared/utilities.rb +0 -57
- data/lib/searchlogic/shared/virtual_classes.rb +0 -39
- data/lib/searchlogic/version.rb +0 -79
- data/test/active_record_tests/associations_test.rb +0 -94
- data/test/active_record_tests/base_test.rb +0 -115
- data/test/condition_tests/base_test.rb +0 -62
- data/test/condition_tests/begins_with_test.rb +0 -11
- data/test/condition_tests/blank_test.rb +0 -31
- data/test/condition_tests/child_of_test.rb +0 -17
- data/test/condition_tests/descendant_of_test.rb +0 -12
- data/test/condition_tests/ends_with_test.rb +0 -11
- data/test/condition_tests/equals_test.rb +0 -28
- data/test/condition_tests/greater_than_or_equal_to_test.rb +0 -11
- data/test/condition_tests/greater_than_test.rb +0 -11
- data/test/condition_tests/inclusive_descendant_of_test.rb +0 -12
- data/test/condition_tests/keywords_test.rb +0 -23
- data/test/condition_tests/less_than_or_equal_to_test.rb +0 -11
- data/test/condition_tests/less_than_test.rb +0 -11
- data/test/condition_tests/like_test.rb +0 -11
- data/test/condition_tests/nil_test.rb +0 -31
- data/test/condition_tests/not_begin_with_test.rb +0 -8
- data/test/condition_tests/not_blank_test.rb +0 -8
- data/test/condition_tests/not_end_with_test.rb +0 -8
- data/test/condition_tests/not_equal_test.rb +0 -19
- data/test/condition_tests/not_have_keywords_test.rb +0 -8
- data/test/condition_tests/not_like_test.rb +0 -8
- data/test/condition_tests/not_nil_test.rb +0 -13
- data/test/condition_tests/sibling_of_test.rb +0 -15
- data/test/conditions_tests/any_or_all_test.rb +0 -23
- data/test/conditions_tests/base_test.rb +0 -185
- data/test/conditions_tests/groups_test.rb +0 -68
- data/test/conditions_tests/magic_methods_test.rb +0 -36
- data/test/conditions_tests/multiparameter_attributes_test.rb +0 -15
- data/test/conditions_tests/protection_test.rb +0 -18
- data/test/config_test.rb +0 -23
- data/test/fixtures/accounts.yml +0 -12
- data/test/fixtures/animals.yml +0 -7
- data/test/fixtures/orders.yml +0 -12
- data/test/fixtures/user_groups.yml +0 -5
- data/test/fixtures/users.yml +0 -45
- data/test/libs/awesome_nested_set.rb +0 -545
- data/test/libs/awesome_nested_set/.autotest +0 -13
- data/test/libs/awesome_nested_set/compatability.rb +0 -29
- data/test/libs/awesome_nested_set/helper.rb +0 -40
- data/test/libs/awesome_nested_set/named_scope.rb +0 -140
- data/test/libs/rexml_fix.rb +0 -14
- data/test/modifier_tests/day_of_month_test.rb +0 -16
- data/test/search_tests/base_test.rb +0 -241
- data/test/search_tests/conditions_test.rb +0 -21
- data/test/search_tests/ordering_test.rb +0 -167
- data/test/search_tests/pagination_test.rb +0 -74
- data/test/search_tests/protection_test.rb +0 -26
- data/test/test_helper.rb +0 -122
@@ -1,11 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class ChildOf < NestedSet
|
4
|
-
def to_conditions(value)
|
5
|
-
parent_association = klass.reflect_on_association(:parent)
|
6
|
-
foreign_key_name = (parent_association && parent_association.options[:foreign_key]) || "parent_id"
|
7
|
-
["#{quoted_table_name}.#{quote_column_name(foreign_key_name)} = ?", (value.is_a?(klass) ? value.send(klass.primary_key) : value)]
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class DescendantOf < NestedSet
|
4
|
-
def to_conditions(value)
|
5
|
-
condition = InclusiveDescendantOf.new(klass, options)
|
6
|
-
condition.value = value
|
7
|
-
scope_condition(merge_conditions(["#{quoted_table_name}.#{quote_column_name(klass.primary_key)} != ?", (value.is_a?(klass) ? value.send(klass.primary_key) : value)], condition.sanitize))
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class EndsWith < Base
|
4
|
-
self.join_arrays_with_or = true
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def condition_names_for_column
|
8
|
-
super + ["ew", "ends", "end"]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_conditions(value)
|
13
|
-
["#{column_sql} LIKE ?", "%#{value}"]
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class Equals < Base
|
4
|
-
self.handle_array_value = true
|
5
|
-
self.ignore_meaningless_value = false
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def condition_names_for_column
|
9
|
-
super + ["", "is"]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_conditions(value)
|
14
|
-
return value if value.is_a?(Array) && value.empty?
|
15
|
-
|
16
|
-
# Let ActiveRecord handle this
|
17
|
-
args = []
|
18
|
-
case value
|
19
|
-
when Range
|
20
|
-
args = [value.first, value.last]
|
21
|
-
else
|
22
|
-
args << value
|
23
|
-
end
|
24
|
-
|
25
|
-
begin
|
26
|
-
return [klass.send(:attribute_condition, column_sql, value), *args]
|
27
|
-
rescue ArgumentError
|
28
|
-
return ["#{column_sql} #{klass.send(:attribute_condition, value)}", *args] # for older versions of AR
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class GreaterThanOrEqualTo < Base
|
4
|
-
class << self
|
5
|
-
def condition_names_for_column
|
6
|
-
super + ["gte", "at_least", "least"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_conditions(value)
|
11
|
-
["#{column_sql} >= ?", value]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class InclusiveDescendantOf < NestedSet
|
4
|
-
def to_conditions(value)
|
5
|
-
root = (value.is_a?(klass) ? value : klass.find(value)) rescue return
|
6
|
-
["(#{quoted_table_name}.#{quote_column_name(klass.left_column_name)} >= ? AND #{quoted_table_name}.#{quote_column_name(klass.right_column_name)} <= ?)", root.left, root.right]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
module Searchlogic
|
3
|
-
module Condition
|
4
|
-
class Keywords < Base
|
5
|
-
class << self
|
6
|
-
def condition_names_for_column
|
7
|
-
super + ["kwords", "kw"]
|
8
|
-
end
|
9
|
-
|
10
|
-
attr_accessor :blacklisted_words, :allowed_characters
|
11
|
-
end
|
12
|
-
|
13
|
-
# Because be default it joins with AND, so padding an array just gives you more options. Joining with and is no different than combining all of the words.
|
14
|
-
self.join_arrays_with_or = true
|
15
|
-
|
16
|
-
self.blacklisted_words ||= []
|
17
|
-
self.blacklisted_words << ('a'..'z').to_a + ["about", "an", "are", "as", "at", "be", "by", "com", "de", "en", "for", "from", "how", "in", "is", "it", "la", "of", "on", "or", "that", "the", "the", "this", "to", "und", "was", "what", "when", "where", "who", "will", "with", "www"] # from ranks.nl
|
18
|
-
self.allowed_characters ||= ""
|
19
|
-
self.allowed_characters += 'àáâãäåßéèêëìíîïñòóôõöùúûüýÿ\-_\.@'
|
20
|
-
|
21
|
-
def to_conditions(value)
|
22
|
-
strs = []
|
23
|
-
subs = []
|
24
|
-
|
25
|
-
search_parts = value.to_s.gsub(/,/, " ").split(/ /)
|
26
|
-
replace_non_alnum_characters!(search_parts)
|
27
|
-
search_parts.uniq!
|
28
|
-
remove_blacklisted_words!(search_parts)
|
29
|
-
return if search_parts.blank?
|
30
|
-
|
31
|
-
search_parts.each do |search_part|
|
32
|
-
strs << "#{column_sql} #{like_condition_name} ?"
|
33
|
-
subs << "%#{search_part}%"
|
34
|
-
end
|
35
|
-
|
36
|
-
[strs.join(" AND "), *subs]
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
def replace_non_alnum_characters!(search_parts)
|
41
|
-
search_parts.each do |word|
|
42
|
-
word.downcase!
|
43
|
-
word.gsub!(/[^[:alnum:]#{self.class.allowed_characters}]/, '')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def remove_blacklisted_words!(search_parts)
|
48
|
-
search_parts.delete_if { |word| word.blank? || self.class.blacklisted_words.include?(word.downcase) }
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class LessThanOrEqualTo < Base
|
4
|
-
class << self
|
5
|
-
def condition_names_for_column
|
6
|
-
super + ["lte", "at_most", "most"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_conditions(value)
|
11
|
-
["#{column_sql} <= ?", value]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class Like < Base
|
4
|
-
class << self
|
5
|
-
def condition_names_for_column
|
6
|
-
super + ["contains", "has"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_conditions(value)
|
11
|
-
["#{column_sql} #{like_condition_name} ?", "%#{value}%"]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NestedSet < Base # :nodoc:
|
4
|
-
self.join_arrays_with_or = true
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def condition_names_for_column
|
8
|
-
[]
|
9
|
-
end
|
10
|
-
|
11
|
-
def condition_names_for_model
|
12
|
-
[condition_type_name]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class Nil < Base
|
4
|
-
self.value_type = :boolean
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def condition_names_for_column
|
8
|
-
super + ["is_nil", "is_null", "null"]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_conditions(value)
|
13
|
-
if value == true
|
14
|
-
"#{column_sql} IS NULL"
|
15
|
-
elsif value == false
|
16
|
-
"#{column_sql} IS NOT NULL"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NotBeginWith < Base
|
4
|
-
class << self
|
5
|
-
def condition_names_for_column
|
6
|
-
super + ["not_bw", "not_sw", "not_start_with", "not_start", "beginning_is_not", "beginning_not"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_conditions(value)
|
11
|
-
begin_with = BeginsWith.new(klass, options)
|
12
|
-
begin_with.value = value
|
13
|
-
conditions = being_with.sanitize
|
14
|
-
return conditions if conditions.blank?
|
15
|
-
conditions.first.gsub!(" LIKE ", " NOT LIKE ")
|
16
|
-
conditions
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NotBlank < Base
|
4
|
-
self.value_type = :boolean
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def condition_names_for_column
|
8
|
-
super + ["is_not_blank"]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_conditions(value)
|
13
|
-
blank = Blank.new(klass, options)
|
14
|
-
blank.value = !value
|
15
|
-
blank.sanitize
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NotEndWith < Base
|
4
|
-
class << self
|
5
|
-
def condition_names_for_column
|
6
|
-
super + ["not_ew", "not_end", "end_is_not", "end_not"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_conditions(value)
|
11
|
-
ends_with = EndsWith.new(klass, options)
|
12
|
-
ends_with.value = value
|
13
|
-
conditions = ends_with.sanitize
|
14
|
-
return conditions if conditions.blank?
|
15
|
-
conditions.first.gsub!(" LIKE ", " NOT LIKE ")
|
16
|
-
conditions
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NotEqual < Base
|
4
|
-
self.handle_array_value = true
|
5
|
-
self.ignore_meaningless_value = false
|
6
|
-
|
7
|
-
class << self
|
8
|
-
def condition_names_for_column
|
9
|
-
super + ["does_not_equal", "not_equal", "is_not", "not", "ne"]
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_conditions(value)
|
14
|
-
# Delegate to equals and then change
|
15
|
-
condition = Equals.new(klass, options)
|
16
|
-
condition.value = value
|
17
|
-
conditions_array = condition.sanitize
|
18
|
-
return conditions_array if conditions_array.blank?
|
19
|
-
conditions_array.first.gsub!(/ IS /, " IS NOT ")
|
20
|
-
conditions_array.first.gsub!(/ BETWEEN /, " NOT BETWEEN ")
|
21
|
-
conditions_array.first.gsub!(/ IN /, " NOT IN ")
|
22
|
-
conditions_array.first.gsub!(/=/, "!=")
|
23
|
-
conditions_array
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NotHaveKeywords < Base
|
4
|
-
class << self
|
5
|
-
def condition_names_for_column
|
6
|
-
super + ["not_have_keywords", "not_keywords", "not_have_kw", "not_kw", "not_have_kwwords", "not_kwwords"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_conditions(value)
|
11
|
-
keywords = Keywords.new(klass, options)
|
12
|
-
keywords.value = value
|
13
|
-
conditions = keywords.sanitize
|
14
|
-
return conditions if conditions.blank?
|
15
|
-
conditions.first.gsub!(" #{like_condition_name} ", " NOT #{like_condition_name} ")
|
16
|
-
conditions
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NotLike < Base
|
4
|
-
class << self
|
5
|
-
def condition_names_for_column
|
6
|
-
super + ["not_contain", "not_have"]
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_conditions(value)
|
11
|
-
like = Like.new(klass, options)
|
12
|
-
like.value = value
|
13
|
-
conditions = like.sanitize
|
14
|
-
return conditions if conditions.blank?
|
15
|
-
conditions.first.gsub!(" #{like_condition_name} ", " NOT #{like_condition_name} ")
|
16
|
-
conditions
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class NotNil < Base
|
4
|
-
self.value_type = :boolean
|
5
|
-
|
6
|
-
class << self
|
7
|
-
def condition_names_for_column
|
8
|
-
super + ["is_not_nil", "is_not_null", "not_null"]
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def to_conditions(value)
|
13
|
-
is_nil = Nil.new(klass, options)
|
14
|
-
is_nil.value = !value
|
15
|
-
is_nil.sanitize
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Condition
|
3
|
-
class SiblingOf < NestedSet
|
4
|
-
def to_conditions(value)
|
5
|
-
parent_association = klass.reflect_on_association(:parent)
|
6
|
-
foreign_key_name = (parent_association && parent_association.options[:foreign_key]) || "parent_id"
|
7
|
-
parent_id = (value.is_a?(klass) ? value : klass.find(value)).send(foreign_key_name)
|
8
|
-
condition = ChildOf.new(klass, options)
|
9
|
-
condition.value = parent_id
|
10
|
-
merge_conditions(["#{quoted_table_name}.#{quote_column_name(klass.primary_key)} != ?", (value.is_a?(klass) ? value.send(klass.primary_key) : value)], condition.sanitize)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module Searchlogic
|
2
|
-
module Conditions
|
3
|
-
# = Any or All
|
4
|
-
#
|
5
|
-
# Adds the ability to join all conditions wth "AND" or "OR".
|
6
|
-
module AnyOrAll
|
7
|
-
# Determines if we should join the conditions with "AND" or "OR".
|
8
|
-
#
|
9
|
-
# === Examples
|
10
|
-
#
|
11
|
-
# search.conditions.any = true # will join all conditions with "or", you can also set this to "true", "1", or "yes"
|
12
|
-
# search.conditions.any = false # will join all conditions with "and"
|
13
|
-
def any=(value)
|
14
|
-
(association_objects + group_objects).each { |object| object.any = value }
|
15
|
-
@any = value
|
16
|
-
end
|
17
|
-
|
18
|
-
def any # :nodoc:
|
19
|
-
@any
|
20
|
-
end
|
21
|
-
|
22
|
-
# Convenience method for determining if we should join the conditions with "AND" or "OR".
|
23
|
-
def any?
|
24
|
-
["true", "1", "yes"].include? @any.to_s
|
25
|
-
end
|
26
|
-
|
27
|
-
# Sets the conditions to be searched by "or"
|
28
|
-
def any!
|
29
|
-
self.any = true
|
30
|
-
end
|
31
|
-
|
32
|
-
def all? # :nodoc:
|
33
|
-
!any?
|
34
|
-
end
|
35
|
-
|
36
|
-
# Sets the conditions to be searched by "and"
|
37
|
-
def all!
|
38
|
-
self.any = false
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|