Module: Sequel::ADO::Access::DatabaseMethods
- Extended by:
- Database::ResetIdentifierMangling
- Defined in:
- lib/sequel/adapters/ado/access.rb
Constant Summary collapse
- DECIMAL_TYPE_RE =
/decimal/io
- LAST_INSERT_ID =
"SELECT @@IDENTITY".freeze
Instance Method Summary collapse
-
#alter_table(name) ⇒ Object
Remove cached schema after altering a table, since otherwise it can be cached incorrectly in the rename column case.
-
#disconnect_connection(conn) ⇒ Object
Access doesn’t let you disconnect if inside a transaction, so try rolling back an existing transaction first.
- #execute_insert(sql, opts = OPTS) ⇒ Object
-
#foreign_key_list(table, opts = OPTS) ⇒ Object
Note OpenSchema returns compound foreign key relationships as multiple rows.
-
#indexes(table_name, opts = OPTS) ⇒ Object
Note OpenSchema returns compound indexes as multiple rows.
- #tables(opts = OPTS) ⇒ Object
- #views(opts = OPTS) ⇒ Object
Methods included from Database::ResetIdentifierMangling
Methods included from Sequel::Access::DatabaseMethods
#database_type, #rename_table, #serial_primary_key_options
Instance Method Details
#alter_table(name) ⇒ Object
Remove cached schema after altering a table, since otherwise it can be cached incorrectly in the rename column case.
98 99 100 101 102 |
# File 'lib/sequel/adapters/ado/access.rb', line 98 def alter_table(name, *) super remove_cached_schema(name) nil end |
#disconnect_connection(conn) ⇒ Object
Access doesn’t let you disconnect if inside a transaction, so try rolling back an existing transaction first.
106 107 108 109 |
# File 'lib/sequel/adapters/ado/access.rb', line 106 def disconnect_connection(conn) conn.RollbackTrans rescue nil super end |
#execute_insert(sql, opts = OPTS) ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/sequel/adapters/ado/access.rb', line 111 def execute_insert(sql, opts=OPTS) synchronize(opts[:server]) do |conn| begin log_connection_yield(sql, conn){conn.Execute(sql)} res = log_connection_yield(LAST_INSERT_ID, conn){conn.Execute(LAST_INSERT_ID)} res.getRows.transpose.each{|r| return r.shift} rescue ::WIN32OLERuntimeError => e raise_error(e) end end nil end |
#foreign_key_list(table, opts = OPTS) ⇒ Object
Note OpenSchema returns compound foreign key relationships as multiple rows
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/sequel/adapters/ado/access.rb', line 150 def foreign_key_list(table, opts=OPTS) m = output_identifier_meth fks = ado_schema_foreign_keys(table).inject({}) do |memo, fk| name = m.call(fk['FK_NAME']) specs = memo[name] ||= { :columns => [], :table => m.call(fk['PK_TABLE_NAME']), :key => [], :deferrable => fk['DEFERRABILITY'], :name => name, :on_delete => fk['DELETE_RULE'], :on_update => fk['UPDATE_RULE'] } specs[:columns] << m.call(fk['FK_COLUMN_NAME']) specs[:key] << m.call(fk['PK_COLUMN_NAME']) memo end fks.values end |
#indexes(table_name, opts = OPTS) ⇒ Object
Note OpenSchema returns compound indexes as multiple rows
135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/sequel/adapters/ado/access.rb', line 135 def indexes(table_name,opts=OPTS) m = output_identifier_meth idxs = ado_schema_indexes(table_name).inject({}) do |memo, idx| unless idx["PRIMARY_KEY"] index = memo[m.call(idx["INDEX_NAME"])] ||= { :columns=>[], :unique=>idx["UNIQUE"] } index[:columns] << m.call(idx["COLUMN_NAME"]) end memo end idxs end |
#tables(opts = OPTS) ⇒ Object
124 125 126 127 |
# File 'lib/sequel/adapters/ado/access.rb', line 124 def tables(opts=OPTS) m = output_identifier_meth ado_schema_tables.map {|tbl| m.call(tbl['TABLE_NAME'])} end |
#views(opts = OPTS) ⇒ Object
129 130 131 132 |
# File 'lib/sequel/adapters/ado/access.rb', line 129 def views(opts=OPTS) m = output_identifier_meth ado_schema_views.map {|tbl| m.call(tbl['TABLE_NAME'])} end |