Skip to content

Commit

Permalink
Fix missing quote_table_name function under Rails 1.2.6 and earlier
Browse files Browse the repository at this point in the history
- Also, small tweaks to jdbc.rake to select proper config


git-svn-id: svn+ssh://rubyforge.org/var/svn/jruby-extras/trunk/activerecord-jdbc@994 8ba958d5-0c1a-0410-94a6-a65dfc1b28a6
  • Loading branch information
nicksieger committed May 16, 2008
1 parent 6281a22 commit 0510769
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions History.txt
Expand Up @@ -5,6 +5,8 @@
- Fix for JRUBY-2256
- JRUBY-1638, JRUBY-2404, JRUBY-2463: schema.table handling and Oracle NUMBER fixes (Thanks Darcy Schultz & Jesse Hu)
- Add structure dump and other DDL-ish for DB2 (courtesy abedra and stuarthalloway)
- Fix missing quote_table_name function under Rails 1.2.6 and earlier
- Small tweaks to jdbc.rake to select proper config

== 0.8

Expand Down
11 changes: 11 additions & 0 deletions lib/active_record/connection_adapters/jdbc_adapter.rb
Expand Up @@ -420,8 +420,19 @@ def alias_chained_method(meth, feature, target)
end
end

module CompatibilityMethods
def self.needed?(base)
!base.instance_methods.include?("quote_table_name")
end

def quote_table_name(name)
quote_column_name(name)
end
end

class JdbcAdapter < AbstractAdapter
extend ShadowCoreMethods
include CompatibilityMethods if CompatibilityMethods.needed?(self)

attr_reader :config

Expand Down
5 changes: 3 additions & 2 deletions lib/jdbc_adapter/jdbc.rake
Expand Up @@ -60,10 +60,11 @@ namespace :db do
end
end
end

namespace :test do
redefine_task :clone_structure => [ "db:structure:dump", "db:test:purge" ] do
abcs = ActiveRecord::Base.configurations
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.establish_connection(abcs[:test])
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') if abcs["test"]["adapter"] =~ /mysql/i
IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
ActiveRecord::Base.connection.execute(ddl)
Expand All @@ -72,7 +73,7 @@ namespace :db do

redefine_task :purge => :environment do
abcs = ActiveRecord::Base.configurations
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.establish_connection(abcs[:test])
db = ActiveRecord::Base.connection.database_name
ActiveRecord::Base.connection.recreate_database(db)
end
Expand Down

0 comments on commit 0510769

Please sign in to comment.