mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Update datamapper truncation to use select as query is deprecated
This commit is contained in:
parent
bc2a480e9b
commit
9e6767d918
1 changed files with 5 additions and 5 deletions
|
@ -15,7 +15,7 @@ module DataMapper
|
||||||
|
|
||||||
# taken from http://github.com/godfat/dm-mapping/tree/master
|
# taken from http://github.com/godfat/dm-mapping/tree/master
|
||||||
def storage_names(repository = :default)
|
def storage_names(repository = :default)
|
||||||
query 'SHOW TABLES'
|
select 'SHOW TABLES'
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate_table(table_name)
|
def truncate_table(table_name)
|
||||||
|
@ -24,7 +24,7 @@ module DataMapper
|
||||||
|
|
||||||
# copied from activerecord
|
# copied from activerecord
|
||||||
def disable_referential_integrity
|
def disable_referential_integrity
|
||||||
old = query("SELECT @@FOREIGN_KEY_CHECKS;")
|
old = select("SELECT @@FOREIGN_KEY_CHECKS;")
|
||||||
begin
|
begin
|
||||||
execute("SET FOREIGN_KEY_CHECKS = 0;")
|
execute("SET FOREIGN_KEY_CHECKS = 0;")
|
||||||
yield
|
yield
|
||||||
|
@ -46,7 +46,7 @@ module DataMapper
|
||||||
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
WHERE type = 'table' AND NOT name = 'sqlite_sequence'
|
||||||
SQL
|
SQL
|
||||||
# activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 181
|
# activerecord-2.1.0/lib/active_record/connection_adapters/sqlite_adapter.rb: 181
|
||||||
query sql
|
select sql
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate_table(table_name)
|
def truncate_table(table_name)
|
||||||
|
@ -76,7 +76,7 @@ module DataMapper
|
||||||
SELECT table_name FROM "information_schema"."tables"
|
SELECT table_name FROM "information_schema"."tables"
|
||||||
WHERE table_schema = current_schema()
|
WHERE table_schema = current_schema()
|
||||||
SQL
|
SQL
|
||||||
query(sql)
|
select(sql)
|
||||||
end
|
end
|
||||||
|
|
||||||
def truncate_table(table_name)
|
def truncate_table(table_name)
|
||||||
|
@ -86,7 +86,7 @@ module DataMapper
|
||||||
# FIXME
|
# FIXME
|
||||||
# copied from activerecord
|
# copied from activerecord
|
||||||
def supports_disable_referential_integrity?
|
def supports_disable_referential_integrity?
|
||||||
version = query("SHOW server_version")[0][0].split('.')
|
version = select("SHOW server_version")[0][0].split('.')
|
||||||
(version[0].to_i >= 8 && version[1].to_i >= 1) ? true : false
|
(version[0].to_i >= 8 && version[1].to_i >= 1) ? true : false
|
||||||
rescue
|
rescue
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue