Class: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter

Inherits:
AbstractAdapter
  • Object
show all
Defined in:
lib/database_cleaner/active_record/deletion.rb,
lib/database_cleaner/active_record/truncation.rb

Instance Method Summary collapse

Methods inherited from AbstractAdapter

#views

Instance Method Details

#cascadeObject



66
67
68
# File 'lib/database_cleaner/active_record/truncation.rb', line 66

def cascade
  @cascade ||= db_version >=  80200 ? 'CASCADE' : ''
end

#db_versionObject



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_identityObject



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