lib/sequel/adapters/cubrid.rb in sequel-4.45.0 vs lib/sequel/adapters/cubrid.rb in sequel-4.46.0

- old
+ new

@@ -9,17 +9,19 @@ module Cubrid CUBRID_TYPE_PROCS = { ::Cubrid::DATE => lambda{|t| Date.new(t.year, t.month, t.day)}, ::Cubrid::TIME => lambda{|t| SQLTime.create(t.hour, t.min, t.sec)}, 21 => lambda(&:to_i) - } + }#.freeze # SEQUEL5 class Database < Sequel::Database include Sequel::Cubrid::DatabaseMethods ROW_COUNT = "SELECT ROW_COUNT()".freeze + Sequel::Deprecation.deprecate_constant(self, :ROW_COUNT) LAST_INSERT_ID = "SELECT LAST_INSERT_ID()".freeze + Sequel::Deprecation.deprecate_constant(self, :LAST_INSERT_ID) set_adapter_scheme :cubrid def connect(server) opts = server_opts(server) @@ -57,18 +59,18 @@ # giving StandardError: ERROR: CCI, -18, Invalid request handle #r.affected_rows # Work around bugs by using the ROW_COUNT function. begin - r2 = conn.query(ROW_COUNT) + r2 = conn.query("SELECT ROW_COUNT()") r2.each{|a| return a.first.to_i} ensure r2.close if r2 end when :insert begin - r2 = conn.query(LAST_INSERT_ID) + r2 = conn.query("SELECT LAST_INSERT_ID()") r2.each{|a| return a.first.to_i} ensure r2.close if r2 end end @@ -97,17 +99,21 @@ end private def begin_transaction(conn, opts=OPTS) - log_connection_yield(TRANSACTION_BEGIN, conn){conn.auto_commit = false} + log_connection_yield("Transaction.begin", conn){conn.auto_commit = false} end def commit_transaction(conn, opts=OPTS) - log_connection_yield(TRANSACTION_COMMIT, conn){conn.commit} + log_connection_yield('Transaction.commit', conn){conn.commit} end + def dataset_class_default + Dataset + end + def database_error_classes [StandardError] end def remove_transaction(conn, committed) @@ -117,24 +123,27 @@ end # This doesn't actually work, as the cubrid ruby driver # does not implement transactions correctly. def rollback_transaction(conn, opts=OPTS) - log_connection_yield(TRANSACTION_ROLLBACK, conn){conn.rollback} + log_connection_yield('Transaction.rollback', conn){conn.rollback} end end class Dataset < Sequel::Dataset include Sequel::Cubrid::DatasetMethods COLUMN_INFO_NAME = "name".freeze + Sequel::Deprecation.deprecate_constant(self, :COLUMN_INFO_NAME) COLUMN_INFO_TYPE = "type_name".freeze + Sequel::Deprecation.deprecate_constant(self, :COLUMN_INFO_TYPE) Database::DatasetClass = self + Sequel::Deprecation.deprecate_constant(Database, :DatasetClass) def fetch_rows(sql) execute(sql) do |stmt| begin - cols = stmt.column_info.map{|c| [output_identifier(c[COLUMN_INFO_NAME]), CUBRID_TYPE_PROCS[c[COLUMN_INFO_TYPE]]]} + cols = stmt.column_info.map{|c| [output_identifier(c["name"]), CUBRID_TYPE_PROCS[c["type_name"]]]} self.columns = cols.map(&:first) stmt.each do |r| row = {} cols.zip(r).each{|(k, p), v| row[k] = (v && p) ? p.call(v) : v} yield row