Title: [702] trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb: -extractd unquote method, so (,',) can be stripped in type_cast
- Revision
- 702
- Author
- weijielin
- Date
- 2007-08-23 13:54:35 -0400 (Thu, 23 Aug 2007)
Log Message
-extractd unquote method, so (,',) can be stripped in type_cast
-fixed a binary type_cast problem
-fixed a string type_cast problem
Modified Paths
Diff
Modified: trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb (701 => 702)
--- trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb 2007-08-23 16:59:57 UTC (rev 701)
+++ trunk/activerecord-jdbc/lib/jdbc_adapter/jdbc_mssql.rb 2007-08-23 17:54:35 UTC (rev 702)
@@ -29,21 +29,24 @@
def type_cast(value)
return nil if value.nil? || value == "(NULL)"
case type
- when :string then value
- when :integer
- value.to_s =~ /^\(*(-?\d+)\)*$/
- $1.to_i rescue value ? 1 : 0
+ when :string then unquote value
+ when :integer then unquote(value).to_i rescue value ? 1 : 0
when :primary_key then value == true || value == false ? value == true ? 1 : 0 : value.to_i
when :decimal then self.class.value_to_decimal(value)
when :datetime then cast_to_datetime(value)
when :timestamp then cast_to_time(value)
when :time then cast_to_time(value)
when :date then cast_to_datetime(value)
- when :boolean then value == true or (value =~ /^t(rue)?$/i) == 0 or (value =~ /^\(*1\)*$/) == 0
+ when :boolean then value == true or (value =~ /^t(rue)?$/i) == 0 or unquote(value)=="1"
+ when :binary then unquote value
else value
end
end
-
+
+ def unquote(value)
+ value.to_s.sub(/^\([\(\']?/, "").sub(/[\'\)]?\)$/, "")
+ end
+
def cast_to_time(value)
return value if value.is_a?(Time)
time_array = ParseDate.parsedate(value)
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel