activerecord-jdbc-adapter 1.2.9.1 → 1.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Appraisals +12 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +19 -19
- data/History.txt +90 -16
- data/LICENSE.txt +2 -1
- data/README.md +14 -1
- data/activerecord-jdbc-adapter.gemspec +2 -2
- data/gemfiles/rails23.gemfile +5 -5
- data/gemfiles/rails23.gemfile.lock +27 -27
- data/gemfiles/rails30.gemfile +3 -3
- data/gemfiles/rails30.gemfile.lock +8 -8
- data/gemfiles/rails31.gemfile +4 -4
- data/gemfiles/rails31.gemfile.lock +18 -18
- data/gemfiles/rails32.gemfile +4 -4
- data/gemfiles/rails32.gemfile.lock +17 -17
- data/gemfiles/rails40.gemfile +17 -0
- data/gemfiles/rails40.gemfile.lock +126 -0
- data/lib/activerecord-jdbc-adapter.rb +0 -7
- data/lib/arjdbc.rb +6 -5
- data/lib/arjdbc/db2.rb +1 -1
- data/lib/arjdbc/db2/adapter.rb +52 -29
- data/lib/arjdbc/db2/connection_methods.rb +13 -14
- data/lib/arjdbc/derby.rb +1 -1
- data/lib/arjdbc/derby/adapter.rb +29 -9
- data/lib/arjdbc/derby/connection_methods.rb +17 -20
- data/lib/arjdbc/firebird.rb +1 -1
- data/lib/arjdbc/h2.rb +2 -2
- data/lib/arjdbc/h2/adapter.rb +1 -1
- data/lib/arjdbc/h2/connection_methods.rb +12 -16
- data/lib/arjdbc/hsqldb.rb +1 -1
- data/lib/arjdbc/hsqldb/connection_methods.rb +13 -16
- data/lib/arjdbc/informix.rb +1 -1
- data/lib/arjdbc/informix/connection_methods.rb +8 -10
- data/lib/arjdbc/jdbc.rb +1 -1
- data/lib/arjdbc/jdbc/adapter.rb +125 -53
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/base_ext.rb +34 -9
- data/lib/arjdbc/jdbc/column.rb +15 -2
- data/lib/arjdbc/jdbc/connection.rb +0 -2
- data/lib/arjdbc/jdbc/connection_methods.rb +10 -3
- data/lib/arjdbc/jdbc/driver.rb +2 -2
- data/lib/arjdbc/jdbc/extension.rb +35 -21
- data/lib/arjdbc/jdbc/java.rb +0 -2
- data/lib/arjdbc/jdbc/missing_functionality_helper.rb +35 -25
- data/lib/arjdbc/jdbc/railtie.rb +2 -9
- data/lib/arjdbc/mimer.rb +1 -1
- data/lib/arjdbc/mssql.rb +2 -2
- data/lib/arjdbc/mssql/adapter.rb +271 -92
- data/lib/arjdbc/mssql/connection_methods.rb +30 -32
- data/lib/arjdbc/mssql/explain_support.rb +107 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +48 -18
- data/lib/arjdbc/mysql.rb +1 -1
- data/lib/arjdbc/mysql/adapter.rb +63 -14
- data/lib/arjdbc/mysql/connection_methods.rb +22 -24
- data/lib/arjdbc/mysql/explain_support.rb +2 -5
- data/lib/arjdbc/oracle.rb +1 -1
- data/lib/arjdbc/oracle/adapter.rb +78 -38
- data/lib/arjdbc/oracle/connection_methods.rb +9 -10
- data/lib/arjdbc/postgresql.rb +1 -1
- data/lib/arjdbc/postgresql/adapter.rb +964 -380
- data/lib/arjdbc/postgresql/column_cast.rb +136 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +19 -21
- data/lib/arjdbc/postgresql/explain_support.rb +3 -6
- data/lib/arjdbc/railtie.rb +9 -0
- data/lib/arjdbc/sqlite3.rb +1 -1
- data/lib/arjdbc/sqlite3/adapter.rb +73 -26
- data/lib/arjdbc/sqlite3/connection_methods.rb +27 -28
- data/lib/arjdbc/sqlite3/explain_support.rb +2 -5
- data/lib/arjdbc/sybase.rb +1 -1
- data/lib/arjdbc/version.rb +5 -4
- data/pom.xml +8 -0
- data/rakelib/02-test.rake +57 -51
- data/rakelib/compile.rake +17 -5
- data/rakelib/rails.rake +42 -31
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +4 -3
- data/src/java/arjdbc/derby/DerbyModule.java +98 -85
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +70 -0
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +0 -4
- data/src/java/arjdbc/jdbc/AdapterJavaService.java +26 -15
- data/src/java/arjdbc/jdbc/Callable.java +44 -0
- data/src/java/arjdbc/jdbc/JdbcConnectionFactory.java +10 -2
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1675 -834
- data/src/java/arjdbc/jdbc/SQLBlock.java +9 -3
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +73 -36
- data/src/java/arjdbc/mysql/MySQLModule.java +11 -10
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +86 -80
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +27 -7
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +214 -0
- data/src/java/arjdbc/postgresql/PostgresqlRubyJdbcConnection.java +25 -67
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +52 -49
- data/src/java/arjdbc/util/QuotingUtils.java +6 -6
- data/test/abstract_db_create.rb +11 -11
- data/test/activerecord/connection_adapters/type_conversion_test.rb +18 -12
- data/test/db/db2.rb +1 -1
- data/test/{db2_binary_test.rb → db/db2/binary_test.rb} +0 -0
- data/test/db/db2/has_many_through_test.rb +6 -0
- data/test/{db2_reset_column_information_test.rb → db/db2/reset_column_information_test.rb} +1 -2
- data/test/{db2_serialize_test.rb → db/db2/serialize_test.rb} +0 -0
- data/test/{db2_simple_test.rb → db/db2/simple_test.rb} +1 -8
- data/test/db/db2/test_helper.rb +6 -0
- data/test/{db2_test.rb → db/db2/unit_test.rb} +1 -1
- data/test/db/derby.rb +1 -1
- data/test/{derby_binary_test.rb → db/derby/binary_test.rb} +0 -0
- data/test/{derby_migration_test.rb → db/derby/migration_test.rb} +0 -0
- data/test/{derby_reset_column_information_test.rb → db/derby/reset_column_information_test.rb} +0 -0
- data/test/{derby_row_locking_test.rb → db/derby/row_locking_test.rb} +1 -4
- data/test/db/derby/schema_dump_test.rb +5 -0
- data/test/{derby_serialize_test.rb → db/derby/serialize_test.rb} +0 -0
- data/test/{derby_simple_test.rb → db/derby/simple_test.rb} +23 -38
- data/test/db/derby/test_helper.rb +6 -0
- data/test/db/derby/unit_test.rb +32 -0
- data/test/db/derby/xml_column_test.rb +17 -0
- data/test/db/h2.rb +1 -1
- data/test/{h2_binary_test.rb → db/h2/binary_test.rb} +0 -0
- data/test/{h2_change_column_test.rb → db/h2/change_column_test.rb} +1 -0
- data/test/{h2_schema_dump_test.rb → db/h2/schema_dump_test.rb} +0 -0
- data/test/{h2_serialize_test.rb → db/h2/serialize_test.rb} +0 -0
- data/test/{h2_simple_test.rb → db/h2/simple_test.rb} +3 -1
- data/test/db/hsqldb.rb +1 -1
- data/test/{hsqldb_binary_test.rb → db/hsqldb/binary_test.rb} +0 -0
- data/test/{hsqldb_schema_dump_test.rb → db/hsqldb/schema_dump_test.rb} +0 -0
- data/test/{hsqldb_serialize_test.rb → db/hsqldb/serialize_test.rb} +0 -0
- data/test/{hsqldb_simple_test.rb → db/hsqldb/simple_test.rb} +3 -1
- data/test/db/informix.rb +1 -1
- data/test/db/jdbc.rb +3 -2
- data/test/db/jdbc_derby.rb +1 -1
- data/test/db/jdbc_h2.rb +1 -1
- data/test/db/jdbc_mysql.rb +1 -1
- data/test/db/jdbc_postgres.rb +1 -1
- data/test/db/jndi_config.rb +1 -2
- data/test/db/jndi_pooled_config.rb +2 -3
- data/test/db/mssql.rb +2 -2
- data/test/{mssql_binary_test.rb → db/mssql/binary_test.rb} +0 -0
- data/test/{mssql_db_create_test.rb → db/mssql/db_create_test.rb} +1 -1
- data/test/db/mssql/exec_proc_test.rb +46 -0
- data/test/{mssql_identity_insert_test.rb → db/mssql/identity_insert_test.rb} +0 -0
- data/test/db/mssql/ignore_system_views_test.rb +40 -0
- data/test/{mssql_limit_offset_test.rb → db/mssql/limit_offset_test.rb} +10 -1
- data/test/{mssql_multibyte_test.rb → db/mssql/multibyte_test.rb} +0 -0
- data/test/db/mssql/multiple_connections_test.rb +71 -0
- data/test/{mssql_reset_column_information_test.rb → db/mssql/reset_column_information_test.rb} +0 -0
- data/test/{mssql_row_locking_test.rb → db/mssql/row_locking_test.rb} +0 -0
- data/test/{mssql_serialize_test.rb → db/mssql/serialize_test.rb} +1 -1
- data/test/db/mssql/simple_test.rb +140 -0
- data/test/db/mssql/transaction_test.rb +6 -0
- data/test/db/mssql/types_test.rb +205 -0
- data/test/{mssql_test.rb → db/mssql/unit_test.rb} +2 -2
- data/test/db/mysql.rb +1 -2
- data/test/db/mysql/_rails_test_mysql.32.out +6768 -0
- data/test/{mysql_binary_test.rb → db/mysql/binary_test.rb} +0 -0
- data/test/db/mysql/connection_test.rb +51 -0
- data/test/{mysql_db_create_test.rb → db/mysql/db_create_test.rb} +0 -0
- data/test/{mysql_index_length_test.rb → db/mysql/index_length_test.rb} +0 -0
- data/test/{mysql_multibyte_test.rb → db/mysql/multibyte_test.rb} +0 -0
- data/test/{mysql_nonstandard_primary_key_test.rb → db/mysql/nonstandard_primary_key_test.rb} +0 -0
- data/test/{mysql_reset_column_information_test.rb → db/mysql/reset_column_information_test.rb} +0 -0
- data/test/{mysql_schema_dump_test.rb → db/mysql/schema_dump_test.rb} +9 -1
- data/test/{mysql_serialize_test.rb → db/mysql/serialize_test.rb} +0 -0
- data/test/{mysql_simple_test.rb → db/mysql/simple_test.rb} +16 -8
- data/test/db/mysql/transaction_test.rb +6 -0
- data/test/db/mysql/types_test.rb +30 -0
- data/test/{mysql_test.rb → db/mysql/unit_test.rb} +1 -1
- data/test/db/mysql_config.rb +1 -1
- data/test/db/oracle.rb +1 -1
- data/test/{oracle_binary_test.rb → db/oracle/binary_test.rb} +0 -0
- data/test/{oracle_limit_test.rb → db/oracle/limit_test.rb} +0 -0
- data/test/db/oracle/multibyte_test.rb +22 -0
- data/test/{oracle_reset_column_information_test.rb → db/oracle/reset_column_information_test.rb} +0 -0
- data/test/{oracle_serialize_test.rb → db/oracle/serialize_test.rb} +0 -0
- data/test/{oracle_simple_test.rb → db/oracle/simple_test.rb} +14 -19
- data/test/{oracle_specific_test.rb → db/oracle/specific_test.rb} +62 -16
- data/test/db/oracle/transaction_test.rb +31 -0
- data/test/db/oracle/unit_test.rb +31 -0
- data/test/db/postgres.rb +1 -1
- data/test/db/postgres/_rails_test_postgres.32.out +6777 -0
- data/test/db/postgres/a_custom_primary_key_test.rb +50 -0
- data/test/db/postgres/array_type_test.rb +101 -0
- data/test/{postgres_binary_test.rb → db/postgres/binary_test.rb} +0 -0
- data/test/db/postgres/connection_test.rb +55 -0
- data/test/db/postgres/data_types_test.rb +703 -0
- data/test/{postgres_db_create_test.rb → db/postgres/db_create_test.rb} +1 -1
- data/test/{postgres_drop_db_test.rb → db/postgres/db_drop_test.rb} +2 -0
- data/test/db/postgres/hstore_test.rb +200 -0
- data/test/db/postgres/information_schema_leak_test.rb +30 -0
- data/test/db/postgres/json_test.rb +86 -0
- data/test/db/postgres/ltree_test.rb +50 -0
- data/test/{postgres_mixed_case_test.rb → db/postgres/mixed_case_test.rb} +0 -0
- data/test/db/postgres/native_types_test.rb +128 -0
- data/test/{postgres_reserved_test.rb → db/postgres/reserved_test.rb} +0 -0
- data/test/{postgres_reset_column_information_test.rb → db/postgres/reset_column_information_test.rb} +0 -0
- data/test/{postgres_row_locking_test.rb → db/postgres/row_locking_test.rb} +0 -0
- data/test/{postgres_schema_dump_test.rb → db/postgres/schema_dump_test.rb} +4 -4
- data/test/db/postgres/schema_test.rb +113 -0
- data/test/{postgres_simple_test.rb → db/postgres/simple_test.rb} +48 -8
- data/test/{postgres_table_alias_length_test.rb → db/postgres/table_alias_length_test.rb} +2 -1
- data/test/db/postgres/transaction_test.rb +6 -0
- data/test/{postgres_test.rb → db/postgres/unit_test.rb} +3 -3
- data/test/db/sqlite3.rb +1 -1
- data/test/db/sqlite3/_rails_test_sqlite3.32.out +6502 -0
- data/test/db/sqlite3/has_many_though_test.rb +6 -0
- data/test/{sqlite3_reset_column_information_test.rb → db/sqlite3/reset_column_information_test.rb} +0 -0
- data/test/{sqlite3_schema_dump_test.rb → db/sqlite3/schema_dump_test.rb} +0 -0
- data/test/{sqlite3_serialize_test.rb → db/sqlite3/serialize_test.rb} +0 -0
- data/test/{sqlite3_simple_test.rb → db/sqlite3/simple_test.rb} +63 -63
- data/test/db/sqlite3/transaction_test.rb +32 -0
- data/test/{sqlite3_type_conversion_test.rb → db/sqlite3/type_conversion_test.rb} +0 -0
- data/test/has_many_through.rb +29 -64
- data/test/jdbc/oracle.rb +11 -0
- data/test/jndi_test.rb +16 -4
- data/test/models/auto_id.rb +1 -1
- data/test/models/rights_and_roles.rb +57 -0
- data/test/row_locking.rb +3 -0
- data/test/schema_dump.rb +24 -10
- data/test/simple.rb +359 -104
- data/test/test_helper.rb +4 -2
- data/test/transaction.rb +109 -0
- metadata +119 -86
- data/lib/arjdbc/jdbc/compatibility.rb +0 -51
- data/lib/arjdbc/jdbc/core_ext.rb +0 -24
- data/lib/arjdbc/jdbc/discover.rb +0 -18
- data/test/derby_schema_dump_test.rb +0 -9
- data/test/mssql_ignore_system_views_test.rb +0 -30
- data/test/mssql_legacy_types_test.rb +0 -58
- data/test/mssql_null_test.rb +0 -14
- data/test/mssql_simple_test.rb +0 -51
- data/test/postgres_information_schema_leak_test.rb +0 -28
- data/test/postgres_native_type_mapping_test.rb +0 -93
- data/test/postgres_nonseq_pkey_test.rb +0 -38
- data/test/postgres_schema_search_path_test.rb +0 -48
- data/test/postgres_type_conversion_test.rb +0 -33
File without changes
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'db/mysql'
|
2
|
+
|
3
|
+
class MySQLConnectionTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_mysql_default_in_strict_mode
|
6
|
+
assert_equal [["STRICT_ALL_TABLES"]], select_rows("SELECT @@SESSION.sql_mode")
|
7
|
+
end if ar_version('4.0')
|
8
|
+
|
9
|
+
def test_mysql_strict_mode_disabled
|
10
|
+
run_without_connection do |orig_connection|
|
11
|
+
ActiveRecord::Base.establish_connection(orig_connection.merge({:strict => false}))
|
12
|
+
assert_equal [['']], select_rows("SELECT @@SESSION.sql_mode")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_mysql_set_session_variable
|
17
|
+
run_without_connection do |orig_connection|
|
18
|
+
ActiveRecord::Base.establish_connection(orig_connection.deep_merge({:variables => {:default_week_format => 3}}))
|
19
|
+
rows = select_rows("SELECT @@SESSION.DEFAULT_WEEK_FORMAT")
|
20
|
+
assert_equal 3, rows.first.first.to_i
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_mysql_set_session_variable_to_default
|
25
|
+
run_without_connection do |orig_connection|
|
26
|
+
ActiveRecord::Base.establish_connection(orig_connection.deep_merge({:variables => {:default_week_format => :default}}))
|
27
|
+
global_mode_rows = select_rows "SELECT @@GLOBAL.DEFAULT_WEEK_FORMAT"
|
28
|
+
session_mode_rows = select_rows "SELECT @@SESSION.DEFAULT_WEEK_FORMAT"
|
29
|
+
assert_equal global_mode_rows, session_mode_rows
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
|
35
|
+
def select_rows(sql)
|
36
|
+
result = ActiveRecord::Base.connection.exec_query(sql)
|
37
|
+
result.respond_to?(:rows) ? result.rows : [ result.first.map { |_,value| value } ]
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def run_without_connection
|
43
|
+
original_connection = ActiveRecord::Base.remove_connection
|
44
|
+
begin
|
45
|
+
yield original_connection
|
46
|
+
ensure
|
47
|
+
ActiveRecord::Base.establish_connection(original_connection)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
data/test/{mysql_nonstandard_primary_key_test.rb → db/mysql/nonstandard_primary_key_test.rb}
RENAMED
File without changes
|
data/test/{mysql_reset_column_information_test.rb → db/mysql/reset_column_information_test.rb}
RENAMED
File without changes
|
@@ -28,10 +28,12 @@ class MysqlSchemaDumpTest < Test::Unit::TestCase
|
|
28
28
|
t.text :normal_text, :limit => 65535
|
29
29
|
t.text :medium_text, :limit => 16777215
|
30
30
|
t.text :long_text, :limit => 2147483647
|
31
|
-
t.text :just_text,
|
31
|
+
t.text :just_text, :null => false
|
32
32
|
# MySQL does not allow default values for blobs.
|
33
33
|
# Fake it out with a big varchar below.
|
34
34
|
t.string :string_col, :null => true, :default => '', :limit => 1024
|
35
|
+
t.binary :var_binary, :limit => 255
|
36
|
+
t.binary :var_binary_large, :limit => 4095
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
@@ -52,6 +54,12 @@ class MysqlSchemaDumpTest < Test::Unit::TestCase
|
|
52
54
|
assert_match %r{t.text\s+"long_text",\s+:limit => 2147483647$}, output
|
53
55
|
end
|
54
56
|
|
57
|
+
def test_schema_dump_includes_length_for_mysql_binary_fields
|
58
|
+
output = standard_dump
|
59
|
+
assert_match %r{t.binary\s+"var_binary",[\s|:]+limit[\s\:\=\>]+255$}, output
|
60
|
+
assert_match %r{t.binary\s+"var_binary_large",[\s|:]+limit[\s\:\=\>]+4095$}, output
|
61
|
+
end
|
62
|
+
|
55
63
|
end
|
56
64
|
|
57
65
|
class MysqlInfoTest < Test::Unit::TestCase
|
File without changes
|
@@ -12,7 +12,9 @@ class MysqlSimpleTest < Test::Unit::TestCase
|
|
12
12
|
include SimpleTestMethods
|
13
13
|
include ActiveRecord3TestMethods
|
14
14
|
include ColumnNameQuotingTests
|
15
|
+
include DirtyAttributeTests
|
15
16
|
include XmlColumnTests
|
17
|
+
include CustomSelectTestMethods
|
16
18
|
|
17
19
|
column_quote_char "`"
|
18
20
|
|
@@ -92,12 +94,18 @@ class MysqlSimpleTest < Test::Unit::TestCase
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def test_find_in_other_schema_with_include
|
97
|
+
user_1 = User.create :login => 'user1'
|
98
|
+
user_2 = User.create :login => 'user2'
|
99
|
+
Entry.create :title => 'title1', :content => '', :rating => 0, :user_id => user_1.id
|
100
|
+
Entry.create :title => 'title2', :content => '', :rating => 1, :user_id => user_2.id
|
101
|
+
|
95
102
|
old_entries_table_name = Entry.table_name
|
96
103
|
old_users_table_name = User.table_name
|
104
|
+
database = MYSQL_CONFIG[:database]
|
97
105
|
begin
|
98
|
-
User.table_name = "#{
|
99
|
-
Entry.table_name = "#{
|
100
|
-
|
106
|
+
User.table_name = "#{database}.users"
|
107
|
+
Entry.table_name = "#{database}.entries"
|
108
|
+
assert_not_empty Entry.all(:include => :user)
|
101
109
|
ensure
|
102
110
|
Entry.table_name = old_entries_table_name
|
103
111
|
User.table_name = old_users_table_name
|
@@ -106,6 +114,11 @@ class MysqlSimpleTest < Test::Unit::TestCase
|
|
106
114
|
|
107
115
|
include ExplainSupportTestMethods if ar_version("3.1")
|
108
116
|
|
117
|
+
def test_reports_server_version
|
118
|
+
assert_instance_of Array, ActiveRecord::Base.connection.send(:version)
|
119
|
+
assert_equal 3, ActiveRecord::Base.connection.send(:version).size
|
120
|
+
end
|
121
|
+
|
109
122
|
def test_update_sql_public_and_returns_rows_affected
|
110
123
|
ActiveRecord::Base.connection.update_sql "UPDATE entries SET title = NULL"
|
111
124
|
|
@@ -117,11 +130,6 @@ class MysqlSimpleTest < Test::Unit::TestCase
|
|
117
130
|
assert_equal 'updated content', e1.reload.content
|
118
131
|
assert_equal 'updated content', e2.reload.content
|
119
132
|
end
|
120
|
-
|
121
|
-
def test_reports_server_version
|
122
|
-
assert_instance_of Array, ActiveRecord::Base.connection.send(:version)
|
123
|
-
assert_equal 3, ActiveRecord::Base.connection.send(:version).size
|
124
|
-
end
|
125
133
|
|
126
134
|
end
|
127
135
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'db/mysql'
|
2
|
+
|
3
|
+
class MySQLTypesTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_binary_types
|
6
|
+
assert_equal 'varbinary(64)', type_to_sql(:binary, 64)
|
7
|
+
assert_equal 'varbinary(4095)', type_to_sql(:binary, 4095)
|
8
|
+
assert_equal 'blob(4096)', type_to_sql(:binary, 4096)
|
9
|
+
assert_equal 'blob', type_to_sql(:binary)
|
10
|
+
end
|
11
|
+
|
12
|
+
def type_to_sql(*args)
|
13
|
+
ActiveRecord::Base.connection.type_to_sql(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.startup
|
17
|
+
ActiveRecord::Base.connection.execute "CREATE TABLE enum_tests ( enum_column ENUM('true','false') )"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.shutdown
|
21
|
+
ActiveRecord::Base.connection.execute "DROP TABLE IF EXISTS enum_tests;"
|
22
|
+
end
|
23
|
+
|
24
|
+
class EnumTest < ActiveRecord::Base; end
|
25
|
+
|
26
|
+
def test_enum_limit
|
27
|
+
assert_equal 5, EnumTest.columns.first.limit
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
data/test/db/mysql_config.rb
CHANGED
data/test/db/oracle.rb
CHANGED
File without changes
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'db/oracle'
|
2
|
+
require 'simple'
|
3
|
+
|
4
|
+
class OracleMultibyteTest < Test::Unit::TestCase
|
5
|
+
include MultibyteTestMethods
|
6
|
+
|
7
|
+
def self.startup
|
8
|
+
super
|
9
|
+
MigrationSetup.setup!
|
10
|
+
ActiveRecord::Base.logger.level = Logger::DEBUG
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.shutdown
|
14
|
+
ActiveRecord::Base.logger.level = Logger::WARN
|
15
|
+
MigrationSetup.teardown!
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def setup!; end # MigrationSetup#setup!
|
20
|
+
def teardown!; end # MigrationSetup#teardown!
|
21
|
+
|
22
|
+
end
|
data/test/{oracle_reset_column_information_test.rb → db/oracle/reset_column_information_test.rb}
RENAMED
File without changes
|
File without changes
|
@@ -1,10 +1,22 @@
|
|
1
|
-
require 'jdbc_common'
|
2
1
|
require 'db/oracle'
|
2
|
+
require 'simple'
|
3
3
|
|
4
4
|
class OracleSimpleTest < Test::Unit::TestCase
|
5
5
|
include SimpleTestMethods
|
6
|
+
include ActiveRecord3TestMethods
|
7
|
+
include DirtyAttributeTests
|
8
|
+
include XmlColumnTests
|
9
|
+
|
10
|
+
def xml_sql_type; 'XMLTYPE'; end
|
6
11
|
|
12
|
+
# #override
|
13
|
+
def test_insert_returns_id
|
14
|
+
# TODO not supported/implemented
|
15
|
+
end
|
16
|
+
|
7
17
|
def test_default_id_type_is_integer
|
18
|
+
user = User.create! :login => 'id_type'
|
19
|
+
Entry.create! :title => 'first', :user_id => user.id
|
8
20
|
assert Integer === Entry.first.id
|
9
21
|
end
|
10
22
|
|
@@ -68,6 +80,7 @@ class OracleSimpleTest < Test::Unit::TestCase
|
|
68
80
|
|
69
81
|
def assert_date_equal expected, actual
|
70
82
|
# Oracle doesn't distinguish btw date/datetime
|
83
|
+
expected = expected.respond_to?(:to_date) ? expected.to_date : expected
|
71
84
|
assert_equal expected, actual.to_date
|
72
85
|
end
|
73
86
|
|
@@ -77,21 +90,3 @@ class OracleSimpleTest < Test::Unit::TestCase
|
|
77
90
|
end
|
78
91
|
|
79
92
|
end
|
80
|
-
|
81
|
-
class OracleMultibyteTest < Test::Unit::TestCase
|
82
|
-
include MultibyteTestMethods
|
83
|
-
|
84
|
-
def self.startup
|
85
|
-
super
|
86
|
-
MigrationSetup.setup!
|
87
|
-
end
|
88
|
-
|
89
|
-
def self.shutdown
|
90
|
-
MigrationSetup.teardown!
|
91
|
-
super
|
92
|
-
end
|
93
|
-
|
94
|
-
def setup!; end # MigrationSetup#setup!
|
95
|
-
def teardown!; end # MigrationSetup#teardown!
|
96
|
-
|
97
|
-
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'jdbc_common'
|
3
2
|
require 'db/oracle'
|
3
|
+
require 'simple'
|
4
4
|
|
5
5
|
class OracleSpecificTest < Test::Unit::TestCase
|
6
6
|
include MigrationSetup
|
@@ -21,17 +21,29 @@ class OracleSpecificTest < Test::Unit::TestCase
|
|
21
21
|
java_connection.createStatement.execute "
|
22
22
|
INSERT INTO DEFAULT_NUMBERS (ID, VALUE, DATUM, FPOINT, VALUE2)
|
23
23
|
VALUES (1, 0.076, TIMESTAMP'2009-11-05 00:00:00', 1000.01, 1234)"
|
24
|
-
java_connection.createStatement.execute "CREATE SYNONYM POSTS FOR ENTRIES"
|
25
24
|
|
26
25
|
MigrationSetup.setup!
|
26
|
+
|
27
|
+
java_connection.createStatement.execute "CREATE SYNONYM POSTS FOR ENTRIES"
|
28
|
+
|
29
|
+
java_connection.createStatement.execute "CREATE VIEW GOOD_ENTRIES AS SELECT * FROM entries WHERE rating >= 1.0"
|
30
|
+
|
31
|
+
# MV will be populated IMMEDIATELY by default :
|
32
|
+
user = User.create! :login => 'sandokan'
|
33
|
+
Entry.create! :title => 'SANDOKAAAN!', :rating => 4.95, :user_id => user.id
|
34
|
+
|
35
|
+
java_connection.createStatement.execute "CREATE MATERIALIZED VIEW USER_ENTRIES AS " +
|
36
|
+
"SELECT e.id, e.title, e.user_id FROM users u, entries e WHERE e.user_id = u.id "
|
27
37
|
end
|
28
38
|
|
29
39
|
def self.shutdown
|
30
|
-
MigrationSetup.teardown!
|
31
|
-
|
32
40
|
java_connection = @@java_connection
|
33
41
|
java_connection.createStatement.execute "DROP TABLE DEFAULT_NUMBERS"
|
34
42
|
java_connection.createStatement.execute "DROP SYNONYM POSTS"
|
43
|
+
java_connection.createStatement.execute "DROP VIEW GOOD_ENTRIES"
|
44
|
+
java_connection.createStatement.execute "DROP MATERIALIZED VIEW USER_ENTRIES"
|
45
|
+
|
46
|
+
MigrationSetup.teardown!
|
35
47
|
|
36
48
|
@@java_connection.close
|
37
49
|
super
|
@@ -91,26 +103,60 @@ class OracleSpecificTest < Test::Unit::TestCase
|
|
91
103
|
obj = DefaultNumber.first
|
92
104
|
assert obj.datum.nil?
|
93
105
|
end
|
106
|
+
|
107
|
+
test "synonym table exists" do
|
108
|
+
assert_true ActiveRecord::Base.connection.table_exists? 'posts'
|
109
|
+
assert_true ActiveRecord::Base.connection.table_exists? 'POSTS'
|
110
|
+
end
|
111
|
+
|
112
|
+
test "view table exists (despite not being among reported tables)" do
|
113
|
+
assert_true ActiveRecord::Base.connection.table_exists? 'GOOD_ENTRIES'
|
114
|
+
assert_false ActiveRecord::Base.connection.tables.include?('GOOD_ENTRIES')
|
115
|
+
end
|
94
116
|
|
95
|
-
|
117
|
+
test "materialized view table exists" do
|
118
|
+
assert_true ActiveRecord::Base.connection.table_exists? 'USER_ENTRIES'
|
119
|
+
end
|
120
|
+
|
121
|
+
test 'model access by synonym' do
|
96
122
|
@klass = Class.new(ActiveRecord::Base)
|
97
123
|
@klass.table_name = "POSTS" # alias
|
98
124
|
entry_columns = Entry.columns_hash
|
99
|
-
@klass.columns.each do |
|
100
|
-
assert
|
101
|
-
assert_equal
|
102
|
-
assert_equal
|
125
|
+
@klass.columns.each do |column|
|
126
|
+
assert entry_column = entry_columns[column.name]
|
127
|
+
assert_equal entry_column.sql_type, column.sql_type
|
128
|
+
assert_equal entry_column.type, column.type
|
103
129
|
end
|
104
130
|
end
|
105
131
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
assert_equal
|
111
|
-
assert_equal
|
112
|
-
assert_equal 30, connection.column_name_length
|
132
|
+
class Post < ActiveRecord::Base; end
|
133
|
+
|
134
|
+
test "post synonym" do
|
135
|
+
Entry.create! :title => 'first', :content => 'SOME CONTENT', :rating => 0.5
|
136
|
+
assert_equal Entry.count, Post.count
|
137
|
+
assert_equal Entry.first.title, Post.first.title
|
113
138
|
end
|
139
|
+
|
140
|
+
test 'model access by materialized view' do
|
141
|
+
@klass = Class.new(ActiveRecord::Base)
|
142
|
+
@klass.table_name = "USER_ENTRIES" # MV
|
143
|
+
entry_columns = Entry.columns_hash
|
144
|
+
|
145
|
+
assert_equal 3, @klass.columns.size
|
146
|
+
assert column = @klass.columns_hash['id']
|
147
|
+
assert_equal entry_columns['id'].sql_type, column.sql_type
|
148
|
+
assert_equal entry_columns['id'].type, column.type
|
149
|
+
assert column = @klass.columns_hash['title']
|
150
|
+
assert_equal entry_columns['title'].sql_type, column.sql_type
|
151
|
+
assert_equal entry_columns['title'].type, column.type
|
152
|
+
assert column = @klass.columns_hash['user_id']
|
153
|
+
assert_equal entry_columns['user_id'].sql_type, column.sql_type
|
154
|
+
assert_equal entry_columns['user_id'].type, column.type
|
155
|
+
|
156
|
+
assert @klass.first # sandokan was here !
|
157
|
+
end
|
158
|
+
|
159
|
+
#
|
114
160
|
|
115
161
|
def test_current_user
|
116
162
|
puts "ORA current_user: #{connection.current_user}"
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'db/oracle'
|
2
|
+
require 'transaction'
|
3
|
+
|
4
|
+
class OracleTransactionTest < Test::Unit::TestCase
|
5
|
+
include TransactionTestMethods
|
6
|
+
|
7
|
+
def test_supports_transaction_isolation
|
8
|
+
assert ActiveRecord::Base.connection.supports_transaction_isolation?
|
9
|
+
assert ActiveRecord::Base.connection.supports_transaction_isolation?(:read_committed)
|
10
|
+
assert ActiveRecord::Base.connection.supports_transaction_isolation?(:serializable)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Oracle supports TRANSACTION_SERIALIZABLE and TRANSACTION_READ_COMMITTED
|
14
|
+
|
15
|
+
def test_transaction_isolation_read_uncommitted
|
16
|
+
assert ! ActiveRecord::Base.connection.supports_transaction_isolation?(:read_uncommitted)
|
17
|
+
|
18
|
+
assert_raise ActiveRecord::TransactionIsolationError do
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end if Test::Unit::TestCase.ar_version('4.0')
|
22
|
+
|
23
|
+
def test_transaction_isolation_repeatable_read
|
24
|
+
assert ! ActiveRecord::Base.connection.supports_transaction_isolation?(:repeatable_read)
|
25
|
+
|
26
|
+
assert_raise ActiveRecord::TransactionIsolationError do
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end if Test::Unit::TestCase.ar_version('4.0')
|
30
|
+
|
31
|
+
end
|