Module: DatabaseCleaner::ActiveRecord::ConnectionWrapper::PostgreSQLAdapter
- Defined in:
- lib/database_cleaner/active_record/truncation.rb
Instance Method Summary collapse
- #database_cleaner_table_cache ⇒ Object
- #database_tables ⇒ Object
- #pre_count_tables(tables) ⇒ Object
- #pre_count_truncate_tables(tables) ⇒ Object
- #truncate_tables(table_names) ⇒ Object
Instance Method Details
#database_cleaner_table_cache ⇒ Object
209 210 211 212 213 214 215 216 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 209 def database_cleaner_table_cache # AR returns a list of tables without schema but then returns a # migrations table with the schema. There are other problems, too, # with using the base list. If a table exists in multiple schemas # within the search path, truncation without the schema name could # result in confusing, if not unexpected results. @database_cleaner_tables ||= tables_with_schema end |
#database_tables ⇒ Object
192 193 194 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 192 def database_tables tables_with_schema end |
#pre_count_tables(tables) ⇒ Object
205 206 207 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 205 def pre_count_tables(tables) tables.select { |table| has_been_used?(table) } end |
#pre_count_truncate_tables(tables) ⇒ Object
201 202 203 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 201 def pre_count_truncate_tables(tables) truncate_tables(pre_count_tables(tables)) end |
#truncate_tables(table_names) ⇒ Object
196 197 198 199 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 196 def truncate_tables(table_names) return if table_names.nil? || table_names.empty? execute("TRUNCATE TABLE #{table_names.map{|name| quote_table_name(name)}.join(', ')} RESTART IDENTITY RESTRICT;") end |