adding exec_insert to sqlite3
This commit is contained in:
parent
c4fc396300
commit
32dbf00d99
@ -173,6 +173,10 @@ def exec_query(sql, name = nil, binds = [])
|
||||
end
|
||||
end
|
||||
|
||||
def exec_insert(sql, name, binds)
|
||||
exec_query(sql, name, binds)
|
||||
end
|
||||
|
||||
def execute(sql, name = nil) #:nodoc:
|
||||
log(sql, name) { @connection.execute(sql) }
|
||||
end
|
||||
|
@ -19,6 +19,18 @@ def setup
|
||||
eosql
|
||||
end
|
||||
|
||||
def test_exec_insert
|
||||
column = @conn.columns('items').find { |col| col.name == 'number' }
|
||||
vals = [[column, 10]]
|
||||
@conn.exec_insert('insert into items (number) VALUES (?)', 'SQL', vals)
|
||||
|
||||
result = @conn.exec_query(
|
||||
'select number from items where number = ?', 'SQL', vals)
|
||||
|
||||
assert_equal 1, result.rows.length
|
||||
assert_equal 10, result.rows.first.first
|
||||
end
|
||||
|
||||
def test_primary_key_returns_nil_for_no_pk
|
||||
@conn.exec_query('create table ex(id int, data string)')
|
||||
assert_nil @conn.primary_key('ex')
|
||||
|
Loading…
Reference in New Issue
Block a user