diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-20 21:21:41 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-02-20 21:21:41 +0000 |
commit | 101968f3674dfedb0549a54bf6407c287d357f0a (patch) | |
tree | f619811941d11d5b59db39f4d4152759eeacb4a7 /activerecord/lib | |
parent | 8322ea45c1087325fd428a201749791550bc7859 (diff) | |
download | rails-101968f3674dfedb0549a54bf6407c287d357f0a.tar.gz rails-101968f3674dfedb0549a54bf6407c287d357f0a.tar.bz2 rails-101968f3674dfedb0549a54bf6407c287d357f0a.zip |
Added automatic dropping/creating of test tables for running the unit tests on all databases #587 [adelle@bullet.net.au]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@719 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
6 files changed, 26 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 6a9ca8fcf1..5d2c764afe 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -356,6 +356,11 @@ module ActiveRecord name end + # Returns the human-readable name of the adapter. Use mixed case - one can always use downcase if needed. + def adapter_name() + 'Abstract' + end + # Returns a string of the CREATE TABLE SQL statements for recreating the entire structure of the database. def structure_dump() end diff --git a/activerecord/lib/active_record/connection_adapters/db2_adapter.rb b/activerecord/lib/active_record/connection_adapters/db2_adapter.rb index 867b17eaa0..225ade0441 100644 --- a/activerecord/lib/active_record/connection_adapters/db2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/db2_adapter.rb @@ -74,6 +74,10 @@ begin def quote_column_name(name) name; end + def adapter_name() + 'DB2' + end + def quote_string(s) s.gsub(/'/, "''") # ' (for ruby-mode) end diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 645e5f6dd4..c637a50c5a 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -102,7 +102,11 @@ module ActiveRecord def quote_column_name(name) return "`#{name}`" end - + + def adapter_name() + 'MySQL' + end + def structure_dump select_all("SHOW TABLES").inject("") do |structure, table| structure += select_one("SHOW CREATE TABLE #{table.to_a.first.last}")["Create Table"] + ";\n\n" diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index ef939d747b..67b26739ca 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -89,6 +89,10 @@ module ActiveRecord return "\"#{name}\"" end + def adapter_name() + 'PostgreSQL' + end + private def last_insert_id(table, column = "id") sequence_name = "#{table}_#{column || 'id'}_seq" diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index b8a91929c7..d8f3e04498 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -141,6 +141,10 @@ module ActiveRecord return "'#{name}'" end + def adapter_name() + 'SQLite' + end + protected def table_structure(table_name) execute "PRAGMA table_info(#{table_name})" diff --git a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb index 84293736e3..7bddba9b5b 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb @@ -43,6 +43,10 @@ module ActiveRecord raise ArgumentError, "No database specified. Missing argument: database." end + def adapter_name() + 'SqlServer' + end + conn = DBI.connect("DBI:ADO:Provider=SQLOLEDB;Data Source=#{host};Initial Catalog=#{database};User Id=#{username};Password=#{password};") conn["AutoCommit"] = true |