activerecord-jdbc-adapter 1.2.5 → 1.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +5 -1
  3. data/Appraisals +5 -5
  4. data/Gemfile +9 -1
  5. data/Gemfile.lock +44 -10
  6. data/History.txt +126 -2
  7. data/README.md +246 -0
  8. data/Rakefile +34 -25
  9. data/activerecord-jdbc-adapter.gemspec +1 -1
  10. data/gemfiles/rails23.gemfile +5 -3
  11. data/gemfiles/rails23.gemfile.lock +26 -18
  12. data/gemfiles/rails30.gemfile +4 -2
  13. data/gemfiles/rails30.gemfile.lock +16 -8
  14. data/gemfiles/rails31.gemfile +4 -2
  15. data/gemfiles/rails31.gemfile.lock +16 -9
  16. data/gemfiles/rails32.gemfile +4 -2
  17. data/gemfiles/rails32.gemfile.lock +15 -8
  18. data/lib/active_record/connection_adapters/db2_adapter.rb +1 -0
  19. data/lib/arel/visitors/sql_server.rb +3 -0
  20. data/lib/arjdbc.rb +3 -5
  21. data/lib/arjdbc/db2.rb +1 -0
  22. data/lib/arjdbc/db2/adapter.rb +302 -196
  23. data/lib/arjdbc/db2/connection_methods.rb +18 -0
  24. data/lib/arjdbc/derby/active_record_patch.rb +12 -0
  25. data/lib/arjdbc/derby/adapter.rb +180 -158
  26. data/lib/arjdbc/derby/connection_methods.rb +5 -1
  27. data/lib/arjdbc/firebird/adapter.rb +27 -19
  28. data/lib/arjdbc/h2/adapter.rb +162 -7
  29. data/lib/arjdbc/h2/connection_methods.rb +5 -1
  30. data/lib/arjdbc/hsqldb.rb +1 -1
  31. data/lib/arjdbc/hsqldb/adapter.rb +96 -61
  32. data/lib/arjdbc/hsqldb/connection_methods.rb +5 -1
  33. data/lib/arjdbc/hsqldb/explain_support.rb +35 -0
  34. data/lib/arjdbc/informix/adapter.rb +56 -55
  35. data/lib/arjdbc/jdbc/adapter.rb +173 -86
  36. data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
  37. data/lib/arjdbc/jdbc/column.rb +28 -23
  38. data/lib/arjdbc/jdbc/connection.rb +10 -6
  39. data/lib/arjdbc/jdbc/driver.rb +13 -5
  40. data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +21 -0
  41. data/lib/arjdbc/mssql.rb +1 -1
  42. data/lib/arjdbc/mssql/adapter.rb +51 -53
  43. data/lib/arjdbc/mssql/connection_methods.rb +8 -1
  44. data/lib/arjdbc/mysql.rb +1 -1
  45. data/lib/arjdbc/mysql/adapter.rb +186 -150
  46. data/lib/arjdbc/mysql/connection_methods.rb +9 -9
  47. data/lib/arjdbc/mysql/explain_support.rb +85 -0
  48. data/lib/arjdbc/oracle.rb +1 -1
  49. data/lib/arjdbc/oracle/adapter.rb +232 -125
  50. data/lib/arjdbc/oracle/connection_methods.rb +2 -2
  51. data/lib/arjdbc/postgresql.rb +1 -1
  52. data/lib/arjdbc/postgresql/adapter.rb +134 -86
  53. data/lib/arjdbc/postgresql/connection_methods.rb +6 -4
  54. data/lib/arjdbc/postgresql/explain_support.rb +55 -0
  55. data/lib/arjdbc/sqlite3.rb +1 -1
  56. data/lib/arjdbc/sqlite3/adapter.rb +176 -108
  57. data/lib/arjdbc/sqlite3/connection_methods.rb +5 -5
  58. data/lib/arjdbc/sqlite3/explain_support.rb +32 -0
  59. data/lib/arjdbc/sybase/adapter.rb +7 -6
  60. data/lib/arjdbc/version.rb +1 -1
  61. data/pom.xml +1 -1
  62. data/rakelib/02-test.rake +9 -11
  63. data/rakelib/rails.rake +18 -10
  64. data/src/java/arjdbc/db2/DB2Module.java +70 -0
  65. data/src/java/arjdbc/derby/DerbyModule.java +24 -5
  66. data/src/java/arjdbc/hsqldb/HSQLDBModule.java +66 -0
  67. data/src/java/arjdbc/jdbc/AdapterJavaService.java +14 -7
  68. data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +111 -89
  69. data/src/java/arjdbc/mysql/MySQLModule.java +79 -70
  70. data/src/java/arjdbc/oracle/OracleModule.java +74 -0
  71. data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +5 -10
  72. data/src/java/arjdbc/sqlite3/SQLite3Module.java +77 -0
  73. data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +127 -0
  74. data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +25 -111
  75. data/src/java/arjdbc/util/QuotingUtils.java +104 -0
  76. data/test/abstract_db_create.rb +6 -6
  77. data/test/activerecord/connection_adapters/type_conversion_test.rb +2 -2
  78. data/test/assets/flowers.jpg +0 -0
  79. data/test/binary.rb +67 -0
  80. data/test/db/db2.rb +30 -7
  81. data/test/db/jdbc.rb +4 -2
  82. data/test/db/oracle.rb +18 -27
  83. data/test/db2_binary_test.rb +6 -0
  84. data/test/db2_serialize_test.rb +6 -0
  85. data/test/db2_simple_test.rb +20 -25
  86. data/test/db2_test.rb +71 -0
  87. data/test/derby_binary_test.rb +6 -0
  88. data/test/derby_migration_test.rb +42 -35
  89. data/test/derby_reset_column_information_test.rb +1 -0
  90. data/test/derby_row_locking_test.rb +17 -0
  91. data/test/derby_schema_dump_test.rb +9 -0
  92. data/test/derby_serialize_test.rb +6 -0
  93. data/test/derby_simple_test.rb +59 -17
  94. data/test/generic_jdbc_connection_test.rb +112 -5
  95. data/test/h2_binary_test.rb +6 -0
  96. data/test/h2_change_column_test.rb +1 -1
  97. data/test/h2_schema_dump_test.rb +25 -0
  98. data/test/h2_serialize_test.rb +6 -0
  99. data/test/h2_simple_test.rb +23 -9
  100. data/test/has_many_through.rb +18 -4
  101. data/test/hsqldb_binary_test.rb +6 -0
  102. data/test/hsqldb_schema_dump_test.rb +15 -0
  103. data/test/hsqldb_serialize_test.rb +6 -0
  104. data/test/hsqldb_simple_test.rb +1 -0
  105. data/test/informix_simple_test.rb +1 -1
  106. data/test/jdbc/db2.rb +23 -0
  107. data/test/jdbc/oracle.rb +23 -0
  108. data/test/jdbc_common.rb +3 -110
  109. data/test/jndi_callbacks_test.rb +0 -2
  110. data/test/jndi_test.rb +2 -0
  111. data/test/models/binary.rb +18 -0
  112. data/test/models/custom_pk_name.rb +1 -0
  113. data/test/models/data_types.rb +11 -2
  114. data/test/models/entry.rb +1 -1
  115. data/test/models/string_id.rb +2 -2
  116. data/test/models/thing.rb +1 -1
  117. data/test/models/topic.rb +32 -0
  118. data/test/mssql_legacy_types_test.rb +1 -1
  119. data/test/mssql_limit_offset_test.rb +13 -3
  120. data/test/mssql_serialize_test.rb +6 -0
  121. data/test/mysql_binary_test.rb +6 -0
  122. data/test/mysql_schema_dump_test.rb +220 -0
  123. data/test/mysql_serialize_test.rb +6 -0
  124. data/test/mysql_simple_test.rb +22 -2
  125. data/test/mysql_test.rb +93 -0
  126. data/test/oracle_binary_test.rb +6 -0
  127. data/test/oracle_limit_test.rb +2 -1
  128. data/test/oracle_serialize_test.rb +6 -0
  129. data/test/oracle_simple_test.rb +61 -0
  130. data/test/oracle_specific_test.rb +77 -26
  131. data/test/postgres_binary_test.rb +6 -0
  132. data/test/postgres_native_type_mapping_test.rb +12 -11
  133. data/test/postgres_nonseq_pkey_test.rb +1 -0
  134. data/test/postgres_reserved_test.rb +1 -0
  135. data/test/postgres_reset_column_information_test.rb +1 -0
  136. data/test/postgres_row_locking_test.rb +21 -0
  137. data/test/postgres_schema_dump_test.rb +88 -0
  138. data/test/postgres_schema_search_path_test.rb +1 -0
  139. data/test/postgres_simple_test.rb +62 -89
  140. data/test/postgres_table_alias_length_test.rb +1 -0
  141. data/test/postgres_test.rb +31 -0
  142. data/test/postgres_type_conversion_test.rb +16 -16
  143. data/test/row_locking.rb +69 -64
  144. data/test/schema_dump.rb +168 -0
  145. data/test/serialize.rb +277 -0
  146. data/test/simple.rb +326 -122
  147. data/test/sqlite3_serialize_test.rb +6 -0
  148. data/test/sqlite3_simple_test.rb +51 -84
  149. data/test/sqlite3_type_conversion_test.rb +101 -0
  150. data/test/test_helper.rb +224 -0
  151. metadata +325 -366
  152. data/README.rdoc +0 -214
  153. data/test/db/logger.rb +0 -3
  154. data/test/derby_multibyte_test.rb +0 -11
  155. data/test/mysql_info_test.rb +0 -123
@@ -0,0 +1,6 @@
1
+ require 'db/h2'
2
+ require 'binary'
3
+
4
+ class H2BinaryTest < Test::Unit::TestCase
5
+ include BinaryTestMethods
6
+ end
@@ -52,7 +52,7 @@ class H2ChangeColumnTest < Test::Unit::TestCase
52
52
  def test_should_set_non_null_restriction
53
53
  ActiveRecord::Migration.change_column :people, :phone, :string, :null => false
54
54
  Person.reset_column_information
55
- assert_raises(ActiveRecord::StatementInvalid) { Person.create! }
55
+ assert_raise(ActiveRecord::StatementInvalid) { Person.create! }
56
56
  end
57
57
 
58
58
  def test_should_set_null_restriction_with_default
@@ -0,0 +1,25 @@
1
+ require 'db/h2'
2
+ require 'schema_dump'
3
+
4
+ class H2SchemaDumpTest < Test::Unit::TestCase
5
+ include SchemaDumpTestMethods
6
+
7
+ DbTypeMigration.big_decimal_precision = 56 # whatever - arbitrary
8
+
9
+ # # #override
10
+ # def test_schema_dump_keeps_id_column_when_id_is_false_and_id_column_added
11
+ # output = standard_dump
12
+ # match = output.match(%r{create_table "string_ids"(.*)do.*\n(.*)\n})
13
+ # assert_not_nil(match, "string_ids table not found")
14
+ # assert_match %r(:id => false), match[1], "no table id not preserved"
15
+ # # t.string \"id\", :limit => 2147483647, :null => false
16
+ # assert_match %r{t.string[[:space:]]+"id",.+?:null => false$}, match[2], "non-primary key id column not preserved"
17
+ # end
18
+
19
+ def test_schema_dump_decimal_when_scale_specified
20
+ output = standard_dump(StringIO.new, [/^[^d]/]) # keep db_types
21
+ # t.column :sample_small_decimal, :decimal, :precision => 3, :scale => 2, :default => 3.14
22
+ assert_match %r{t.decimal\s+"sample_small_decimal",\s+:precision => 3,\s+:scale => 2}, output
23
+ end
24
+
25
+ end
@@ -0,0 +1,6 @@
1
+ require 'db/h2'
2
+ require 'serialize'
3
+
4
+ class H2SerializeTest < Test::Unit::TestCase
5
+ include SerializeTestMethods
6
+ end
@@ -1,11 +1,21 @@
1
1
  require 'jdbc_common'
2
+ require 'db/h2'
2
3
 
3
4
  class H2SimpleTest < Test::Unit::TestCase
4
5
  include SimpleTestMethods
6
+ include ExplainSupportTestMethods if ar_version("3.1")
7
+ end
8
+
9
+ class H2HasManyThroughTest < Test::Unit::TestCase
10
+ include HasManyThroughMethods
5
11
  end
6
12
 
7
13
  class H2SchemaTest < Test::Unit::TestCase
14
+
8
15
  def setup
16
+ @entry_table_name, @user_table_name = Entry.table_name, User.table_name
17
+ @current_schema = ActiveRecord::Base.connection.current_schema
18
+
9
19
  @connection = ActiveRecord::Base.connection
10
20
  @connection.execute("create schema s1");
11
21
  @connection.execute("set schema s1");
@@ -14,8 +24,9 @@ class H2SchemaTest < Test::Unit::TestCase
14
24
  @connection.execute("set schema s2");
15
25
  CreateUsers.up
16
26
  @connection.execute("set schema public");
17
- Entry.table_name = 's1.entries'
18
- User.table_name = 's2.users'
27
+
28
+ Entry.table_name = 's1.entries'; User.table_name = 's2.users'
29
+
19
30
  user = User.create! :login => "something"
20
31
  Entry.create! :title => "title", :content => "content", :rating => 123.45, :user => user
21
32
  end
@@ -28,13 +39,16 @@ class H2SchemaTest < Test::Unit::TestCase
28
39
  @connection.execute("drop schema s1");
29
40
  @connection.execute("drop schema s2");
30
41
  @connection.execute("set schema public");
31
- Entry.reset_table_name
32
- Entry.reset_column_information
33
- User.reset_table_name
34
- User.reset_column_information
42
+
43
+ Entry.reset_column_information; User.reset_column_information
44
+ Entry.table_name, User.table_name = @entry_table_name, @user_table_name
45
+
46
+ ActiveRecord::Base.clear_active_connections!
35
47
  end
36
-
48
+
37
49
  def test_find_in_other_schema
38
- assert !Entry.all(:include => :user).empty?
50
+ all = Entry.all(:include => :user)
51
+ assert ! all.empty?, "expected `Entry.all(:include => :user)` to not be empty but was"
39
52
  end
40
- end
53
+
54
+ end
@@ -11,8 +11,8 @@ class CreateRbac < ActiveRecord::Migration
11
11
  end
12
12
 
13
13
  create_table :permission_groups do |t|
14
- t.column :right_id, :integer
15
- t.column :role_id, :integer
14
+ t.column :right_id, :integer, :null => false
15
+ t.column :role_id, :integer, :null => false
16
16
  end
17
17
 
18
18
  create_table :rights do |t|
@@ -40,6 +40,10 @@ class Role < ActiveRecord::Base
40
40
  has_many :permission_groups, :dependent => :destroy
41
41
  has_many :rights, :through => :permission_groups
42
42
  has_many :role_assignments, :dependent => :destroy
43
+
44
+ def has_right?(right)
45
+ rights.include? right
46
+ end
43
47
  end
44
48
 
45
49
  class PermissionGroup < ActiveRecord::Base
@@ -63,7 +67,7 @@ module HasManyThroughMethods
63
67
 
64
68
  def test_has_many_through
65
69
  admin_role = Role.create( {:name => "Administrator", :description => "System defined super user - access to right and role management."} )
66
- admin_role.save
70
+ admin_role.save!
67
71
 
68
72
  assert_equal(0, admin_role.rights.sum(:hours))
69
73
 
@@ -72,8 +76,18 @@ module HasManyThroughMethods
72
76
 
73
77
  admin_role.rights << role_rights
74
78
  admin_role.rights << right_rights
75
- admin_role.save
79
+ admin_role.save!
76
80
 
77
81
  assert_equal(1.5, admin_role.rights.sum(:hours))
82
+
83
+ rights_only_role = Role.create!(:name => "Rights Manager", :description => "access to rights management")
84
+ rights_only_role.rights << right_rights
85
+ rights_only_role.save!
86
+ rights_only_role.reload
87
+
88
+ assert admin_role.has_right?(right_rights)
89
+ assert rights_only_role.has_right?(right_rights)
90
+ assert admin_role.reload.has_right?(role_rights)
91
+ assert ! rights_only_role.has_right?(role_rights)
78
92
  end
79
93
  end
@@ -0,0 +1,6 @@
1
+ require 'db/hsqldb'
2
+ require 'binary'
3
+
4
+ class HSQLDBBinaryTest < Test::Unit::TestCase
5
+ include BinaryTestMethods
6
+ end
@@ -0,0 +1,15 @@
1
+ require 'db/hsqldb'
2
+ require 'schema_dump'
3
+
4
+ class HSQLDBSchemaDumpTest < Test::Unit::TestCase
5
+ include SchemaDumpTestMethods
6
+
7
+ DbTypeMigration.big_decimal_precision = 42 # whatever - arbitrary
8
+
9
+ def test_schema_dump_decimal_when_scale_specified
10
+ output = standard_dump(StringIO.new, [/^[^d]/]) # keep db_types
11
+ # t.column :sample_small_decimal, :decimal, :precision => 3, :scale => 2, :default => 3.14
12
+ assert_match %r{t.decimal\s+"sample_small_decimal",\s+:precision => 3,\s+:scale => 2}, output
13
+ end
14
+
15
+ end
@@ -0,0 +1,6 @@
1
+ require 'db/hsqldb'
2
+ require 'serialize'
3
+
4
+ class HSQLDBSerializeTest < Test::Unit::TestCase
5
+ include SerializeTestMethods
6
+ end
@@ -3,4 +3,5 @@ require 'db/hsqldb'
3
3
 
4
4
  class HsqldbSimpleTest < Test::Unit::TestCase
5
5
  include SimpleTestMethods
6
+ include ExplainSupportTestMethods if ar_version("3.1")
6
7
  end
@@ -36,7 +36,7 @@ class InformixMultibyteTest < Test::Unit::TestCase
36
36
  # simple insert in Informix.
37
37
  def test_select_multibyte_string
38
38
  Entry.create!(:title => 'テスト', :content => '本文')
39
- entry = Entry.find(:first)
39
+ entry = Entry.first
40
40
  assert_equal "テスト", entry.title
41
41
  assert_equal "本文", entry.content
42
42
  assert_equal entry, Entry.find_by_title("テスト")
@@ -0,0 +1,23 @@
1
+ module Jdbc
2
+ module DB2
3
+ def self.driver_jar
4
+ if const_defined?(:VERSION)
5
+ "db2jcc-#{VERSION}.jar"
6
+ else
7
+ "db2jcc4.jar"
8
+ end
9
+ end
10
+
11
+ def self.load_driver(method = :load)
12
+ send method, driver_jar
13
+ end
14
+
15
+ def self.driver_name
16
+ 'com.ibm.db2.jcc.DB2Driver'
17
+ end
18
+ end
19
+ end
20
+
21
+ # NOTE: just put the db2jcc4.jar into the test/jars directory ...
22
+ jars = File.expand_path('../jars', File.dirname(__FILE__))
23
+ $LOAD_PATH << jars unless $LOAD_PATH.include?(jars)
@@ -0,0 +1,23 @@
1
+ module Jdbc
2
+ module Oracle
3
+ def self.driver_jar
4
+ if const_defined?(:VERSION)
5
+ "ojdbc-#{VERSION}.jar"
6
+ else
7
+ "ojdbc6.jar"
8
+ end
9
+ end
10
+
11
+ def self.load_driver(method = :load)
12
+ send method, driver_jar
13
+ end
14
+
15
+ def self.driver_name
16
+ 'oracle.jdbc.driver.OracleDriver'
17
+ end
18
+ end
19
+ end
20
+
21
+ # NOTE: just put the ojdbc6.jar into the test/jars directory ...
22
+ jars = File.expand_path('../jars', File.dirname(__FILE__))
23
+ $LOAD_PATH << jars unless $LOAD_PATH.include?(jars)
@@ -1,12 +1,7 @@
1
1
  # Simple method to reduce the boilerplate
2
- def jruby?
3
- defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
4
- end
5
2
 
6
- require 'bundler'
7
- Bundler.require(:default, :test)
8
- require 'arjdbc' if jruby?
9
- puts "Using activerecord version #{ActiveRecord::VERSION::STRING}"
3
+ require 'test_helper'
4
+
10
5
  require 'models/auto_id'
11
6
  require 'models/entry'
12
7
  require 'models/data_types'
@@ -15,109 +10,7 @@ require 'models/validates_uniqueness_of_string'
15
10
  require 'models/string_id'
16
11
  require 'models/thing'
17
12
  require 'models/custom_pk_name'
13
+
18
14
  require 'simple'
19
15
  require 'has_many_through'
20
- require 'helper'
21
16
  require 'row_locking'
22
- require 'test/unit'
23
- require 'logger'
24
-
25
- # we always require logger (some tests fail if ActiveRecord::Base.logger is nil), but level
26
- # is set to warn unless $DEBUG or ENV['DEBUG'] is set
27
- require 'db/logger'
28
- if $DEBUG || ENV['DEBUG']
29
- require 'ruby-debug'
30
- end
31
-
32
- # assert_queries and SQLCounter taken from rails active_record tests
33
- class Test::Unit::TestCase
34
- def assert_queries(num = 1, matching = nil)
35
- if !ActiveRecord::SQLCounter.enabled?
36
- warn "SQLCounter assert_queries skipped"
37
- return
38
- end
39
-
40
- ActiveRecord::SQLCounter.log = []
41
- yield
42
- ensure
43
- queries = nil
44
- ActiveRecord::SQLCounter.log.tap {|log| queries = (matching ? log.select {|s| s =~ matching } : log) }
45
- assert_equal num, queries.size, "#{queries.size} instead of #{num} queries were executed.#{queries.size == 0 ? '' : "\nQueries:\n#{queries.join("\n")}"}"
46
- end
47
-
48
- def self.ar_version(version)
49
- match = version.match(/(\d+)\.(\d+)(?:\.(\d+))?/)
50
- ActiveRecord::VERSION::MAJOR > match[1].to_i ||
51
- (ActiveRecord::VERSION::MAJOR == match[1].to_i &&
52
- ActiveRecord::VERSION::MINOR >= match[2].to_i)
53
- end
54
- end
55
-
56
- module ActiveRecord
57
- class SQLCounter
58
- @@enabled = true
59
- def self.enabled?
60
- @@enabled
61
- end
62
-
63
- def self.ignored_sql
64
- @@ignored_sql
65
- end
66
-
67
- def self.ignored_sql=(value)
68
- @@ignored_sql = value
69
- end
70
-
71
- self.ignored_sql = [
72
- /^PRAGMA (?!(table_info))/,
73
- /^SELECT currval/,
74
- /^SELECT CAST/,
75
- /^SELECT @@IDENTITY/,
76
- /^SELECT @@ROWCOUNT/,
77
- /^SAVEPOINT/,
78
- /^ROLLBACK TO SAVEPOINT/,
79
- /^RELEASE SAVEPOINT/,
80
- /^SHOW max_identifier_length/,
81
- /^BEGIN/,
82
- /^COMMIT/
83
- ]
84
-
85
- # FIXME: this needs to be refactored so specific database can add their own
86
- # ignored SQL. This ignored SQL is for Oracle.
87
- ignored_sql.concat [/^select .*nextval/i,
88
- /^SAVEPOINT/,
89
- /^ROLLBACK TO/,
90
- /^\s*select .* from all_triggers/im
91
- ]
92
-
93
- def self.log=(v)
94
- @@log = v
95
- end
96
-
97
- def self.log
98
- @@log
99
- end
100
-
101
- self.log = []
102
-
103
- def call(name, start, finish, message_id, values)
104
- sql = values[:sql]
105
-
106
- # FIXME: this seems bad. we should probably have a better way to indicate
107
- # the query was cached
108
- unless 'CACHE' == values[:name]
109
- self.class.log << sql unless self.class.ignored_sql.
110
- any? { |r| sql =~ r }
111
- end
112
- end
113
- end
114
-
115
- begin
116
- require 'active_support/notifications'
117
- ActiveSupport::Notifications.subscribe('sql.active_record', SQLCounter.new)
118
- rescue LoadError
119
- @@enabled = false
120
- end
121
- end
122
-
123
-
@@ -1,8 +1,6 @@
1
1
  require 'jdbc_common'
2
2
  require 'db/jndi_config'
3
3
 
4
- require 'mocha'
5
-
6
4
  class JndiConnectionPoolCallbacksTest < Test::Unit::TestCase
7
5
 
8
6
  def self.startup
@@ -38,6 +38,8 @@ require 'db/jndi_pooled_config'
38
38
  class DerbyJndiPooledTest < Test::Unit::TestCase
39
39
  include SimpleTestMethods
40
40
 
41
+ DbTypeMigration.big_decimal_precision = 31
42
+
41
43
  def self.startup
42
44
  ActiveRecord::Base.establish_connection JNDI_POOLED_CONFIG
43
45
  end
@@ -0,0 +1,18 @@
1
+ class Binary < ActiveRecord::Base
2
+ end
3
+
4
+ class BinaryMigration < ActiveRecord::Migration
5
+
6
+ def self.up
7
+ create_table :binaries, :force => true do |t|
8
+ t.string :name
9
+ t.binary :data
10
+ t.binary :short_data, :limit => 2048
11
+ end
12
+ end
13
+
14
+ def self.down
15
+ drop_table :binaries
16
+ end
17
+
18
+ end
@@ -9,6 +9,7 @@ class CreateCustomPkName < ActiveRecord::Migration
9
9
  drop_table :custom_pk_names
10
10
  end
11
11
  end
12
+
12
13
  class CustomPkName < ActiveRecord::Base
13
14
  self.primary_key = "custom_id"
14
15
  end
@@ -1,12 +1,20 @@
1
1
  class DbTypeMigration < ActiveRecord::Migration
2
+
3
+ # Oracle/SQLServer supports precision up to 38
4
+ @@big_decimal_precision = 38
5
+
6
+ def self.big_decimal_precision; @@big_decimal_precision; end
7
+ def self.big_decimal_precision=(precision); @@big_decimal_precision = precision; end
8
+
2
9
  def self.up
3
10
  create_table "db_types", :force => true do |t|
4
11
  t.column :sample_timestamp, :timestamp
5
12
  t.column :sample_datetime, :datetime
6
13
  t.column :sample_date, :date
7
14
  t.column :sample_time, :time
8
- t.column :sample_decimal, :decimal, :precision => 15, :scale => 0
9
- t.column :sample_small_decimal, :decimal, :precision => 3, :scale => 2
15
+ # NOTE: on purpose setup so that it's OK to use a 32-bit integer column :
16
+ t.column :sample_decimal, :decimal, :precision => 9, :scale => 0
17
+ t.column :sample_small_decimal, :decimal, :precision => 3, :scale => 2, :default => 3.14
10
18
  t.column :sample_default_decimal, :decimal
11
19
  t.column :sample_float, :float
12
20
  t.column :sample_binary, :binary
@@ -18,6 +26,7 @@ class DbTypeMigration < ActiveRecord::Migration
18
26
  t.column :sample_integer_no_limit, :integer
19
27
  t.column :sample_integer_neg_default, :integer, :default => -1
20
28
  t.column :sample_text, :text
29
+ t.decimal :big_decimal, :precision => big_decimal_precision, :scale => 0
21
30
  end
22
31
  end
23
32