module Sequel::ADO::Access::DatabaseMethods

  1. lib/sequel/adapters/ado/access.rb

Public Instance methods

alter_table(name, *)

Remove cached schema after altering a table, since otherwise it can be cached incorrectly in the rename column case.

[show source]
   # File lib/sequel/adapters/ado/access.rb
95 def alter_table(name, *)
96   super
97   remove_cached_schema(name)
98   nil
99 end
disconnect_connection(conn)

Access doesn’t let you disconnect if inside a transaction, so try rolling back an existing transaction first.

[show source]
    # File lib/sequel/adapters/ado/access.rb
103 def disconnect_connection(conn)
104   conn.RollbackTrans rescue nil
105   super
106 end
execute_insert(sql, opts=OPTS)
[show source]
    # File lib/sequel/adapters/ado/access.rb
108 def execute_insert(sql, opts=OPTS)
109   synchronize(opts[:server]) do |conn|
110     begin
111       log_connection_yield(sql, conn){conn.Execute(sql)}
112       last_insert_sql = "SELECT @@IDENTITY"
113       res = log_connection_yield(last_insert_sql, conn){conn.Execute(last_insert_sql)}
114       res.GetRows.transpose.each{|r| return r.shift}
115     rescue ::WIN32OLERuntimeError => e
116       raise_error(e)
117     end
118   end
119   nil
120 end
foreign_key_list(table, opts=OPTS)

OpenSchema returns compound foreign key relationships as multiple rows

[show source]
    # File lib/sequel/adapters/ado/access.rb
148 def foreign_key_list(table, opts=OPTS)
149   m = output_identifier_meth
150   fks = ado_schema_foreign_keys(table).inject({}) do |memo, fk|
151     name = m.call(fk['FK_NAME'])
152     specs = memo[name] ||= {
153       :columns => [],
154       :table   => m.call(fk['PK_TABLE_NAME']),
155       :key     => [],
156       :deferrable => fk['DEFERRABILITY'],
157       :name    => name,
158       :on_delete => fk['DELETE_RULE'],
159       :on_update => fk['UPDATE_RULE']
160     }
161     specs[:columns] << m.call(fk['FK_COLUMN_NAME'])
162     specs[:key]     << m.call(fk['PK_COLUMN_NAME'])
163     memo
164   end
165   fks.values
166 end
indexes(table_name,opts=OPTS)

OpenSchema returns compound indexes as multiple rows

[show source]
    # File lib/sequel/adapters/ado/access.rb
133 def indexes(table_name,opts=OPTS)
134   m = output_identifier_meth
135   idxs = ado_schema_indexes(table_name).inject({}) do |memo, idx|
136     unless idx["PRIMARY_KEY"]
137       index = memo[m.call(idx["INDEX_NAME"])] ||= {
138         :columns=>[], :unique=>idx["UNIQUE"]
139       }
140       index[:columns] << m.call(idx["COLUMN_NAME"])
141     end
142     memo
143   end
144   idxs
145 end
tables(opts=OPTS)
[show source]
    # File lib/sequel/adapters/ado/access.rb
122 def tables(opts=OPTS)
123   m = output_identifier_meth
124   ado_schema_tables.map {|tbl| m.call(tbl['TABLE_NAME'])}
125 end
views(opts=OPTS)
[show source]
    # File lib/sequel/adapters/ado/access.rb
127 def views(opts=OPTS)
128   m = output_identifier_meth
129   ado_schema_views.map {|tbl| m.call(tbl['TABLE_NAME'])}
130 end