Sha256: 27cd5471f39f4a4819d48fe7e680dc7ddb49a64889aff521fb74250360b090a0

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 KB

Contents

module ActiveRecord
  module ConnectionAdapters
    module OracleEnhanced
      module JDBCQuoting
        def _type_cast(value)
          case value
          when ActiveModel::Type::Binary::Data
            blob = Java::OracleSql::BLOB.createTemporary(@connection.raw_connection, false, Java::OracleSql::BLOB::DURATION_SESSION)
            blob.setBytes(1, value.to_s.to_java_bytes)
            blob
          when ActiveRecord::OracleEnhanced::Type::Text::Data
            clob = Java::OracleSql::CLOB.createTemporary(@connection.raw_connection, false, Java::OracleSql::CLOB::DURATION_SESSION)
            clob.setString(1, value.to_s)
            clob
          when Date, DateTime
            Java::oracle.sql.DATE.new(value.strftime("%Y-%m-%d %H:%M:%S"))
          when Time
            Java::java.sql.Timestamp.new(value.year-1900, value.month-1, value.day, value.hour, value.min, value.sec, value.usec * 1000)
          when Java::JavaSql::Timestamp
            # Returning value as it is likely this value was already type casted from Time to Java::JavaSql::Timestamp
            value
          else
            super
          end
        end
      end
    end
  end
end

module ActiveRecord
  module ConnectionAdapters
    module OracleEnhanced
      module Quoting
        prepend JDBCQuoting
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-oracle_enhanced-adapter-1.7.11 lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb
activerecord-oracle_enhanced-adapter-1.7.10 lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb