Merge pull request #52 from greg-barnett/database_cleaner

---

The first commit works, for versions of postgresql up to 9.*

The second should work for any and all future versions of postgresql, as long as the implementation of postgresql_version in ActiveRecord doesnt change...
This commit is contained in:
Ben Mabey 2011-03-16 21:51:01 -06:00
commit fb01b5fb67
1 changed files with 3 additions and 6 deletions

View File

@ -60,18 +60,15 @@ module ActiveRecord
class PostgreSQLAdapter < AbstractAdapter
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
@db_version ||= postgresql_version
end
def cascade
@cascade ||= db_version >= "08.02" ? "CASCADE" : ""
@cascade ||= db_version >= 80200 ? 'CASCADE' : ''
end
def restart_identity
@restart_identity ||= db_version >= "08.04" ? "RESTART IDENTITY" : ""
@restart_identity ||= db_version >= 80400 ? 'RESTART IDENTITY' : ''
end
def truncate_table(table_name)