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, opts = {}) ⇒ Object
- #truncate_tables(table_names, opts) ⇒ Object
Instance Method Details
#database_cleaner_table_cache ⇒ Object
213 214 215 216 217 218 219 220 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 213 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
195 196 197 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 195 def database_tables tables_with_schema end |
#pre_count_tables(tables) ⇒ Object
209 210 211 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 209 def pre_count_tables(tables) tables.select { |table| has_been_used?(table) } end |
#pre_count_truncate_tables(tables, opts = {}) ⇒ Object
205 206 207 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 205 def pre_count_truncate_tables(tables, opts = {}) truncate_tables(pre_count_tables(tables), opts) end |
#truncate_tables(table_names, opts) ⇒ Object
199 200 201 202 203 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 199 def truncate_tables(table_names, opts) return if table_names.nil? || table_names.empty? execute("TRUNCATE TABLE #{table_names.map{|name| quote_table_name(name)}.join(', ')} RESTART IDENTITY #{opts[:truncate_option]};") end |