Class: ActiveRecord::ConnectionAdapters::IntersysAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::IntersysAdapter
- Defined in:
- lib/intersys_adapter.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #active? ⇒ Boolean
-
#adapter_name ⇒ Object
:nodoc:.
- #add_limit_offset!(sql, options) ⇒ Object
- #begin_db_transaction ⇒ Object
- #columns(table_name, name = nil) ⇒ Object
- #commit_db_transaction ⇒ Object
- #disconnect! ⇒ Object
-
#initialize(database, logger, config) ⇒ IntersysAdapter
constructor
A new instance of IntersysAdapter.
-
#insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) ⇒ Object
:nodoc:.
- #native_database_types ⇒ Object
- #reconnect! ⇒ Object
- #rollback_db_transaction ⇒ Object
-
#select_all(sql, name = nil) ⇒ Object
:nodoc:.
-
#select_one(sql, name = nil) ⇒ Object
:nodoc:.
-
#supports_migrations? ⇒ Boolean
:nodoc:.
-
#update(sql, name = nil) ⇒ Object
(also: #delete)
:nodoc:.
Constructor Details
#initialize(database, logger, config) ⇒ IntersysAdapter
Returns a new instance of IntersysAdapter.
21 22 23 24 |
# File 'lib/intersys_adapter.rb', line 21 def initialize(database, logger, config) super(database, logger) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'lib/intersys_adapter.rb', line 20 def config @config end |
Instance Method Details
#active? ⇒ Boolean
34 35 36 37 38 39 40 |
# File 'lib/intersys_adapter.rb', line 34 def active? warn "IntersysAdapter#active? not implemented" return true @connection.query "select 1" rescue Intersys::IntersysException false end |
#adapter_name ⇒ Object
:nodoc:
26 27 28 |
# File 'lib/intersys_adapter.rb', line 26 def adapter_name #:nodoc: 'Intersys Caché' end |
#add_limit_offset!(sql, options) ⇒ Object
61 62 63 64 |
# File 'lib/intersys_adapter.rb', line 61 def add_limit_offset!(sql, ) sql << " LIMIT #{limit}" if limit = [:limit] sql << " OFFSET #{offset}" if offset = [:offset] end |
#begin_db_transaction ⇒ Object
51 52 53 |
# File 'lib/intersys_adapter.rb', line 51 def begin_db_transaction @connection.start end |
#columns(table_name, name = nil) ⇒ Object
89 90 91 92 93 94 95 96 |
# File 'lib/intersys_adapter.rb', line 89 def columns(table_name, name = nil) @cdef = Intersys::Reflection::ClassDefinition.open("User.#{table_name.camelize}") result = [IntersysColumn.new("id", "", "int")] @cdef.properties.each do |prop| result << IntersysColumn.new(prop.sql_field_name, prop.initial_expression, prop.Type.gsub("%","").underscore, prop.required) end result end |
#commit_db_transaction ⇒ Object
54 55 56 |
# File 'lib/intersys_adapter.rb', line 54 def commit_db_transaction @connection.commit end |
#disconnect! ⇒ Object
42 43 44 |
# File 'lib/intersys_adapter.rb', line 42 def disconnect! @connection.close! rescue nil end |
#insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) ⇒ Object
:nodoc:
75 76 77 78 |
# File 'lib/intersys_adapter.rb', line 75 def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc: execute(sql, name = nil) id_value || @connection.insert_id end |
#native_database_types ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/intersys_adapter.rb', line 98 def native_database_types { :primary_key => 'int generated by default as identity (start with 42) primary key', :string => { :name => 'varchar', :limit => 255 }, :text => { :name => 'clob', :limit => 32768 }, :integer => { :name => 'int' }, :float => { :name => 'float' }, :datetime => { :name => 'timestamp' }, :timestamp => { :name => 'timestamp' }, :time => { :name => 'time' }, :date => { :name => 'date' }, :binary => { :name => 'blob', :limit => 32768 }, :boolean => { :name => 'decimal', :limit => 1 } } end |
#reconnect! ⇒ Object
46 47 48 49 |
# File 'lib/intersys_adapter.rb', line 46 def reconnect! disconnect! connect end |
#rollback_db_transaction ⇒ Object
57 58 59 |
# File 'lib/intersys_adapter.rb', line 57 def rollback_db_transaction @connection.rollback end |
#select_all(sql, name = nil) ⇒ Object
:nodoc:
66 67 68 |
# File 'lib/intersys_adapter.rb', line 66 def select_all(sql, name = nil) #:nodoc: select(sql, name) end |
#select_one(sql, name = nil) ⇒ Object
:nodoc:
70 71 72 73 |
# File 'lib/intersys_adapter.rb', line 70 def select_one(sql, name = nil) #:nodoc: result = select(sql, name) result.nil? ? nil : result.first end |
#supports_migrations? ⇒ Boolean
:nodoc:
30 31 32 |
# File 'lib/intersys_adapter.rb', line 30 def supports_migrations? #:nodoc: false end |
#update(sql, name = nil) ⇒ Object Also known as: delete
:nodoc:
80 81 82 83 |
# File 'lib/intersys_adapter.rb', line 80 def update(sql, name = nil) #:nodoc: execute(sql, name) @connection.affected_rows end |