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
@@ -51,9 +51,9 @@ public abstract class QuotingUtils {
|
|
51
51
|
final char value, final char quote) {
|
52
52
|
|
53
53
|
final ByteList stringBytes = string.getByteList();
|
54
|
-
final byte[] bytes = stringBytes.
|
55
|
-
final int begin = stringBytes.
|
56
|
-
final int realSize = stringBytes.
|
54
|
+
final byte[] bytes = stringBytes.unsafeBytes();
|
55
|
+
final int begin = stringBytes.getBegin();
|
56
|
+
final int realSize = stringBytes.getRealSize();
|
57
57
|
|
58
58
|
ByteList quotedBytes = null; int appendFrom = begin;
|
59
59
|
for ( int i = begin; i < begin + realSize; i++ ) {
|
@@ -61,10 +61,10 @@ public abstract class QuotingUtils {
|
|
61
61
|
if ( quotedBytes == null ) {
|
62
62
|
quotedBytes = new ByteList(
|
63
63
|
new byte[realSize + 8],
|
64
|
-
stringBytes.
|
64
|
+
stringBytes.getEncoding()
|
65
65
|
);
|
66
|
-
quotedBytes.
|
67
|
-
quotedBytes.
|
66
|
+
quotedBytes.setBegin(0);
|
67
|
+
quotedBytes.setRealSize(0);
|
68
68
|
}
|
69
69
|
quotedBytes.append(bytes, appendFrom, i - appendFrom);
|
70
70
|
quotedBytes.append(quote).append(value); // e.g. "'" => "''"
|
data/test/abstract_db_create.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'test_helper'
|
2
2
|
require 'rake'
|
3
3
|
|
4
4
|
module Rails
|
5
|
-
class Configuration
|
6
|
-
end
|
5
|
+
class Configuration; end unless const_defined?(:Configuration)
|
7
6
|
class Application
|
8
7
|
def self.config
|
9
8
|
@config ||= Object.new
|
@@ -23,7 +22,7 @@ module AbstractDbCreate
|
|
23
22
|
end
|
24
23
|
|
25
24
|
def setup
|
26
|
-
@
|
25
|
+
@prev_app = Rake.application
|
27
26
|
Rake.application = Rake::Application.new
|
28
27
|
verbose(true)
|
29
28
|
do_setup
|
@@ -31,7 +30,7 @@ module AbstractDbCreate
|
|
31
30
|
|
32
31
|
def do_setup(env = 'unittest', db = 'test_rake_db_create')
|
33
32
|
@env = env
|
34
|
-
@
|
33
|
+
@prev_configs = ActiveRecord::Base.configurations
|
35
34
|
ActiveRecord::Base.connection.disconnect!
|
36
35
|
@db_name = db
|
37
36
|
setup_rails
|
@@ -49,19 +48,19 @@ module AbstractDbCreate
|
|
49
48
|
|
50
49
|
def teardown
|
51
50
|
Rake::Task["db:drop"].invoke
|
52
|
-
Rake.application = @
|
51
|
+
Rake.application = @prev_app
|
53
52
|
restore_rails
|
54
|
-
ActiveRecord::Base.configurations = @
|
53
|
+
ActiveRecord::Base.configurations = @prev_configs
|
55
54
|
ActiveRecord::Base.establish_connection(db_config)
|
56
55
|
@rails_env_set = nil
|
57
56
|
@full_env_loaded = nil
|
58
57
|
end
|
59
58
|
|
60
59
|
def setup_rails
|
61
|
-
if ActiveRecord::VERSION::MAJOR
|
62
|
-
setup_rails3
|
63
|
-
else
|
60
|
+
if ActiveRecord::VERSION::MAJOR <= 2
|
64
61
|
setup_rails2
|
62
|
+
else
|
63
|
+
setup_rails3
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
@@ -77,7 +76,7 @@ module AbstractDbCreate
|
|
77
76
|
|
78
77
|
def setup_rails2
|
79
78
|
configs = configurations
|
80
|
-
Rails::Configuration.
|
79
|
+
Rails::Configuration.module_eval do
|
81
80
|
define_method(:database_configuration) { configs }
|
82
81
|
end
|
83
82
|
ar_version = $LOADED_FEATURES.grep(%r{active_record/version}).first
|
@@ -136,4 +135,5 @@ module AbstractDbCreate
|
|
136
135
|
ensure
|
137
136
|
$VERBOSE = prev
|
138
137
|
end
|
138
|
+
|
139
139
|
end
|
@@ -3,28 +3,34 @@ require 'models/data_types'
|
|
3
3
|
require 'arjdbc'
|
4
4
|
require 'test/unit'
|
5
5
|
|
6
|
-
JInteger = java.lang.Integer
|
7
|
-
|
8
6
|
class TypeConversionTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
TEST_INT = 987654321
|
9
|
+
|
9
10
|
TEST_TIME = Time.at(1169964202).gmtime
|
11
|
+
|
12
|
+
def self.startup
|
13
|
+
DbTypeMigration.up
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.shutdown
|
17
|
+
DbTypeMigration.down
|
18
|
+
end
|
19
|
+
|
10
20
|
def setup
|
11
|
-
DbTypeMigration.up
|
12
21
|
DbType.create(
|
13
22
|
:sample_timestamp => TEST_TIME,
|
14
|
-
:sample_decimal =>
|
15
|
-
end
|
16
|
-
|
17
|
-
def teardown
|
18
|
-
DbTypeMigration.down
|
23
|
+
:sample_decimal => TEST_INT) # DECIMAL(9,0)
|
19
24
|
end
|
20
25
|
|
21
26
|
def test_timestamp
|
22
|
-
|
23
|
-
assert_equal TEST_TIME,
|
27
|
+
type = DbType.first
|
28
|
+
assert_equal TEST_TIME, type.sample_timestamp.getutc
|
24
29
|
end
|
25
30
|
|
26
31
|
def test_decimal
|
27
|
-
|
28
|
-
assert_equal
|
32
|
+
type = DbType.first
|
33
|
+
assert_equal TEST_INT, type.sample_decimal
|
29
34
|
end
|
35
|
+
|
30
36
|
end
|
data/test/db/db2.rb
CHANGED
File without changes
|
File without changes
|
@@ -1,7 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'db/db2'
|
3
|
-
|
4
|
-
DbTypeMigration.big_decimal_precision = 31
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
5
2
|
|
6
3
|
class DB2SimpleTest < Test::Unit::TestCase
|
7
4
|
include SimpleTestMethods
|
@@ -62,7 +59,3 @@ class DB2SimpleTest < Test::Unit::TestCase
|
|
62
59
|
end
|
63
60
|
|
64
61
|
end
|
65
|
-
|
66
|
-
class DB2HasManyThroughTest < Test::Unit::TestCase
|
67
|
-
include HasManyThroughMethods
|
68
|
-
end
|
data/test/db/derby.rb
CHANGED
File without changes
|
File without changes
|
data/test/{derby_reset_column_information_test.rb → db/derby/reset_column_information_test.rb}
RENAMED
File without changes
|
@@ -1,13 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'jdbc_common'
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
3
2
|
require 'row_locking'
|
4
3
|
|
5
4
|
class DerbyRowLockingTest < Test::Unit::TestCase
|
6
5
|
include MigrationSetup
|
7
6
|
include RowLockingTestMethods
|
8
7
|
|
9
|
-
DbTypeMigration.big_decimal_precision = 31
|
10
|
-
|
11
8
|
# def self.startup
|
12
9
|
# MigrationSetup.setup!
|
13
10
|
# end
|
File without changes
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: ASCII-8BIT
|
2
|
-
require '
|
3
|
-
require '
|
4
|
-
|
5
|
-
DbTypeMigration.big_decimal_precision = 31
|
2
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
3
|
+
require 'simple'
|
4
|
+
require 'has_many_through'
|
6
5
|
|
7
6
|
class DerbySimpleTest < Test::Unit::TestCase
|
8
7
|
include SimpleTestMethods
|
9
8
|
include ActiveRecord3TestMethods
|
9
|
+
include CustomSelectTestMethods
|
10
10
|
|
11
11
|
# Check that a table-less VALUES(xxx) query (like SELECT works.
|
12
12
|
def test_values
|
@@ -18,9 +18,13 @@ class DerbySimpleTest < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_find_with_include_and_order
|
21
|
+
Entry.create! :title => 'First Post!',
|
22
|
+
:content => "Hello from 'JRuby on Rails'!",
|
23
|
+
:user => (user = User.create!(:login => "someone"))
|
24
|
+
|
21
25
|
users = User.find(:all, :include=>[:entries], :order=>"entries.rating DESC", :limit => 2)
|
22
26
|
|
23
|
-
assert users.include?(
|
27
|
+
assert users.include?(user)
|
24
28
|
end
|
25
29
|
|
26
30
|
def test_text_and_string_conversions
|
@@ -136,6 +140,20 @@ class DerbySimpleTest < Test::Unit::TestCase
|
|
136
140
|
|
137
141
|
assert_equal expected_types, result
|
138
142
|
end
|
143
|
+
|
144
|
+
# @override Derby is made in IBM thus it needs to get complicated with 1.42
|
145
|
+
def test_custom_select_float
|
146
|
+
model = DbType.create! :sample_float => 1.42
|
147
|
+
if ActiveRecord::VERSION::MAJOR >= 3
|
148
|
+
model = DbType.where("id = #{model.id}").select('sample_float AS custom_sample_float').first
|
149
|
+
else
|
150
|
+
model = DbType.find(:first, :conditions => "id = #{model.id}", :select => 'sample_float AS custom_sample_float')
|
151
|
+
end
|
152
|
+
assert_instance_of Float, model.custom_sample_float
|
153
|
+
custom_sample_float = (model.custom_sample_float * 100).round.to_f / 100 # .round(2) 1.8.7 compatible
|
154
|
+
assert_equal 1.42, custom_sample_float # Derby otherwise returns us smt like: 1.4199999570846558
|
155
|
+
end
|
156
|
+
|
139
157
|
end
|
140
158
|
|
141
159
|
class DerbyMultibyteTest < Test::Unit::TestCase
|
@@ -145,36 +163,3 @@ end
|
|
145
163
|
class DerbyHasManyThroughTest < Test::Unit::TestCase
|
146
164
|
include HasManyThroughMethods
|
147
165
|
end
|
148
|
-
|
149
|
-
# encoding: ASCII-8BIT
|
150
|
-
require 'test_helper'
|
151
|
-
|
152
|
-
class DerbyTest < Test::Unit::TestCase
|
153
|
-
|
154
|
-
class DerbyImpl
|
155
|
-
include ArJdbc::Derby
|
156
|
-
def initialize; end
|
157
|
-
end
|
158
|
-
derby = DerbyImpl.new
|
159
|
-
|
160
|
-
test "quote (string) without column passed" do
|
161
|
-
s = "'"; q = "''"
|
162
|
-
assert_equal q, derby.quote_string(s)
|
163
|
-
assert_equal "'string #{q}'", derby.quote(v = "string #{s}"), "while quoting #{v.inspect}"
|
164
|
-
assert_equal "' #{q}'", derby.quote(v = " #{s}", nil), "while quoting #{v.inspect}"
|
165
|
-
assert_equal "'#{q}str'", derby.quote(v = "#{s}str", nil), "while quoting #{v.inspect}"
|
166
|
-
end
|
167
|
-
|
168
|
-
test "quote (string) keeps original" do
|
169
|
-
s = "kôň ůň löw9876qűáéőú.éáű-mehehehehehehe0 \x01 \x02"
|
170
|
-
q = "'kôň ůň löw9876qűáéőú.éáű-mehehehehehehe0 \x01 \x02'"
|
171
|
-
assert_equal q, derby.quote(s.dup)
|
172
|
-
|
173
|
-
if s.respond_to?(:force_encoding)
|
174
|
-
s.force_encoding('UTF-8')
|
175
|
-
q.force_encoding('UTF-8')
|
176
|
-
assert_equal q, derby.quote(s.dup)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class DerbyUnitTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class DerbyImpl
|
7
|
+
include ArJdbc::Derby
|
8
|
+
def initialize; end
|
9
|
+
end
|
10
|
+
derby = DerbyImpl.new
|
11
|
+
|
12
|
+
test "quote (string) without column passed" do
|
13
|
+
s = "'"; q = "''"
|
14
|
+
assert_equal q, derby.quote_string(s)
|
15
|
+
assert_equal "'string #{q}'", derby.quote(v = "string #{s}"), "while quoting #{v.inspect}"
|
16
|
+
assert_equal "' #{q}'", derby.quote(v = " #{s}", nil), "while quoting #{v.inspect}"
|
17
|
+
assert_equal "'#{q}str'", derby.quote(v = "#{s}str", nil), "while quoting #{v.inspect}"
|
18
|
+
end
|
19
|
+
|
20
|
+
test "quote (string) keeps original" do
|
21
|
+
s = "kôň ůň löw9876qűáéőú.éáű-mehehehehehehe0 \x01 \x02"
|
22
|
+
q = "'kôň ůň löw9876qűáéőú.éáű-mehehehehehehe0 \x01 \x02'"
|
23
|
+
assert_equal q, derby.quote(s.dup)
|
24
|
+
|
25
|
+
if s.respond_to?(:force_encoding)
|
26
|
+
s.force_encoding('UTF-8')
|
27
|
+
q.force_encoding('UTF-8')
|
28
|
+
assert_equal q, derby.quote(s.dup)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
+
require 'simple'
|
3
|
+
|
4
|
+
class DerbyXmlColumnTest < Test::Unit::TestCase
|
5
|
+
include FixtureSetup
|
6
|
+
include XmlColumnTests
|
7
|
+
|
8
|
+
def xml_sql_type; 'xml'; end
|
9
|
+
|
10
|
+
# @override
|
11
|
+
def test_use_xml_column
|
12
|
+
omit("[derby] XML values are not allowed in top-level result sets;")
|
13
|
+
# we'll need to somehow magically add XMLSERIALIZE for all XML columns !
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
data/test/db/h2.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -1,9 +1,11 @@
|
|
1
|
-
require 'jdbc_common'
|
2
1
|
require 'db/h2'
|
2
|
+
require 'jdbc_common'
|
3
3
|
|
4
4
|
class H2SimpleTest < Test::Unit::TestCase
|
5
5
|
include SimpleTestMethods
|
6
6
|
include ExplainSupportTestMethods if ar_version("3.1")
|
7
|
+
include ActiveRecord3TestMethods
|
8
|
+
include CustomSelectTestMethods
|
7
9
|
end
|
8
10
|
|
9
11
|
class H2HasManyThroughTest < Test::Unit::TestCase
|
data/test/db/hsqldb.rb
CHANGED
File without changes
|
File without changes
|