Fix truncation for PostgreSQL

Fix suggested by bjeanes on GH #15
This commit is contained in:
Gabriel Sobrinho 2010-10-04 09:53:58 +08:00 committed by Ben Mabey
parent 57807b0321
commit 7159f903bf
1 changed files with 4 additions and 4 deletions

View File

@ -42,19 +42,19 @@ module ActiveRecord
class PostgreSQLAdapter < AbstractAdapter
def self.db_version
@db_version ||= connection.select_values(
def db_version
@db_version ||= select_values(
"SELECT CHARACTER_VALUE
FROM INFORMATION_SCHEMA.SQL_IMPLEMENTATION_INFO
WHERE IMPLEMENTATION_INFO_NAME = 'DBMS VERSION' ").join.to_s
end
def self.cascade
def cascade
@cascade ||= db_version >= "08.02" ? "CASCADE" : ""
end
def truncate_table(table_name)
execute("TRUNCATE TABLE #{quote_table_name(table_name)} #{self.class.cascade};")
execute("TRUNCATE TABLE #{quote_table_name(table_name)} #{cascade};")
end
end