Skip to content

Commit

Permalink
Handle pre-epoch date conversions. Important for TimeStamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jherdman committed Nov 12, 2008
1 parent 8414fc4 commit 01078e4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/active_record/connection_adapters/odbc_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1583,9 +1583,9 @@ def dbmsNameToSym(dbmsName, dbmsVer)
elsif dbmsName =~ /virtuoso/i
symbl = :virtuoso
elsif dbmsName =~ /SQLAnywhere/i or dbmsName =~ /adaptiveserveranywhere/i
symbl = :sqlanywhere
elsif dbmsName =~ /visualfoxpro/i
# Try to access Visual Fox Pro database as a PostgreSQL database, works for simple queries.
symbl = :sqlanywhere
elsif dbmsName =~ /visualfoxpro/i
# Try to access Visual Fox Pro database as a PostgreSQL database, works for simple queries.
symbl = :postgresql
else
raise ActiveRecord::ActiveRecordError, "ODBCAdapter: Unsupported database (#{dbmsName})"
Expand Down Expand Up @@ -1728,6 +1728,10 @@ def convertOdbcValToGenericVal(value)
res = Date.new(value.year, value.month, value.day)
end
res
rescue
# Handle pre-epoch dates
# TODO Write a test to show that this works beyond anecdotal evidence
DateTime.new(value.year, value.month, value.day, value.hour, value.minute, value.second)
end

# In general, ActiveRecord uses lowercase attribute names. This may
Expand Down

0 comments on commit 01078e4

Please sign in to comment.