case_insensitive_arel 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{case_insensitive_arel}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Steve Lamotte"]
12
- s.date = %q{2011-03-19}
12
+ s.date = %q{2011-05-18}
13
13
  s.description = %q{If you're using Oracle or another DBMS that has case-insensitive collation sequences, and you don't want to litter your database access code with case conversions, this gem is for you.}
14
14
  s.email = %q{steve@lexor.ca}
15
15
  s.extra_rdoc_files = [
@@ -6,11 +6,11 @@ module Arel #:nodoc:
6
6
  class ToSql
7
7
  # List of Arel types that should be converted to make them comparable in a case-insensitive fashion
8
8
  %w(Arel_Attributes_Attribute Arel_Attributes_String String).each do |arel_type_name|
9
- define_method "visit_#{arel_type_name}_with_case_insensitive" do |o|
10
- value = send("visit_#{arel_type_name}_without_case_insensitive", o)
9
+ define_method "visit_#{arel_type_name}_with_case_insensitive" do |obj|
10
+ value = send("visit_#{arel_type_name}_without_case_insensitive", obj)
11
11
 
12
- # If the object has been tagged with
13
- o.respond_to?(:do_not_make_case_insensitive?) ? value : Arel::CaseInsensitive.convert_value(value)
12
+ # Return either the original case-sensitive value or a converted version
13
+ Arel::CaseInsensitive.leave_case_sensitive?(obj) ? value : Arel::CaseInsensitive.convert_value(value)
14
14
  end
15
15
  alias_method_chain "visit_#{arel_type_name}", :case_insensitive
16
16
  end
@@ -27,6 +27,14 @@ module Arel #:nodoc:
27
27
  # Arel::CaseInsensitive.conversion_proc = Proc.new { |val| "UPPER(#{val})" }
28
28
  cattr_accessor :conversion_proc
29
29
 
30
+ protected
31
+
32
+ # Determines whether an object should be converted to case-insensitive form or not
33
+ def self.leave_case_sensitive?(obj)
34
+ obj.respond_to?(:do_not_make_case_insensitive?) ||
35
+ false#(obj.respond_to?(:name) && obj.name.eql?('*'))
36
+ end
37
+
30
38
  private
31
39
 
32
40
  # Return the converted value or the value itself depending on the current state of +case_insensitive+
@@ -5,6 +5,7 @@ class TestProjects < Test::Unit::TestCase
5
5
  Arel::CaseInsensitive.case_insensitive = true
6
6
  should_be_like @users.project(Arel.sql('*')).to_sql, "SELECT * FROM \"users\""
7
7
  should_be_like @users.project('*').to_sql, "SELECT * FROM \"users\""
8
+ should_be_like @users.project('"users".*').to_sql, "SELECT \"users\".* FROM \"users\""
8
9
  should_be_like @users.project(@users[:name]).to_sql, "SELECT \"users\".\"name\" FROM \"users\""
9
10
  should_be_like @users.project(@users[:name]).where(@users[:name].eq(@users[:name])).to_sql, "SELECT \"users\".\"name\" FROM \"users\" WHERE UPPER(\"users\".\"name\") = UPPER(\"users\".\"name\")"
10
11
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: case_insensitive_arel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steve Lamotte
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-19 00:00:00 -05:00
18
+ date: 2011-05-18 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency