Class: TestProf::AnyFixture::Dump::SQLite
Instance Method Summary
collapse
Methods inherited from BaseAdapter
#setup_env, #teardown_env
Instance Method Details
#compile_sql(sql, binds) ⇒ Object
20
21
22
|
# File 'lib/test_prof/any_fixture/dump/sqlite.rb', line 20
def compile_sql(sql, binds)
sql.gsub(/\?/) { binds.shift }
end
|
#import(path) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/test_prof/any_fixture/dump/sqlite.rb', line 24
def import(path)
db = conn.pool.spec.config[:database]
return false if %r{:memory:}.match?(db)
`sqlite3 --version`
while_disconnected do
`sqlite3 #{db} < "#{path}"`
end
true
rescue Errno::ENOENT
false
end
|
#reset_sequence!(table_name, start) ⇒ Object
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/test_prof/any_fixture/dump/sqlite.rb', line 9
def reset_sequence!(table_name, start)
execute <<~SQL.chomp
DELETE FROM sqlite_sequence WHERE name=#{table_name}
SQL
execute <<~SQL.chomp
INSERT INTO sqlite_sequence (name, seq)
VALUES (#{table_name}, #{start})
SQL
end
|