activerecord-jdbc-adapter 0.9.0.1 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. data/History.txt +31 -0
  2. data/Manifest.txt +7 -0
  3. data/README.txt +15 -2
  4. data/Rakefile +28 -30
  5. data/lib/active_record/connection_adapters/h2_adapter.rb +13 -1
  6. data/lib/active_record/connection_adapters/jdbc_adapter.rb +78 -96
  7. data/lib/jdbc_adapter/jdbc.rake +15 -5
  8. data/lib/jdbc_adapter/jdbc_adapter_internal.jar +0 -0
  9. data/lib/jdbc_adapter/jdbc_cachedb.rb +4 -4
  10. data/lib/jdbc_adapter/jdbc_db2.rb +5 -7
  11. data/lib/jdbc_adapter/jdbc_derby.rb +57 -30
  12. data/lib/jdbc_adapter/jdbc_firebird.rb +2 -2
  13. data/lib/jdbc_adapter/jdbc_hsqldb.rb +53 -46
  14. data/lib/jdbc_adapter/jdbc_informix.rb +4 -5
  15. data/lib/jdbc_adapter/jdbc_mimer.rb +2 -2
  16. data/lib/jdbc_adapter/jdbc_mssql.rb +25 -23
  17. data/lib/jdbc_adapter/jdbc_mysql.rb +20 -22
  18. data/lib/jdbc_adapter/jdbc_oracle.rb +115 -117
  19. data/lib/jdbc_adapter/jdbc_postgre.rb +129 -59
  20. data/lib/jdbc_adapter/jdbc_sqlite3.rb +149 -28
  21. data/lib/jdbc_adapter/jdbc_sybase.rb +13 -2
  22. data/lib/jdbc_adapter/missing_functionality_helper.rb +12 -3
  23. data/lib/jdbc_adapter/version.rb +1 -1
  24. data/src/java/jdbc_adapter/JdbcAdapterInternalService.java +6 -1101
  25. data/src/java/jdbc_adapter/JdbcDerbySpec.java +26 -23
  26. data/src/java/jdbc_adapter/JdbcMySQLSpec.java +79 -28
  27. data/src/java/jdbc_adapter/PostgresRubyJdbcConnection.java +35 -0
  28. data/src/java/jdbc_adapter/RubyJdbcConnection.java +1149 -0
  29. data/src/java/jdbc_adapter/SQLBlock.java +12 -3
  30. data/src/java/jdbc_adapter/Sqlite3RubyJdbcConnection.java +41 -0
  31. data/test/activerecord/connection_adapters/type_conversion_test.rb +1 -1
  32. data/test/db/derby.rb +0 -3
  33. data/test/db/h2.rb +0 -3
  34. data/test/db/hsqldb.rb +1 -4
  35. data/test/db/mysql.rb +1 -0
  36. data/test/db/oracle.rb +5 -0
  37. data/test/db/sqlite3.rb +7 -3
  38. data/test/derby_migration_test.rb +21 -0
  39. data/test/has_many_through.rb +11 -4
  40. data/test/jdbc_common.rb +13 -1
  41. data/test/models/data_types.rb +11 -1
  42. data/test/models/mixed_case.rb +20 -0
  43. data/test/mysql_multibyte_test.rb +4 -0
  44. data/test/oracle_simple_test.rb +1 -1
  45. data/test/postgres_mixed_case_test.rb +19 -0
  46. data/test/simple.rb +220 -41
  47. data/test/sqlite3_simple_test.rb +83 -0
  48. data/test/sybase_jtds_simple_test.rb +6 -0
  49. metadata +12 -10
data/History.txt CHANGED
@@ -1,3 +1,34 @@
1
+ == 0.9.1
2
+
3
+ - We did a lot of internal cleanup this release in the hopes of
4
+ simplifying the code and increasing performance.
5
+ - Many SQLite updates (thanks Nils Christian Haugen)
6
+ - JRUBY-2912: Fix MSSQL create/drop database (Joern Hartmann)
7
+ - JRUBY-2767: Mistake in selecting identity with H2/HSQLDB
8
+ - JRUBY-2884: jdbc_postgre.rb issue handling nil booleans (also a fix
9
+ for hsqldb/h2) + tests
10
+ - JRUBY-2995: activerecord jdbc derby adapter should quote columns
11
+ called 'year'
12
+ - JRUBY-2897: jdbc_postgre.rb needs microsecond support
13
+ - JRUBY-3282: Upgrade to derby 10.4.2.0 to allow unique constraints
14
+ with nullable columns
15
+ - Update h2 from 1.0.63 to 1.1.107 in driver
16
+ - JRUBY-3026: [Derby] Allow select/delete/update conditions with
17
+ comparison to NULL using '='
18
+ - JRUBY-2996: ...(actually this fixes only remaining issue of this bug
19
+ which was symbols making into quote were exploding
20
+ - JRUBY-2691: Update sybase driver to pass simple unit tests with jtds
21
+ and verify it works with the new dialect keyword. patch by Leigh
22
+ Kennedy
23
+ - Make :float type work on h2,hsql [returned as string]. Make :float
24
+ work on hsqldb (no paren value supported). Make REAL_TYPE just
25
+ return RubyFloat
26
+ - JRUBY-3222: Upgrade #type_to_sql to variation of AR 2.1.2 version
27
+ - Add patch supplied in JRUBY-3489 (patch by Jean-Dominique Morani)
28
+ - Various Oracle fixes by edsono
29
+ - JRUBY-2688: Don't hard-code MySQL connection character encoding to
30
+ utf8
31
+
1
32
  == 0.9
2
33
 
3
34
  - Now updated to support ActiveRecord 2.2. JNDI-based connections will
data/Manifest.txt CHANGED
@@ -52,6 +52,7 @@ test/db/oracle.rb
52
52
  test/db/postgres.rb
53
53
  test/db/sqlite3.rb
54
54
  test/db2_simple_test.rb
55
+ test/derby_migration_test.rb
55
56
  test/derby_multibyte_test.rb
56
57
  test/derby_simple_test.rb
57
58
  test/generic_jdbc_connection_test.rb
@@ -76,18 +77,24 @@ test/models/add_not_null_column_to_table.rb
76
77
  test/models/auto_id.rb
77
78
  test/models/data_types.rb
78
79
  test/models/entry.rb
80
+ test/models/mixed_case.rb
79
81
  test/models/reserved_word.rb
80
82
  test/mssql_simple_test.rb
81
83
  test/mysql_multibyte_test.rb
82
84
  test/mysql_simple_test.rb
83
85
  test/oracle_simple_test.rb
86
+ test/postgres_mixed_case_test.rb
84
87
  test/postgres_reserved_test.rb
85
88
  test/postgres_simple_test.rb
86
89
  test/simple.rb
87
90
  test/sqlite3_simple_test.rb
91
+ test/sybase_jtds_simple_test.rb
88
92
  lib/jdbc_adapter/jdbc.rake
89
93
  src/java/jdbc_adapter/JdbcAdapterInternalService.java
90
94
  src/java/jdbc_adapter/JdbcConnectionFactory.java
91
95
  src/java/jdbc_adapter/JdbcDerbySpec.java
92
96
  src/java/jdbc_adapter/JdbcMySQLSpec.java
97
+ src/java/jdbc_adapter/PostgresRubyJdbcConnection.java
98
+ src/java/jdbc_adapter/RubyJdbcConnection.java
93
99
  src/java/jdbc_adapter/SQLBlock.java
100
+ src/java/jdbc_adapter/Sqlite3RubyJdbcConnection.java
data/README.txt CHANGED
@@ -30,8 +30,8 @@ What's there, and what is not there:
30
30
  * Informix - Fairly complete support, all tests pass and migrations appear to work. Comments welcome.
31
31
 
32
32
  Other databases will require testing and likely a custom configuration module.
33
- Please join the jruby-extras
34
- mailing-list[http://rubyforge.org/mail/?group_id=2014] to help us discover
33
+ Please join the activerecord-jdbc
34
+ mailing-lists[http://kenai.com/projects/activerecord-jdbc/lists] to help us discover
35
35
  support for more databases.
36
36
 
37
37
  == Using ActiveRecord JDBC
@@ -133,6 +133,19 @@ installed, you can simply type <tt>jruby -S rake</tt> to run the tests. A
133
133
  database named <tt>weblog_development</tt> is needed beforehand with a
134
134
  connection user of "blog" and password empty.
135
135
 
136
+ If you want rails logging enabled during these test runs you can edit
137
+ test/jdbc_common.rb and add the following line:
138
+
139
+ require 'db/logger'
140
+
141
+ == Running AR Tests
142
+
143
+ # If you want to run MRI against Rails remember to re-export RUBYLIB to be
144
+ # empty (or whatever you normally have it set to when you are done).
145
+ export RUBYLIB=$(find $HOME/NetbeansProjects/activerecord-jdbc-adapter -name lib -type d | grep -v pkg | ruby -e 'puts $stdin.readlines.map{|l| l.chomp}.join(":")')
146
+ cd active_record_source_dir
147
+ jruby -S rake test_jdbcmysql (or specific adapter you want to test)
148
+
136
149
  == Authors
137
150
 
138
151
  This project was written by Nick Sieger <nick@nicksieger.com> and Ola Bini
data/Rakefile CHANGED
@@ -31,7 +31,7 @@ task :filelist do
31
31
  puts FileList['pkg/**/*'].inspect
32
32
  end
33
33
 
34
- if RUBY_PLATFORM =~ /java/
34
+ if defined?(JRUBY_VERSION)
35
35
  # TODO: add more databases into the standard tests here.
36
36
  task :test => [:test_mysql, :test_jdbc, :test_derby, :test_hsqldb, :test_h2, :test_sqlite3]
37
37
  else
@@ -46,9 +46,15 @@ FileList['drivers/*'].each do |d|
46
46
  if driver == "derby"
47
47
  files << 'test/activerecord/connection_adapters/type_conversion_test.rb'
48
48
  end
49
- t.ruby_opts << "-rjdbc/#{driver}"
50
49
  t.test_files = files
51
- t.libs << "test" << "#{d}/lib"
50
+ t.libs = []
51
+ if defined?(JRUBY_VERSION)
52
+ t.ruby_opts << "-rjdbc/#{driver}"
53
+ t.libs << "lib" << "#{d}/lib"
54
+ t.libs.push *FileList["adapters/#{driver}*/lib"]
55
+ end
56
+ t.libs << "test"
57
+ t.verbose = true
52
58
  end
53
59
  end
54
60
 
@@ -65,40 +71,32 @@ end
65
71
  task :test_postgresql => [:test_postgres]
66
72
  task :test_pgsql => [:test_postgres]
67
73
 
68
- # Ensure oracle driver is on your classpath before launching rake
69
- Rake::TestTask.new(:test_oracle) do |t|
70
- t.test_files = FileList['test/oracle_simple_test.rb']
71
- t.libs << 'test'
72
- end
73
-
74
- # Ensure DB2 driver is on your classpath before launching rake
75
- Rake::TestTask.new(:test_db2) do |t|
76
- t.test_files = FileList['test/db2_simple_test.rb']
77
- t.libs << 'test'
78
- end
79
-
80
- # Ensure InterSystems CacheDB driver is on your classpath before launching rake
81
- Rake::TestTask.new(:test_cachedb) do | t |
82
- t.test_files = FileList[ 'test/cachedb_simple_test.rb' ]
83
- t.libs << 'test'
74
+ # Ensure driver for these DBs is on your classpath
75
+ %w(oracle db2 cachedb mssql informix).each do |d|
76
+ Rake::TestTask.new("test_#{d}") do |t|
77
+ t.test_files = FileList["test/#{d}_simple_test.rb"]
78
+ t.libs = []
79
+ t.libs << 'lib' if defined?(JRUBY_VERSION)
80
+ t.libs << 'test'
81
+ end
84
82
  end
85
83
 
86
- # Ensure that the jTDS driver in on your classpath before launching rake
87
- Rake::TestTask.new(:test_mssql) do | t |
88
- t.test_files = FileList[ 'test/mssql_simple_test.rb' ]
84
+ # Tests for JDBC adapters that don't require a database.
85
+ Rake::TestTask.new(:test_jdbc_adapters) do | t |
86
+ t.test_files = FileList[ 'test/jdbc_adapter/jdbc_sybase_test.rb' ]
89
87
  t.libs << 'test'
90
88
  end
91
89
 
92
- # Ensure that the Informix driver is on your classpath before launching rake
93
- Rake::TestTask.new(:test_informix) do |t|
94
- t.test_files = FileList[ 'test/informix_simple_test.rb' ]
95
- t.libs << 'test'
90
+ # Ensure that the jTDS driver is in your classpath before launching rake
91
+ Rake::TestTask.new(:test_sybase_jtds) do |t|
92
+ t.test_files = FileList['test/sybase_jtds_simple_test.rb']
93
+ t.libs << 'test'
96
94
  end
97
95
 
98
- # Tests for JDBC adapters that don't require a database.
99
- Rake::TestTask.new(:test_jdbc_adapters) do | t |
100
- t.test_files = FileList[ 'test/jdbc_adapter/jdbc_sybase_test.rb' ]
101
- t.libs << 'test'
96
+ # Ensure that the jConnect driver is in your classpath before launching rake
97
+ Rake::TestTask.new(:test_sybase_jconnect) do |t|
98
+ t.test_files = FileList['test/sybase_jconnect_simple_test.rb']
99
+ t.libs << 'test'
102
100
  end
103
101
 
104
102
  MANIFEST = FileList["History.txt", "Manifest.txt", "README.txt",
@@ -1 +1,13 @@
1
- require 'active_record/connection_adapters/jdbc_adapter'
1
+ tried_gem = false
2
+ begin
3
+ require "jdbc/h2"
4
+ rescue LoadError
5
+ unless tried_gem
6
+ require 'rubygems'
7
+ gem "jdbc-h2"
8
+ tried_gem = true
9
+ retry
10
+ end
11
+ # trust that the hsqldb jar is already present
12
+ end
13
+ require 'active_record/connection_adapters/jdbc_adapter'
@@ -9,31 +9,38 @@ begin
9
9
  rescue LoadError
10
10
  end if defined?(RAILS_ROOT)
11
11
 
12
- module ActiveRecord
13
- module ConnectionAdapters # :nodoc:
14
- module SchemaStatements
15
- # The original implementation of this had a bug, which modifies native_database_types.
16
- # This version allows us to cache that value.
17
- def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
18
- native = native_database_types[type.to_s.downcase.to_sym]
19
- column_type_sql = native.is_a?(Hash) ? native[:name] : native
20
- if type == :decimal # ignore limit, use precison and scale
21
- precision ||= native[:precision]
22
- scale ||= native[:scale]
23
- if precision
24
- if scale
25
- column_type_sql += "(#{precision},#{scale})"
26
- else
27
- column_type_sql += "(#{precision})"
12
+ # AR's 2.2 version of this method is sufficient, but we need it for
13
+ # older versions
14
+ if ActiveRecord::VERSION::MAJOR <= 2 && ActiveRecord::VERSION::MINOR < 2
15
+ module ActiveRecord
16
+ module ConnectionAdapters # :nodoc:
17
+ module SchemaStatements
18
+ # Convert the speficied column type to a SQL string.
19
+ def type_to_sql(type, limit = nil, precision = nil, scale = nil)
20
+ if native = native_database_types[type]
21
+ column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
22
+
23
+ if type == :decimal # ignore limit, use precision and scale
24
+ scale ||= native[:scale]
25
+
26
+ if precision ||= native[:precision]
27
+ if scale
28
+ column_type_sql << "(#{precision},#{scale})"
29
+ else
30
+ column_type_sql << "(#{precision})"
31
+ end
32
+ elsif scale
33
+ raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified"
34
+ end
35
+
36
+ elsif limit ||= native.is_a?(Hash) && native[:limit]
37
+ column_type_sql << "(#{limit})"
28
38
  end
39
+
40
+ column_type_sql
29
41
  else
30
- raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified" if scale
42
+ type
31
43
  end
32
- column_type_sql
33
- else
34
- limit ||= native[:limit]
35
- column_type_sql += "(#{limit})" if limit
36
- column_type_sql
37
44
  end
38
45
  end
39
46
  end
@@ -43,8 +50,7 @@ end
43
50
  module JdbcSpec
44
51
  module ActiveRecordExtensions
45
52
  def jdbc_connection(config)
46
- connection = ::ActiveRecord::ConnectionAdapters::JdbcConnection.new(config)
47
- ::ActiveRecord::ConnectionAdapters::JdbcAdapter.new(connection, logger, config)
53
+ ::ActiveRecord::ConnectionAdapters::JdbcAdapter.new(nil, logger, config)
48
54
  end
49
55
  alias jndi_connection jdbc_connection
50
56
 
@@ -208,7 +214,8 @@ module ActiveRecord
208
214
  procs = AR_TO_JDBC_TYPES[ar_type]
209
215
  types = @types
210
216
  procs.each do |p|
211
- new_types = types.select(&p)
217
+ new_types = types.reject {|r| r["data_type"].to_i == Jdbc::Types::OTHER}
218
+ new_types = new_types.select(&p)
212
219
  new_types = new_types.inject([]) do |typs,t|
213
220
  typs << t unless typs.detect {|el| el['type_name'] == t['type_name']}
214
221
  typs
@@ -294,6 +301,14 @@ module ActiveRecord
294
301
  class JdbcConnection
295
302
  attr_reader :adapter, :connection_factory
296
303
 
304
+ # @native_database_types - setup properly by adapter= versus set_native_database_types.
305
+ # This contains type information for the adapter. Individual adapters can make tweaks
306
+ # by defined modify_types
307
+ #
308
+ # @native_types - This is the default type settings sans any modifications by the
309
+ # individual adapter. My guess is that if we loaded two adapters of different types
310
+ # then this is used as a base to be tweaked by each adapter to create @native_database_types
311
+
297
312
  def initialize(config)
298
313
  @config = config.symbolize_keys!
299
314
  @config[:retry_count] ||= 5
@@ -315,64 +330,25 @@ module ActiveRecord
315
330
  raise "The driver encountered an error: #{e}"
316
331
  end
317
332
 
318
- def adapter=(adapt)
319
- @adapter = adapt
320
- @tps = {}
321
- @native_types.each_pair {|k,v| @tps[k] = v.inject({}) {|memo,kv| memo.merge({kv.first => (kv.last.dup rescue kv.last)})}}
322
- adapt.modify_types(@tps)
333
+ def adapter=(adapter)
334
+ @adapter = adapter
335
+ @native_database_types = dup_native_types
336
+ @adapter.modify_types(@native_database_types)
323
337
  end
324
338
 
325
- # Default JDBC introspection for index metadata on the JdbcConnection.
326
- # This is currently used for migrations by JdbcSpec::HSQDLB and JdbcSpec::Derby
327
- # indexes with a little filtering tacked on.
328
- #
329
- # JDBC index metadata is denormalized (multiple rows may be returned for
330
- # one index, one row per column in the index), so a simple block-based
331
- # filter like that used for tables doesn't really work here. Callers
332
- # should filter the return from this method instead.
333
- def indexes(table_name, name = nil, schema_name = nil)
334
- with_connection_retry_guard do |conn|
335
- metadata = conn.getMetaData
336
- begin
337
- unless String === table_name
338
- table_name = table_name.to_s
339
- else
340
- table_name = table_name.dup
341
- end
342
- table_name.upcase! if metadata.storesUpperCaseIdentifiers
343
- table_name.downcase! if metadata.storesLowerCaseIdentifiers
344
- resultset = metadata.getIndexInfo(nil, schema_name, table_name, false, false)
345
- primary_keys = primary_keys(table_name)
346
- indexes = []
347
- current_index = nil
348
- while resultset.next
349
- index_name = resultset.get_string(Jdbc::IndexMetaData::INDEX_NAME)
350
- next unless index_name
351
- index_name.downcase!
352
- column_name = resultset.get_string(Jdbc::IndexMetaData::COLUMN_NAME).downcase
353
-
354
- next if primary_keys.include? column_name
355
-
356
- # We are working on a new index
357
- if current_index != index_name
358
- current_index = index_name
359
- table_name = resultset.get_string(Jdbc::IndexMetaData::TABLE_NAME).downcase
360
- non_unique = resultset.get_boolean(Jdbc::IndexMetaData::NON_UNIQUE)
361
-
362
- # empty list for column names, we'll add to that in just a bit
363
- indexes << IndexDefinition.new(table_name, index_name, !non_unique, [])
364
- end
365
-
366
- # One or more columns can be associated with an index
367
- indexes.last.columns << column_name
368
- end
369
- resultset.close
370
- indexes
371
- ensure
372
- metadata.close rescue nil
339
+ # Duplicate all native types into new hash structure so it can be modified
340
+ # without destroying original structure.
341
+ def dup_native_types
342
+ types = {}
343
+ @native_types.each_pair do |k, v|
344
+ types[k] = v.inject({}) do |memo, kv|
345
+ memo[kv.first] = begin kv.last.dup rescue kv.last end
346
+ memo
373
347
  end
374
348
  end
349
+ types
375
350
  end
351
+ private :dup_native_types
376
352
 
377
353
  def jndi_connection?
378
354
  @jndi_connection
@@ -402,12 +378,6 @@ module ActiveRecord
402
378
  raise ::ActiveRecord::ConnectionFailed, "jdbc adapter requires driver class and url"
403
379
  end
404
380
 
405
- if driver =~ /mysql/i && url !~ /#{Regexp.quote(JdbcSpec::MySQL::URL_OPTIONS)}/
406
- div = url =~ /\?/ ? '&' : '?'
407
- url = "#{url}#{div}#{JdbcSpec::MySQL::URL_OPTIONS}"
408
- @config[:url] = url
409
- end
410
-
411
381
  jdbc_driver = JdbcDriver.new(driver)
412
382
  jdbc_driver.load
413
383
  @connection_factory = JdbcConnectionFactory.impl do
@@ -479,25 +449,37 @@ module ActiveRecord
479
449
 
480
450
  attr_reader :config
481
451
 
482
- ADAPTER_TYPES = ::JdbcSpec.constants.map{|c|
483
- ::JdbcSpec.const_get c }.select{ |c|
484
- c.respond_to? :adapter_selector }.map{|c|
485
- c.adapter_selector }.inject({}) { |h,val|
486
- h[val[0]] = val[1]; h }
487
-
488
452
  def initialize(connection, logger, config)
489
- super(connection, logger)
490
453
  @config = config
491
- dialect = config[:dialect] || config[:driver]
492
- for reg, func in ADAPTER_TYPES
493
- if reg === dialect.to_s
494
- func.call(@config,self)
495
- end
454
+ spec = adapter_spec config
455
+ unless connection
456
+ connection_class = jdbc_connection_class spec
457
+ connection = connection_class.new config
496
458
  end
459
+ super(connection, logger)
460
+ extend spec if spec
497
461
  connection.adapter = self
498
462
  JndiConnectionPoolCallbacks.prepare(self, connection)
499
463
  end
500
464
 
465
+ def jdbc_connection_class(spec)
466
+ connection_class = spec.jdbc_connection_class if spec && spec.respond_to?(:jdbc_connection_class)
467
+ connection_class = ::ActiveRecord::ConnectionAdapters::JdbcConnection unless connection_class
468
+ connection_class
469
+ end
470
+
471
+ # Locate specialized adapter specification if one exists based on config data
472
+ def adapter_spec(config)
473
+ dialect = (config[:dialect] || config[:driver]).to_s
474
+ ::JdbcSpec.constants.map { |name| ::JdbcSpec.const_get name }.each do |constant|
475
+ if constant.respond_to? :adapter_matcher
476
+ spec = constant.adapter_matcher(dialect, config)
477
+ return spec if spec
478
+ end
479
+ end
480
+ nil
481
+ end
482
+
501
483
  def modify_types(tp)
502
484
  tp
503
485
  end
@@ -2,11 +2,17 @@ def redefine_task(*args, &block)
2
2
  task_name = Hash === args.first ? args.first.keys[0] : args.first
3
3
  existing_task = Rake.application.lookup task_name
4
4
  if existing_task
5
- class << existing_task; public :instance_variable_set; end
6
- existing_task.instance_variable_set "@prerequisites", FileList[]
5
+ class << existing_task
6
+ public :instance_variable_set
7
+ attr_reader :actions
8
+ end
9
+ existing_task.instance_variable_set "@prerequisites", FileList[]
10
+ existing_task.actions.shift
11
+ enhancements = existing_task.actions
7
12
  existing_task.instance_variable_set "@actions", []
8
13
  end
9
- task(*args, &block)
14
+ redefined_task = task(*args, &block)
15
+ enhancements.each {|enhancement| redefined_task.actions << enhancement}
10
16
  end
11
17
 
12
18
  namespace :db do
@@ -68,7 +74,11 @@ namespace :db do
68
74
  ActiveRecord::Base.establish_connection(abcs["test"])
69
75
  ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0') if abcs["test"]["adapter"] =~ /mysql/i
70
76
  IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
71
- ActiveRecord::Base.connection.execute(ddl.chomp(';'))
77
+ begin
78
+ ActiveRecord::Base.connection.execute(ddl.chomp(';'))
79
+ rescue Exception => ex
80
+ puts ex.message
81
+ end
72
82
  end
73
83
  end
74
84
 
@@ -78,7 +88,7 @@ namespace :db do
78
88
  if config['adapter'] =~ /postgresql/i
79
89
  if config['url']
80
90
  db = config['url'][/\/([^\/]*)$/, 1]
81
- config['url'][/\/([^\/]*)$/, 1] if db_name
91
+ config['url'][/\/([^\/]*)$/, 1] = 'postgres' if db
82
92
  else
83
93
  db = config['database']
84
94
  config['database'] = 'postgres'