/usr/lib/ruby/vendor_ruby/sequel/adapters/jdbc/sqlanywhere.rb is in ruby-sequel 4.15.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | Sequel.require 'adapters/shared/sqlanywhere'
Sequel.require 'adapters/jdbc/transactions'
module Sequel
module JDBC
drv = [
lambda{Java::sybase.jdbc4.sqlanywhere.IDriver},
lambda{Java::ianywhere.ml.jdbcodbc.jdbc4.IDriver},
lambda{Java::sybase.jdbc.sqlanywhere.IDriver},
lambda{Java::ianywhere.ml.jdbcodbc.jdbc.IDriver},
lambda{Java::com.sybase.jdbc4.jdbc.Sybdriver},
lambda{Java::com.sybase.jdbc3.jdbc.Sybdriver}
].each do |class_proc|
begin
break class_proc.call
rescue NameError
end
end
raise(Sequel::AdapterNotFound, "no suitable SQLAnywhere JDBC driver found") unless drv
Sequel.synchronize do
DATABASE_SETUP[:sqlanywhere] = proc do |db|
db.extend(Sequel::JDBC::SqlAnywhere::DatabaseMethods)
db.dataset_class = Sequel::JDBC::SqlAnywhere::Dataset
drv
end
end
class TypeConvertor
def SqlAnywhereBoolean(r, i)
if v = Short(r, i)
v != 0
end
end
end
module SqlAnywhere
# Database instance methods for Sybase databases accessed via JDBC.
module DatabaseMethods
extend Sequel::Database::ResetIdentifierMangling
include Sequel::SqlAnywhere::DatabaseMethods
include Sequel::JDBC::Transactions
LAST_INSERT_ID = 'SELECT @@IDENTITY'.freeze
private
# Get the last inserted id.
def last_insert_id(conn, opts=OPTS)
statement(conn) do |stmt|
sql = LAST_INSERT_ID
rs = log_yield(sql){stmt.executeQuery(sql)}
rs.next
rs.getInt(1)
end
end
def setup_type_convertor_map
super
@type_convertor_map[:SqlAnywhereBoolean] = TypeConvertor::INSTANCE.method(:SqlAnywhereBoolean)
end
end
#Dataset class for Sybase datasets accessed via JDBC.
class Dataset < JDBC::Dataset
include Sequel::SqlAnywhere::DatasetMethods
private
SMALLINT_TYPE = Java::JavaSQL::Types::SMALLINT
def type_convertor(map, meta, type, i)
if convert_smallint_to_bool && type == SMALLINT_TYPE
map[:SqlAnywhereBoolean]
else
super
end
end
end
end
end
end
|