Class: Swift::Adapter::Sql
Overview
Instance Attribute Summary
#db
Instance Method Summary
collapse
#migrate!
#aexecute, #blocking_execute, #create, #delete, #execute, #get, #identity_map, #initialize, #log_command, #pending, #prepare, #trace, #trace?, #update
Constructor Details
This class inherits a constructor from Swift::Adapter
Instance Method Details
#fields(table) ⇒ Object
17
18
19
20
|
# File 'lib/swift/adapter/sql.rb', line 17
def fields table
result = execute("select * from #{table} limit 0")
Hash[result.fields.map(&:to_sym).zip(result.types)]
end
|
#serialized_transaction(&block) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/swift/fiber_connection_pool.rb', line 81
def serialized_transaction &block
Swift.scopes.push(self)
execute('begin')
res = yield(self)
execute('commit')
res
rescue => e
execute('rollback')
raise e
ensure
Swift.scopes.pop
end
|
#tables ⇒ Object
13
14
15
|
# File 'lib/swift/adapter/sql.rb', line 13
def tables
raise NotImplementedError
end
|
#transaction(*args) ⇒ Object
22
23
24
|
# File 'lib/swift/adapter/sql.rb', line 22
def transaction *args
db.transaction(*args) {|db| yield self}
end
|