Remove cached schema after altering a table, since otherwise it can be cached incorrectly in the rename column case.
# File lib/sequel/adapters/ado/access.rb, line 100 def alter_table(name, *) super remove_cached_schema(name) nil end
Access doesn’t let you disconnect if inside a transaction, so try rolling back an existing transaction first.
# File lib/sequel/adapters/ado/access.rb, line 108 def disconnect_connection(conn) conn.RollbackTrans rescue nil super end
# File lib/sequel/adapters/ado/access.rb, line 113 def execute_insert(sql, opts=OPTS) synchronize(opts[:server]) do |conn| begin log_connection_yield(sql, conn){conn.Execute(sql)} last_insert_sql = "SELECT @@IDENTITY" res = log_connection_yield(last_insert_sql, conn){conn.Execute(last_insert_sql)} res.getRows.transpose.each{|r| return r.shift} rescue ::WIN32OLERuntimeError => e raise_error(e) end end nil end
Note OpenSchema returns compound foreign key relationships as multiple rows
# File lib/sequel/adapters/ado/access.rb, line 153 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
Note OpenSchema returns compound indexes as multiple rows
# File lib/sequel/adapters/ado/access.rb, line 138 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
# File lib/sequel/adapters/ado/access.rb, line 127 def tables(opts=OPTS) m = output_identifier_meth ado_schema_tables.map {|tbl| m.call(tbl['TABLE_NAME'])} end
# File lib/sequel/adapters/ado/access.rb, line 132 def views(opts=OPTS) m = output_identifier_meth ado_schema_views.map {|tbl| m.call(tbl['TABLE_NAME'])} end