activerecord 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activerecord might be problematic. Click here for more details.

Files changed (96) hide show
  1. data/CHANGELOG +78 -0
  2. data/README +20 -29
  3. data/RUNNING_UNIT_TESTS +1 -2
  4. data/examples/validation.rb +0 -3
  5. data/install.rb +3 -16
  6. data/lib/active_record.rb +11 -4
  7. data/lib/active_record/aggregations.rb +2 -2
  8. data/lib/active_record/associations.rb +8 -8
  9. data/lib/active_record/associations/association_collection.rb +1 -1
  10. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +1 -1
  11. data/lib/active_record/base.rb +117 -43
  12. data/lib/active_record/callbacks.rb +2 -2
  13. data/lib/active_record/connection_adapters/abstract_adapter.rb +7 -14
  14. data/lib/active_record/connection_adapters/db2_adapter.rb +33 -22
  15. data/lib/active_record/connection_adapters/mysql_adapter.rb +74 -33
  16. data/lib/active_record/connection_adapters/oci_adapter.rb +265 -0
  17. data/lib/active_record/connection_adapters/postgresql_adapter.rb +23 -3
  18. data/lib/active_record/connection_adapters/sqlite_adapter.rb +13 -4
  19. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +158 -67
  20. data/lib/active_record/deprecated_associations.rb +4 -4
  21. data/lib/active_record/fixtures.rb +12 -5
  22. data/lib/active_record/locking.rb +22 -22
  23. data/lib/active_record/observer.rb +6 -3
  24. data/lib/active_record/timestamp.rb +15 -5
  25. data/lib/active_record/transactions.rb +4 -4
  26. data/lib/active_record/validations.rb +272 -189
  27. data/lib/active_record/wrappings.rb +2 -2
  28. data/rakefile +17 -2
  29. data/test/aaa_create_tables_test.rb +58 -0
  30. data/test/abstract_unit.rb +3 -2
  31. data/test/aggregations_test.rb +0 -1
  32. data/test/associations_test.rb +27 -28
  33. data/test/base_test.rb +74 -2
  34. data/test/binary_test.rb +6 -2
  35. data/test/class_inheritable_attributes_test.rb +1 -1
  36. data/test/column_alias_test.rb +9 -2
  37. data/test/connections/native_oci/connection.rb +25 -0
  38. data/test/connections/native_sqlite/connection.rb +4 -1
  39. data/test/connections/native_sqlite3/connection.rb +4 -2
  40. data/test/deprecated_associations_test.rb +4 -5
  41. data/test/finder_test.rb +20 -4
  42. data/test/fixtures/db_definitions/create_oracle_db.bat +5 -0
  43. data/test/fixtures/db_definitions/create_oracle_db.sh +5 -0
  44. data/test/fixtures/db_definitions/db2.drop.sql +18 -0
  45. data/test/fixtures/db_definitions/db2.sql +1 -0
  46. data/test/fixtures/db_definitions/db22.drop.sql +2 -0
  47. data/test/fixtures/db_definitions/db22.sql +1 -0
  48. data/test/fixtures/db_definitions/drop_oracle_tables.sql +35 -0
  49. data/test/fixtures/db_definitions/drop_oracle_tables2.sql +3 -0
  50. data/test/fixtures/db_definitions/mysql.drop.sql +18 -0
  51. data/test/fixtures/db_definitions/mysql.sql +2 -1
  52. data/test/fixtures/db_definitions/mysql2.drop.sql +2 -0
  53. data/test/fixtures/db_definitions/mysql2.sql +1 -0
  54. data/test/fixtures/db_definitions/oci.drop.sql +18 -0
  55. data/test/fixtures/db_definitions/oci.sql +167 -0
  56. data/test/fixtures/db_definitions/oci2.drop.sql +2 -0
  57. data/test/fixtures/db_definitions/oci2.sql +6 -0
  58. data/test/fixtures/db_definitions/postgresql.drop.sql +18 -0
  59. data/test/fixtures/db_definitions/postgresql.sql +2 -1
  60. data/test/fixtures/db_definitions/postgresql2.drop.sql +2 -0
  61. data/test/fixtures/db_definitions/postgresql2.sql +2 -1
  62. data/test/fixtures/db_definitions/sqlite.drop.sql +18 -0
  63. data/test/fixtures/db_definitions/sqlite.sql +2 -1
  64. data/test/fixtures/db_definitions/sqlite2.drop.sql +2 -0
  65. data/test/fixtures/db_definitions/sqlite2.sql +1 -0
  66. data/test/fixtures/db_definitions/sqlserver.drop.sql +18 -0
  67. data/test/fixtures/db_definitions/sqlserver.sql +1 -0
  68. data/test/fixtures/db_definitions/sqlserver2.drop.sql +2 -0
  69. data/test/fixtures/db_definitions/sqlserver2.sql +1 -0
  70. data/test/fixtures/fixture_database.sqlite +0 -0
  71. data/test/fixtures/fixture_database_2.sqlite +0 -0
  72. data/test/fixtures/topics.yml +3 -3
  73. data/test/lifecycle_test.rb +0 -1
  74. data/test/modules_test.rb +0 -1
  75. data/test/reflection_test.rb +0 -1
  76. data/test/validations_test.rb +229 -41
  77. metadata +36 -28
  78. data/dev-utils/eval_debugger.rb +0 -14
  79. data/lib/active_record/support/binding_of_caller.rb +0 -83
  80. data/lib/active_record/support/breakpoint.rb +0 -518
  81. data/lib/active_record/support/class_attribute_accessors.rb +0 -57
  82. data/lib/active_record/support/class_inheritable_attributes.rb +0 -117
  83. data/lib/active_record/support/clean_logger.rb +0 -10
  84. data/lib/active_record/support/core_ext.rb +0 -1
  85. data/lib/active_record/support/core_ext/hash.rb +0 -5
  86. data/lib/active_record/support/core_ext/hash/keys.rb +0 -35
  87. data/lib/active_record/support/core_ext/numeric.rb +0 -7
  88. data/lib/active_record/support/core_ext/numeric/bytes.rb +0 -33
  89. data/lib/active_record/support/core_ext/numeric/time.rb +0 -59
  90. data/lib/active_record/support/core_ext/object_and_class.rb +0 -24
  91. data/lib/active_record/support/core_ext/string.rb +0 -5
  92. data/lib/active_record/support/core_ext/string/inflections.rb +0 -45
  93. data/lib/active_record/support/dependencies.rb +0 -63
  94. data/lib/active_record/support/inflector.rb +0 -84
  95. data/lib/active_record/support/misc.rb +0 -8
  96. data/lib/active_record/support/module_attribute_accessors.rb +0 -57
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  # A plugin framework for wrapping attribute values before they go in and unwrapping them after they go out of the database.
3
3
  # This was intended primarily for YAML wrapping of arrays and hashes, but this behavior is now native in the Base class.
4
- # So for now this framework is laying dorment until a need pops up.
4
+ # So for now this framework is laying dormant until a need pops up.
5
5
  module Wrappings #:nodoc:
6
6
  module ClassMethods #:nodoc:
7
7
  def wrap_with(wrapper, *attributes)
@@ -56,4 +56,4 @@ module ActiveRecord
56
56
  def unwrap(attribute) end
57
57
  end
58
58
  end
59
- end
59
+ end
data/rakefile CHANGED
@@ -8,7 +8,7 @@ require 'rake/contrib/rubyforgepublisher'
8
8
 
9
9
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
10
10
  PKG_NAME = 'activerecord'
11
- PKG_VERSION = '1.6.0' + PKG_BUILD
11
+ PKG_VERSION = '1.7.0' + PKG_BUILD
12
12
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13
13
 
14
14
  PKG_FILES = FileList[
@@ -63,6 +63,18 @@ Rake::TestTask.new("test_db2") { |t|
63
63
  t.verbose = true
64
64
  }
65
65
 
66
+ Rake::TestTask.new("test_oracle") { |t|
67
+ t.libs << "test" << "test/connections/native_oracle"
68
+ t.pattern = 'test/*_test.rb'
69
+ t.verbose = true
70
+ }
71
+
72
+ Rake::TestTask.new("test_oci") { |t|
73
+ t.libs << "test" << "test/connections/native_oci"
74
+ t.pattern = 'test/*_test.rb'
75
+ t.verbose = true
76
+ }
77
+
66
78
  # Generate the RDoc documentation
67
79
 
68
80
  Rake::RDocTask.new { |rdoc|
@@ -104,6 +116,9 @@ spec = Gem::Specification.new do |s|
104
116
  dist_dirs.each do |dir|
105
117
  s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
106
118
  end
119
+
120
+ s.add_dependency('activesupport', '= 1.0.0' + PKG_BUILD)
121
+
107
122
  s.files.delete "test/fixtures/fixture_database.sqlite"
108
123
  s.files.delete "test/fixtures/fixture_database_2.sqlite"
109
124
  s.files.delete "test/fixtures/fixture_database.sqlite3"
@@ -117,7 +132,7 @@ spec = Gem::Specification.new do |s|
117
132
 
118
133
  s.author = "David Heinemeier Hansson"
119
134
  s.email = "david@loudthinking.com"
120
- s.homepage = "http://www.rubyonrails.com"
135
+ s.homepage = "http://www.rubyonrails.org"
121
136
  s.rubyforge_project = "activerecord"
122
137
  end
123
138
 
@@ -0,0 +1,58 @@
1
+ require 'abstract_unit'
2
+
3
+ # The filename for this test begins with "aaa" so that
4
+ # it will be the first test.
5
+
6
+ class SqlFile < File
7
+ #Define an iterator that iterates over the statements in a .sql file.
8
+ #statements are separated by a semicolon.
9
+ def initialize(path)
10
+ super(path)
11
+ end
12
+
13
+ def each_statement()
14
+ statement = ''
15
+ each_line { |line|
16
+ #The last character of each line is a line-feed, so we will check the next-to-last character
17
+ #to see if it is a semicolon. A better way of doing this would be to look for a semicolon anywhere
18
+ #within the line in case multiple statements have been put on a single line.
19
+ #The last statement in the file must be followed by a line-feed.
20
+ if line.slice(-2,1)==';' then
21
+ statement = statement + line.slice(0,line.length-2) + "\n"
22
+ yield statement
23
+ statement = ''
24
+ else
25
+ statement = statement + line
26
+ end
27
+ }
28
+ end
29
+ end
30
+
31
+ class CreateTablesTest < Test::Unit::TestCase
32
+ def setup
33
+ # This method is required by rake.
34
+ end
35
+
36
+ def run_sql_file(connection, path)
37
+ sql_file = SqlFile.new(path)
38
+ sql_file.each_statement { |statement|
39
+ begin
40
+ #Skip errors. If there is a problem creating the tables then it will show up in other tests.
41
+ connection.execute(statement)
42
+ rescue ActiveRecord::StatementInvalid
43
+ end }
44
+ end
45
+
46
+ def test_table_creation
47
+ adapter_name = ActiveRecord::Base.connection.adapter_name.downcase
48
+ run_sql_file ActiveRecord::Base.connection, "test/fixtures/db_definitions/" + adapter_name + ".drop.sql"
49
+ run_sql_file ActiveRecord::Base.connection, "test/fixtures/db_definitions/" + adapter_name + ".sql"
50
+
51
+ # Now do the same thing with the connection used by multiple_db_test.rb
52
+ adapter_name = Course.retrieve_connection.adapter_name.downcase
53
+ run_sql_file Course.retrieve_connection, "test/fixtures/db_definitions/" + adapter_name + "2.drop.sql"
54
+ run_sql_file Course.retrieve_connection, "test/fixtures/db_definitions/" + adapter_name + "2.sql"
55
+
56
+ assert_equal 1,1
57
+ end
58
+ end
@@ -1,10 +1,11 @@
1
1
  $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ $:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
2
3
 
3
4
  require 'test/unit'
4
5
  require 'active_record'
5
6
  require 'active_record/fixtures'
6
- require 'active_record/support/binding_of_caller'
7
- require 'active_record/support/breakpoint'
7
+ require 'active_support/binding_of_caller'
8
+ require 'active_support/breakpoint'
8
9
  require 'connection'
9
10
 
10
11
  class Test::Unit::TestCase #:nodoc:
@@ -1,5 +1,4 @@
1
1
  require 'abstract_unit'
2
- # require File.dirname(__FILE__) + '/../dev-utils/eval_debugger'
3
2
  require 'fixtures/customer'
4
3
 
5
4
  class AggregationsTest < Test::Unit::TestCase
@@ -1,7 +1,6 @@
1
1
  require 'abstract_unit'
2
2
  require 'fixtures/developer'
3
3
  require 'fixtures/project'
4
- # require File.dirname(__FILE__) + '/../dev-utils/eval_debugger'
5
4
  require 'fixtures/company'
6
5
  require 'fixtures/topic'
7
6
  require 'fixtures/reply'
@@ -462,13 +461,13 @@ class HasManyAssociationsTest < Test::Unit::TestCase
462
461
 
463
462
  def test_deleting_type_mismatch
464
463
  david = Developer.find(1)
465
- david.projects.id
464
+ david.projects.reload
466
465
  assert_raises(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(1) }
467
466
  end
468
467
 
469
468
  def test_deleting_self_type_mismatch
470
469
  david = Developer.find(1)
471
- david.projects.id
470
+ david.projects.reload
472
471
  assert_raises(ActiveRecord::AssociationTypeMismatch) { david.projects.delete(Project.find(1).developers) }
473
472
  end
474
473
 
@@ -672,7 +671,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
672
671
 
673
672
  def test_adding_single
674
673
  jamis = Developer.find(2)
675
- jamis.projects.id # causing the collection to load
674
+ jamis.projects.reload # causing the collection to load
676
675
  action_controller = Project.find(2)
677
676
  assert_equal 1, jamis.projects.size
678
677
  assert_equal 1, action_controller.developers.size
@@ -693,7 +692,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
693
692
  def test_adding_from_the_project
694
693
  jamis = Developer.find(2)
695
694
  action_controller = Project.find(2)
696
- action_controller.developers.id
695
+ action_controller.developers.reload
697
696
  assert_equal 1, jamis.projects.size
698
697
  assert_equal 1, action_controller.developers.size
699
698
 
@@ -705,36 +704,36 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
705
704
  end
706
705
 
707
706
  def test_adding_multiple
708
- aridridel = Developer.new("name" => "Aridridel")
709
- aridridel.save
710
- aridridel.projects.id
711
- aridridel.projects.push(Project.find(1), Project.find(2))
712
- assert_equal 2, aridridel.projects.size
713
- assert_equal 2, aridridel.projects(true).size
707
+ aredridel = Developer.new("name" => "Aridridel")
708
+ aredridel.save
709
+ aredridel.projects.reload
710
+ aredridel.projects.push(Project.find(1), Project.find(2))
711
+ assert_equal 2, aredridel.projects.size
712
+ assert_equal 2, aredridel.projects(true).size
714
713
  end
715
714
 
716
715
  def test_adding_a_collection
717
- aridridel = Developer.new("name" => "Aridridel")
718
- aridridel.save
719
- aridridel.projects.id
720
- aridridel.projects.concat([Project.find(1), Project.find(2)])
721
- assert_equal 2, aridridel.projects.size
722
- assert_equal 2, aridridel.projects(true).size
716
+ aredridel = Developer.new("name" => "Aridridel")
717
+ aredridel.save
718
+ aredridel.projects.reload
719
+ aredridel.projects.concat([Project.find(1), Project.find(2)])
720
+ assert_equal 2, aredridel.projects.size
721
+ assert_equal 2, aredridel.projects(true).size
723
722
  end
724
723
 
725
724
  def test_habtm_adding_before_save
726
725
  no_of_devels = Developer.count
727
726
  no_of_projects = Project.count
728
- aridridel = Developer.new("name" => "Aridridel")
729
- aridridel.projects.concat([Project.find(1), p = Project.new("name" => "Projekt")])
730
- assert aridridel.new_record?
727
+ aredridel = Developer.new("name" => "Aridridel")
728
+ aredridel.projects.concat([Project.find(1), p = Project.new("name" => "Projekt")])
729
+ assert aredridel.new_record?
731
730
  assert p.new_record?
732
- assert aridridel.save
733
- assert !aridridel.new_record?
731
+ assert aredridel.save
732
+ assert !aredridel.new_record?
734
733
  assert_equal no_of_devels+1, Developer.count
735
734
  assert_equal no_of_projects+1, Project.count
736
- assert_equal 2, aridridel.projects.size
737
- assert_equal 2, aridridel.projects(true).size
735
+ assert_equal 2, aredridel.projects.size
736
+ assert_equal 2, aredridel.projects(true).size
738
737
  end
739
738
 
740
739
  def test_habtm_adding_before_save_with_join_attributes
@@ -791,7 +790,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
791
790
  def test_deleting
792
791
  david = Developer.find(1)
793
792
  active_record = Project.find(1)
794
- david.projects.id
793
+ david.projects.reload
795
794
  assert_equal 2, david.projects.size
796
795
  assert_equal 2, active_record.developers.size
797
796
 
@@ -804,7 +803,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
804
803
 
805
804
  def test_deleting_array
806
805
  david = Developer.find(1)
807
- david.projects.id
806
+ david.projects.reload
808
807
  david.projects.delete(Project.find_all)
809
808
  assert_equal 0, david.projects.size
810
809
  assert_equal 0, david.projects(true).size
@@ -812,7 +811,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
812
811
 
813
812
  def test_deleting_all
814
813
  david = Developer.find(1)
815
- david.projects.id
814
+ david.projects.reload
816
815
  david.projects.clear
817
816
  assert_equal 0, david.projects.size
818
817
  assert_equal 0, david.projects(true).size
@@ -829,7 +828,7 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
829
828
 
830
829
  def test_destroy_all
831
830
  david = Developer.find(1)
832
- david.projects.id
831
+ david.projects.reload
833
832
  assert !david.projects.empty?
834
833
  david.projects.destroy_all
835
834
  assert david.projects.empty?
@@ -176,6 +176,10 @@ class BasicsTest < Test::Unit::TestCase
176
176
  "The last_read attribute should be of the Date class"
177
177
  )
178
178
 
179
+ # Oracle does not have a TIME datatype.
180
+ if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
181
+ return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
182
+ end
179
183
  assert_kind_of(
180
184
  Time, Topic.find(1).bonus_time,
181
185
  "The bonus_time attribute should be of the Time class"
@@ -201,7 +205,7 @@ class BasicsTest < Test::Unit::TestCase
201
205
  end
202
206
 
203
207
  def test_record_not_found_exception
204
- assert_raises(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(id) }
208
+ assert_raises(ActiveRecord::RecordNotFound) { topicReloaded = Topic.find(99999) }
205
209
  end
206
210
 
207
211
  def test_initialize_with_attributes
@@ -381,6 +385,11 @@ class BasicsTest < Test::Unit::TestCase
381
385
  end
382
386
 
383
387
  def test_utc_as_time_zone
388
+ # Oracle does not have a TIME datatype.
389
+ if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
390
+ return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
391
+ end
392
+
384
393
  Topic.default_timezone = :utc
385
394
  attributes = { "bonus_time" => "5:42:00AM" }
386
395
  topic = Topic.find(1)
@@ -506,6 +515,11 @@ class BasicsTest < Test::Unit::TestCase
506
515
  end
507
516
 
508
517
  def test_attributes_on_dummy_time
518
+ # Oracle does not have a TIME datatype.
519
+ if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
520
+ return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
521
+ end
522
+
509
523
  attributes = {
510
524
  "bonus_time" => "5:42:00AM"
511
525
  }
@@ -543,6 +557,10 @@ class BasicsTest < Test::Unit::TestCase
543
557
  cloned_topic = topic.clone
544
558
  cloned_topic.title["a"] = "c"
545
559
  assert_equal "b", topic.title["a"]
560
+
561
+ cloned_topic.save
562
+ assert !cloned_topic.new_record?
563
+ assert cloned_topic.id != topic.id
546
564
  end
547
565
 
548
566
  def test_bignum
@@ -557,7 +575,7 @@ class BasicsTest < Test::Unit::TestCase
557
575
  if Default.connection.class.name == 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter'
558
576
  default = Default.new
559
577
 
560
- # dates / timestampts
578
+ # dates / timestamps
561
579
  time_format = "%m/%d/%Y %H:%M"
562
580
  assert_equal Time.now.strftime(time_format), default.modified_time.strftime(time_format)
563
581
  assert_equal Date.today, default.modified_date
@@ -688,4 +706,58 @@ class BasicsTest < Test::Unit::TestCase
688
706
  t2.reload
689
707
  assert_equal t1.title, t2.title
690
708
  end
709
+
710
+ def test_define_attr_method_with_value
711
+ k = Class.new( ActiveRecord::Base )
712
+ k.send(:define_attr_method, :table_name, "foo")
713
+ assert_equal "foo", k.table_name
714
+ end
715
+
716
+ def test_define_attr_method_with_block
717
+ k = Class.new( ActiveRecord::Base )
718
+ k.send(:define_attr_method, :primary_key) { "sys_" + original_primary_key }
719
+ assert_equal "sys_id", k.primary_key
720
+ end
721
+
722
+ def test_set_table_name_with_value
723
+ k = Class.new( ActiveRecord::Base )
724
+ k.table_name = "foo"
725
+ assert_equal "foo", k.table_name
726
+ k.set_table_name "bar"
727
+ assert_equal "bar", k.table_name
728
+ end
729
+
730
+ def test_set_table_name_with_block
731
+ k = Class.new( ActiveRecord::Base )
732
+ k.set_table_name { "ks" }
733
+ assert_equal "ks", k.table_name
734
+ end
735
+
736
+ def test_set_primary_key_with_value
737
+ k = Class.new( ActiveRecord::Base )
738
+ k.primary_key = "foo"
739
+ assert_equal "foo", k.primary_key
740
+ k.set_primary_key "bar"
741
+ assert_equal "bar", k.primary_key
742
+ end
743
+
744
+ def test_set_primary_key_with_block
745
+ k = Class.new( ActiveRecord::Base )
746
+ k.set_primary_key { "sys_" + original_primary_key }
747
+ assert_equal "sys_id", k.primary_key
748
+ end
749
+
750
+ def test_set_inheritance_column_with_value
751
+ k = Class.new( ActiveRecord::Base )
752
+ k.inheritance_column = "foo"
753
+ assert_equal "foo", k.inheritance_column
754
+ k.set_inheritance_column "bar"
755
+ assert_equal "bar", k.inheritance_column
756
+ end
757
+
758
+ def test_set_inheritance_column_with_block
759
+ k = Class.new( ActiveRecord::Base )
760
+ k.set_inheritance_column { original_inheritance_column + "_id" }
761
+ assert_equal "type_id", k.inheritance_column
762
+ end
691
763
  end
@@ -13,6 +13,10 @@ class BinaryTest < Test::Unit::TestCase
13
13
  if ActiveRecord::ConnectionAdapters.const_defined? :DB2Adapter
14
14
  return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::DB2Adapter)
15
15
  end
16
+
17
+ if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
18
+ return true if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
19
+ end
16
20
  bin = Binary.new
17
21
  bin.data = @data
18
22
 
@@ -27,10 +31,10 @@ class BinaryTest < Test::Unit::TestCase
27
31
  db_bin = Binary.find(bin.id)
28
32
 
29
33
  assert db_bin.data == bin.data,
30
- "Loaded binary data differes from memory version"
34
+ "Loaded binary data differs from memory version"
31
35
 
32
36
  assert db_bin.data == File.new(File.dirname(__FILE__)+"/fixtures/associations.png","rb").read,
33
- "Loaded binary data differes from file version"
37
+ "Loaded binary data differs from file version"
34
38
  end
35
39
 
36
40
  private
@@ -1,7 +1,7 @@
1
1
  $:.unshift(File.dirname(__FILE__) + '/../lib')
2
2
 
3
3
  require 'test/unit'
4
- require 'active_record/support/class_inheritable_attributes'
4
+ require 'active_support/class_inheritable_attributes'
5
5
 
6
6
  class A
7
7
  include ClassInheritableAttributes
@@ -5,8 +5,15 @@ class TestColumnAlias < Test::Unit::TestCase
5
5
 
6
6
  def test_column_alias
7
7
  topic = Topic.find(1)
8
- records = topic.connection.select_all("SELECT id AS pk FROM topics LIMIT 1")
9
- assert_equal(records[0].keys[0], "pk")
8
+ if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter
9
+ if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter)
10
+ records = topic.connection.select_all("SELECT id AS pk FROM topics WHERE ROWNUM < 2")
11
+ assert_equal(records[0].keys[0], "pk")
12
+ end
13
+ else
14
+ records = topic.connection.select_all("SELECT id AS pk FROM topics LIMIT 1")
15
+ assert_equal(records[0].keys[0], "pk")
16
+ end
10
17
  end
11
18
 
12
19
  end
@@ -0,0 +1,25 @@
1
+ print "Using OCI Oracle\n"
2
+ require 'fixtures/course'
3
+ require 'logger'
4
+
5
+ ActiveRecord::Base.logger = Logger.new STDOUT
6
+ ActiveRecord::Base.logger.level = Logger::WARN
7
+
8
+ db1 = 'activerecord_unittest'
9
+ db2 = 'activerecord_unittest2'
10
+
11
+ ActiveRecord::Base.establish_connection(
12
+ :adapter => 'oci',
13
+ :host => '', # can use an oracle SID
14
+ :username => 'arunit',
15
+ :password => 'arunit',
16
+ :database => db1
17
+ )
18
+
19
+ Course.establish_connection(
20
+ :adapter => 'oci',
21
+ :host => '', # can use an oracle SID
22
+ :username => 'arunit2',
23
+ :password => 'arunit2',
24
+ :database => db2
25
+ )