Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
- Defined in:
- lib/database_cleaner/active_record/deletion.rb,
lib/database_cleaner/active_record/truncation.rb
Instance Method Summary collapse
- #cascade ⇒ Object
- #db_version ⇒ Object
- #delete_table(table_name) ⇒ Object
- #restart_identity ⇒ Object
- #truncate_table(table_name) ⇒ Object
Methods inherited from AbstractAdapter
Instance Method Details
#cascade ⇒ Object
66 67 68 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 66 def cascade @cascade ||= db_version >= 80200 ? 'CASCADE' : '' end |
#db_version ⇒ Object
62 63 64 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 62 def db_version @db_version ||= postgresql_version end |
#delete_table(table_name) ⇒ Object
31 32 33 |
# File 'lib/database_cleaner/active_record/deletion.rb', line 31 def delete_table(table_name) execute("DELETE FROM #{quote_table_name(table_name)};") end |
#restart_identity ⇒ Object
70 71 72 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 70 def restart_identity @restart_identity ||= db_version >= 80400 ? 'RESTART IDENTITY' : '' end |
#truncate_table(table_name) ⇒ Object
74 75 76 |
# File 'lib/database_cleaner/active_record/truncation.rb', line 74 def truncate_table(table_name) execute("TRUNCATE TABLE #{quote_table_name(table_name)} #{restart_identity} #{cascade};") end |