searchgasm 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/lib/searchgasm/active_record/connection_adapters/mysql_adapter.rb +1 -1
- data/lib/searchgasm/condition/blank.rb +2 -2
- data/lib/searchgasm/condition/equals.rb +9 -1
- data/lib/searchgasm/condition/not_equal.rb +6 -6
- data/lib/searchgasm/helpers/utilities.rb +1 -1
- data/lib/searchgasm/shared/utilities.rb +1 -1
- data/lib/searchgasm/version.rb +1 -1
- data/searchgasm.gemspec +3 -3
- data/test/test_condition_types.rb +10 -10
- data/test/test_conditions_base.rb +3 -3
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 1.3.3 released 2008-10-03
|
2
|
+
|
3
|
+
* Fixed modifiers being double escaped on equals condition
|
4
|
+
* Fixed bug when merging conditions with array substitutions
|
5
|
+
* Updated blank condition to check if the values is false or not
|
6
|
+
* Fixed type for the year modifier in the mysql adapter
|
7
|
+
|
1
8
|
== 1.3.2 released 2008-10-03
|
2
9
|
|
3
10
|
* Fixed condition to type cast all values in an array
|
@@ -11,9 +11,9 @@ module Searchgasm
|
|
11
11
|
|
12
12
|
def to_conditions(value)
|
13
13
|
if value == true
|
14
|
-
"#{column_sql} is NULL or #{column_sql} = ''"
|
14
|
+
"#{column_sql} is NULL or #{column_sql} = '' or #{column_sql} = false"
|
15
15
|
elsif value == false
|
16
|
-
"#{column_sql} is NOT NULL and #{column_sql} != ''"
|
16
|
+
"#{column_sql} is NOT NULL and #{column_sql} != '' and #{column_sql} != false"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -12,7 +12,15 @@ module Searchgasm
|
|
12
12
|
|
13
13
|
def to_conditions(value)
|
14
14
|
# Let ActiveRecord handle this
|
15
|
-
|
15
|
+
args = []
|
16
|
+
case value
|
17
|
+
when Range
|
18
|
+
args = [value.first, value.last]
|
19
|
+
else
|
20
|
+
args << value
|
21
|
+
end
|
22
|
+
|
23
|
+
["#{column_sql} #{klass.send(:attribute_condition, value)}", *args]
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
@@ -15,12 +15,12 @@ module Searchgasm
|
|
15
15
|
condition = Equals.new(klass, column)
|
16
16
|
condition.value = value
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
conditions_array = condition.sanitize
|
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
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Searchgasm
|
2
2
|
module Helpers #:nodoc:
|
3
|
-
module Utilities
|
3
|
+
module Utilities
|
4
4
|
# Builds a hash of params for creating a url and preserves any existing params. You can pass this into url_for and build your url. Although most rails helpers accept a hash.
|
5
5
|
#
|
6
6
|
# Let's take the page_link helper. Here is the code behind that helper:
|
@@ -13,7 +13,7 @@ module Searchgasm
|
|
13
13
|
|
14
14
|
conditions.each do |condition|
|
15
15
|
next if condition.blank?
|
16
|
-
arr_condition = [condition]
|
16
|
+
arr_condition = condition.is_a?(Array) ? condition : [condition]
|
17
17
|
conditions_strs << arr_condition.first
|
18
18
|
conditions_subs += arr_condition[1..-1]
|
19
19
|
end
|
data/lib/searchgasm/version.rb
CHANGED
data/searchgasm.gemspec
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
|
2
|
-
# Gem::Specification for Searchgasm-1.3.
|
2
|
+
# Gem::Specification for Searchgasm-1.3.3
|
3
3
|
# Originally generated by Echoe
|
4
4
|
|
5
5
|
--- !ruby/object:Gem::Specification
|
6
6
|
name: searchgasm
|
7
7
|
version: !ruby/object:Gem::Version
|
8
|
-
version: 1.3.
|
8
|
+
version: 1.3.3
|
9
9
|
platform: ruby
|
10
10
|
authors:
|
11
11
|
- Ben Johnson of Binary Logic
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
|
15
|
-
date: 2008-10-
|
15
|
+
date: 2008-10-05 00:00:00 -04:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
@@ -8,19 +8,19 @@ class TestConditionTypes < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
condition = Searchgasm::Condition::Blank.new(Account, Account.columns_hash["id"])
|
10
10
|
condition.value = "true"
|
11
|
-
assert_equal "\"accounts\".\"id\" is NULL or \"accounts\".\"id\" = ''", condition.sanitize
|
11
|
+
assert_equal "\"accounts\".\"id\" is NULL or \"accounts\".\"id\" = '' or \"accounts\".\"id\" = false", condition.sanitize
|
12
12
|
|
13
13
|
condition = Searchgasm::Condition::Blank.new(Account, Account.columns_hash["id"])
|
14
14
|
condition.value = "false"
|
15
|
-
assert_equal "\"accounts\".\"id\" is NOT NULL and \"accounts\".\"id\" != ''", condition.sanitize
|
15
|
+
assert_equal "\"accounts\".\"id\" is NOT NULL and \"accounts\".\"id\" != '' and \"accounts\".\"id\" != false", condition.sanitize
|
16
16
|
|
17
17
|
condition = Searchgasm::Condition::Blank.new(Account, Account.columns_hash["id"])
|
18
18
|
condition.value = true
|
19
|
-
assert_equal "\"accounts\".\"id\" is NULL or \"accounts\".\"id\" = ''", condition.sanitize
|
19
|
+
assert_equal "\"accounts\".\"id\" is NULL or \"accounts\".\"id\" = '' or \"accounts\".\"id\" = false", condition.sanitize
|
20
20
|
|
21
21
|
condition = Searchgasm::Condition::Blank.new(Account, Account.columns_hash["id"])
|
22
22
|
condition.value = false
|
23
|
-
assert_equal "\"accounts\".\"id\" is NOT NULL and \"accounts\".\"id\" != ''", condition.sanitize
|
23
|
+
assert_equal "\"accounts\".\"id\" is NOT NULL and \"accounts\".\"id\" != '' and \"accounts\".\"id\" != false", condition.sanitize
|
24
24
|
|
25
25
|
condition = Searchgasm::Condition::Blank.new(Account, Account.columns_hash["id"])
|
26
26
|
condition.value = nil
|
@@ -48,15 +48,15 @@ class TestConditionTypes < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
condition = Searchgasm::Condition::Equals.new(Account, Account.columns_hash["id"])
|
50
50
|
condition.value = 12
|
51
|
-
assert_equal "\"accounts\".\"id\" =
|
51
|
+
assert_equal ["\"accounts\".\"id\" = ?", 12], condition.sanitize
|
52
52
|
|
53
53
|
condition = Searchgasm::Condition::Equals.new(Account, Account.columns_hash["id"])
|
54
54
|
condition.value = [1,2,3,4]
|
55
|
-
assert_equal "\"accounts\".\"id\" IN (1,2,3,4
|
55
|
+
assert_equal ["\"accounts\".\"id\" IN (?)", [1, 2, 3, 4]], condition.sanitize
|
56
56
|
|
57
57
|
condition = Searchgasm::Condition::Equals.new(Account, Account.columns_hash["id"])
|
58
58
|
condition.value = (1..10)
|
59
|
-
assert_equal "\"accounts\".\"id\" BETWEEN
|
59
|
+
assert_equal ["\"accounts\".\"id\" BETWEEN ? AND ?", 1, 10], condition.sanitize
|
60
60
|
|
61
61
|
condition = Searchgasm::Condition::GreaterThan.new(Account, Account.columns_hash["id"])
|
62
62
|
condition.value = 2
|
@@ -100,15 +100,15 @@ class TestConditionTypes < Test::Unit::TestCase
|
|
100
100
|
|
101
101
|
condition = Searchgasm::Condition::NotEqual.new(Account, Account.columns_hash["id"])
|
102
102
|
condition.value = 12
|
103
|
-
assert_equal "\"accounts\".\"id\" !=
|
103
|
+
assert_equal ["\"accounts\".\"id\" != ?", 12], condition.sanitize
|
104
104
|
|
105
105
|
condition = Searchgasm::Condition::NotEqual.new(Account, Account.columns_hash["id"])
|
106
106
|
condition.value = [1,2,3,4]
|
107
|
-
assert_equal "\"accounts\".\"id\" NOT IN (1,2,3,4
|
107
|
+
assert_equal ["\"accounts\".\"id\" NOT IN (?)", [1, 2, 3, 4]], condition.sanitize
|
108
108
|
|
109
109
|
condition = Searchgasm::Condition::NotEqual.new(Account, Account.columns_hash["id"])
|
110
110
|
condition.value = (1..10)
|
111
|
-
assert_equal "\"accounts\".\"id\" NOT BETWEEN
|
111
|
+
assert_equal ["\"accounts\".\"id\" NOT BETWEEN ? AND ?", 1, 10], condition.sanitize
|
112
112
|
|
113
113
|
condition = Searchgasm::Condition::Keywords.new(Account, Account.columns_hash["name"])
|
114
114
|
condition.value = "freedom yeah, freedom YEAH right"
|
@@ -44,11 +44,11 @@ class TestConditionsBase < Test::Unit::TestCase
|
|
44
44
|
conditions.name_contains = "Binary"
|
45
45
|
assert_equal ["\"accounts\".\"name\" LIKE ?", "%Binary%"], conditions.sanitize
|
46
46
|
conditions.id = 1
|
47
|
-
assert_equal ["(\"accounts\".\"id\" =
|
47
|
+
assert_equal ["(\"accounts\".\"id\" = ?) AND (\"accounts\".\"name\" LIKE ?)", 1, "%Binary%"], conditions.sanitize
|
48
48
|
conditions.any = true
|
49
|
-
assert_equal ["(\"accounts\".\"id\" =
|
49
|
+
assert_equal ["(\"accounts\".\"id\" = ?) OR (\"accounts\".\"name\" LIKE ?)", 1, "%Binary%"], conditions.sanitize
|
50
50
|
conditions.any = false
|
51
|
-
assert_equal ["(\"accounts\".\"id\" =
|
51
|
+
assert_equal ["(\"accounts\".\"id\" = ?) AND (\"accounts\".\"name\" LIKE ?)", 1, "%Binary%"], conditions.sanitize
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_auto_joins
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: searchgasm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Johnson of Binary Logic
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-05 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|