Skip to content
Browse files

correctly add jdbc support

  • Loading branch information...
1 parent 158ed4c commit 9a8d85995e3553d594290fddd800eacb72802ebc Matthew committed May 22, 2010
View
2 lib/foreigner.rb
@@ -39,9 +39,7 @@ def on_load(&block)
end
Foreigner.register 'mysql', 'foreigner/connection_adapters/mysql_adapter'
-Foreigner.register 'jdbcmysql', 'foreigner/connection_adapters/mysql_adapter'
Foreigner.register 'postgresql', 'foreigner/connection_adapters/postgresql_adapter'
-Foreigner.register 'jdbcpostgresql', 'foreigner/connection_adapters/postgresql_adapter'
Foreigner.on_load do
module ActiveRecord
View
12 lib/foreigner/connection_adapters/mysql_adapter.rb
@@ -46,8 +46,16 @@ def foreign_keys(table_name)
module ActiveRecord
module ConnectionAdapters
- MysqlAdapter.class_eval do
- include Foreigner::ConnectionAdapters::MysqlAdapter
+ if defined? MysqlAdapter
+ MysqlAdapter.class_eval do
+ include Foreigner::ConnectionAdapters::MysqlAdapter
+ end
+ end
+
+ if defined? JdbcAdapter
+ JdbcAdapter.class_eval do
+ include Foreigner::ConnectionAdapters::MysqlAdapter
+ end
end
end
end
View
12 lib/foreigner/connection_adapters/postgresql_adapter.rb
@@ -49,8 +49,16 @@ def foreign_keys(table_name)
module ActiveRecord
module ConnectionAdapters
- PostgreSQLAdapter.class_eval do
- include Foreigner::ConnectionAdapters::PostgreSQLAdapter
+ if defined? PostgreSQLAdapter
+ PostgreSQLAdapter.class_eval do
+ include Foreigner::ConnectionAdapters::PostgreSQLAdapter
+ end
+ end
+
+ if defined? JdbcAdapter
+ JdbcAdapter.class_eval do
+ include Foreigner::ConnectionAdapters::PostgreSQLAdapter
+ end
end
end
end
View
3 lib/foreigner/connection_adapters/sql_2003.rb
@@ -16,8 +16,7 @@ def add_foreign_key(from_table, to_table, options = {})
"ADD CONSTRAINT #{quote_column_name(foreign_key_name)} " +
"FOREIGN KEY (#{quote_column_name(column)}) " +
"REFERENCES #{quote_table_name(ActiveRecord::Migrator.proper_table_name(to_table))}(#{primary_key})"
-
- sql << " #{dependency}" unless dependency.blank?
+ sql << " #{dependency}" if dependency.present?
execute(sql)
end

0 comments on commit 9a8d859

Please sign in to comment.
Something went wrong with that request. Please try again.