activerecord-jdbc-adapter 1.3.0.beta2 → 1.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -8
- data/.travis.yml +40 -31
- data/.yardopts +4 -0
- data/Appraisals +2 -5
- data/CONTRIBUTING.md +46 -0
- data/Gemfile +21 -4
- data/Gemfile.lock +42 -17
- data/{History.txt → History.md} +142 -75
- data/README.md +102 -104
- data/RUNNING_TESTS.md +76 -0
- data/Rakefile.jdbc +20 -0
- data/activerecord-jdbc-adapter.gemspec +35 -18
- data/gemfiles/rails23.gemfile +4 -3
- data/gemfiles/rails23.gemfile.lock +9 -6
- data/gemfiles/rails30.gemfile +4 -3
- data/gemfiles/rails30.gemfile.lock +9 -6
- data/gemfiles/rails31.gemfile +4 -3
- data/gemfiles/rails31.gemfile.lock +9 -6
- data/gemfiles/rails32.gemfile +4 -3
- data/gemfiles/rails32.gemfile.lock +17 -14
- data/gemfiles/rails40.gemfile +5 -5
- data/gemfiles/rails40.gemfile.lock +17 -69
- data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
- data/lib/arel/visitors/compat.rb +22 -3
- data/lib/arel/visitors/db2.rb +8 -4
- data/lib/arel/visitors/derby.rb +14 -13
- data/lib/arel/visitors/firebird.rb +5 -4
- data/lib/arel/visitors/hsqldb.rb +11 -9
- data/lib/arel/visitors/sql_server.rb +89 -61
- data/lib/arjdbc.rb +1 -1
- data/lib/arjdbc/db2/adapter.rb +181 -212
- data/lib/arjdbc/db2/as400.rb +31 -18
- data/lib/arjdbc/db2/column.rb +167 -0
- data/lib/arjdbc/db2/connection_methods.rb +2 -0
- data/lib/arjdbc/derby/adapter.rb +206 -107
- data/lib/arjdbc/derby/connection_methods.rb +4 -9
- data/lib/arjdbc/firebird.rb +1 -0
- data/lib/arjdbc/firebird/adapter.rb +202 -64
- data/lib/arjdbc/firebird/connection_methods.rb +20 -0
- data/lib/arjdbc/h2/adapter.rb +56 -36
- data/lib/arjdbc/hsqldb/adapter.rb +99 -68
- data/lib/arjdbc/jdbc/adapter.rb +474 -265
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +8 -7
- data/lib/arjdbc/jdbc/arel_support.rb +132 -0
- data/lib/arjdbc/jdbc/base_ext.rb +8 -7
- data/lib/arjdbc/jdbc/callbacks.rb +16 -10
- data/lib/arjdbc/jdbc/column.rb +25 -3
- data/lib/arjdbc/jdbc/connection.rb +28 -55
- data/lib/arjdbc/jdbc/extension.rb +14 -14
- data/lib/arjdbc/jdbc/java.rb +6 -3
- data/lib/arjdbc/jdbc/jdbc.rake +1 -1
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +2 -2
- data/lib/arjdbc/jdbc/rake_tasks.rb +1 -1
- data/lib/arjdbc/jdbc/type_converter.rb +5 -2
- data/lib/arjdbc/mssql/adapter.rb +160 -280
- data/lib/arjdbc/mssql/column.rb +182 -0
- data/lib/arjdbc/mssql/connection_methods.rb +37 -4
- data/lib/arjdbc/mssql/explain_support.rb +13 -21
- data/lib/arjdbc/mssql/limit_helpers.rb +79 -42
- data/lib/arjdbc/mssql/lock_methods.rb +77 -0
- data/lib/arjdbc/mssql/utils.rb +11 -11
- data/lib/arjdbc/mysql/adapter.rb +165 -247
- data/lib/arjdbc/mysql/column.rb +123 -0
- data/lib/arjdbc/mysql/connection_methods.rb +3 -6
- data/lib/arjdbc/oracle/adapter.rb +282 -288
- data/lib/arjdbc/oracle/column.rb +122 -0
- data/lib/arjdbc/oracle/connection_methods.rb +3 -0
- data/lib/arjdbc/postgresql/adapter.rb +336 -574
- data/lib/arjdbc/postgresql/column.rb +458 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +1 -2
- data/lib/arjdbc/postgresql/schema_creation.rb +38 -0
- data/lib/arjdbc/sqlite3/adapter.rb +189 -145
- data/lib/arjdbc/sqlite3/explain_support.rb +1 -1
- data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +8 -8
- data/lib/arjdbc/util/quoted_cache.rb +60 -0
- data/lib/arjdbc/util/table_copier.rb +110 -0
- data/lib/arjdbc/version.rb +6 -7
- data/pom.xml +56 -2
- data/rakelib/02-test.rake +72 -83
- data/rakelib/db.rake +29 -17
- data/src/java/arjdbc/ArJdbcModule.java +21 -18
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +84 -12
- data/src/java/arjdbc/derby/DerbyModule.java +140 -143
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +58 -7
- data/src/java/arjdbc/h2/H2Module.java +43 -0
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +7 -6
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1223 -648
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +24 -23
- data/src/java/arjdbc/mysql/MySQLModule.java +33 -32
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +147 -30
- data/src/java/arjdbc/oracle/OracleModule.java +13 -13
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +114 -6
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +166 -36
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +101 -19
- data/src/java/arjdbc/util/QuotingUtils.java +19 -19
- metadata +240 -394
- data/bench/bench_attributes.rb +0 -13
- data/bench/bench_attributes_new.rb +0 -14
- data/bench/bench_create.rb +0 -12
- data/bench/bench_find_all.rb +0 -12
- data/bench/bench_find_all_mt.rb +0 -25
- data/bench/bench_model.rb +0 -85
- data/bench/bench_new.rb +0 -12
- data/bench/bench_new_valid.rb +0 -12
- data/bench/bench_valid.rb +0 -13
- data/lib/arel/engines/sql/compilers/db2_compiler.rb +0 -9
- data/lib/arel/engines/sql/compilers/derby_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/h2_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/hsqldb_compiler.rb +0 -15
- data/lib/arel/engines/sql/compilers/jdbc_compiler.rb +0 -6
- data/lib/arel/engines/sql/compilers/mssql_compiler.rb +0 -46
- data/lib/arjdbc/jdbc/missing_functionality_helper.rb +0 -98
- data/lib/arjdbc/mssql/lock_helpers.rb +0 -76
- data/lib/arjdbc/mssql/tsql_methods.rb +0 -58
- data/lib/arjdbc/postgresql/column_cast.rb +0 -134
- data/test/activerecord/connections/native_jdbc_mysql/connection.rb +0 -25
- data/test/activerecord/jall.sh +0 -7
- data/test/activerecord/jtest.sh +0 -3
- data/test/assets/flowers.jpg +0 -0
- data/test/binary.rb +0 -67
- data/test/db/db2.rb +0 -43
- data/test/db/db2/binary_test.rb +0 -6
- data/test/db/db2/has_many_through_test.rb +0 -6
- data/test/db/db2/rake_test.rb +0 -82
- data/test/db/db2/rake_test_data.sql +0 -35
- data/test/db/db2/reset_column_information_test.rb +0 -5
- data/test/db/db2/serialize_test.rb +0 -6
- data/test/db/db2/simple_test.rb +0 -81
- data/test/db/db2/test_helper.rb +0 -6
- data/test/db/db2/unit_test.rb +0 -73
- data/test/db/derby.rb +0 -12
- data/test/db/derby/binary_test.rb +0 -6
- data/test/db/derby/migration_test.rb +0 -74
- data/test/db/derby/rake_test.rb +0 -96
- data/test/db/derby/reset_column_information_test.rb +0 -6
- data/test/db/derby/row_locking_test.rb +0 -20
- data/test/db/derby/schema_dump_test.rb +0 -5
- data/test/db/derby/serialize_test.rb +0 -6
- data/test/db/derby/simple_test.rb +0 -173
- data/test/db/derby/test_helper.rb +0 -6
- data/test/db/derby/unit_test.rb +0 -32
- data/test/db/derby/xml_column_test.rb +0 -17
- data/test/db/h2.rb +0 -11
- data/test/db/h2/binary_test.rb +0 -6
- data/test/db/h2/change_column_test.rb +0 -68
- data/test/db/h2/identity_column_test.rb +0 -35
- data/test/db/h2/offset_test.rb +0 -49
- data/test/db/h2/rake_test.rb +0 -98
- data/test/db/h2/schema_dump_test.rb +0 -29
- data/test/db/h2/serialize_test.rb +0 -6
- data/test/db/h2/simple_test.rb +0 -56
- data/test/db/hsqldb.rb +0 -11
- data/test/db/hsqldb/binary_test.rb +0 -6
- data/test/db/hsqldb/rake_test.rb +0 -101
- data/test/db/hsqldb/schema_dump_test.rb +0 -19
- data/test/db/hsqldb/serialize_test.rb +0 -6
- data/test/db/hsqldb/simple_test.rb +0 -17
- data/test/db/informix.rb +0 -13
- data/test/db/jdbc.rb +0 -16
- data/test/db/jdbc_derby.rb +0 -14
- data/test/db/jdbc_h2.rb +0 -17
- data/test/db/jdbc_mysql.rb +0 -13
- data/test/db/jdbc_postgres.rb +0 -23
- data/test/db/jndi_config.rb +0 -32
- data/test/db/jndi_pooled_config.rb +0 -32
- data/test/db/mssql.rb +0 -11
- data/test/db/mssql/binary_test.rb +0 -6
- data/test/db/mssql/exec_proc_test.rb +0 -46
- data/test/db/mssql/identity_insert_test.rb +0 -18
- data/test/db/mssql/ignore_system_views_test.rb +0 -40
- data/test/db/mssql/limit_offset_test.rb +0 -190
- data/test/db/mssql/multibyte_test.rb +0 -16
- data/test/db/mssql/multiple_connections_test.rb +0 -71
- data/test/db/mssql/rake_test.rb +0 -143
- data/test/db/mssql/reset_column_information_test.rb +0 -6
- data/test/db/mssql/row_locking_test.rb +0 -7
- data/test/db/mssql/serialize_test.rb +0 -6
- data/test/db/mssql/simple_test.rb +0 -140
- data/test/db/mssql/transaction_test.rb +0 -6
- data/test/db/mssql/types_test.rb +0 -205
- data/test/db/mssql/unit_test.rb +0 -249
- data/test/db/mysql.rb +0 -4
- data/test/db/mysql/_rails_test_mysql.32.out +0 -6585
- data/test/db/mysql/binary_test.rb +0 -6
- data/test/db/mysql/connection_test.rb +0 -51
- data/test/db/mysql/index_length_test.rb +0 -58
- data/test/db/mysql/multibyte_test.rb +0 -10
- data/test/db/mysql/nonstandard_primary_key_test.rb +0 -39
- data/test/db/mysql/rake_test.rb +0 -97
- data/test/db/mysql/reset_column_information_test.rb +0 -6
- data/test/db/mysql/schema_dump_test.rb +0 -228
- data/test/db/mysql/serialize_test.rb +0 -6
- data/test/db/mysql/simple_test.rb +0 -187
- data/test/db/mysql/statement_escaping_test.rb +0 -46
- data/test/db/mysql/transaction_test.rb +0 -6
- data/test/db/mysql/types_test.rb +0 -30
- data/test/db/mysql/unit_test.rb +0 -93
- data/test/db/mysql_config.rb +0 -7
- data/test/db/oracle.rb +0 -27
- data/test/db/oracle/binary_test.rb +0 -6
- data/test/db/oracle/limit_test.rb +0 -24
- data/test/db/oracle/multibyte_test.rb +0 -22
- data/test/db/oracle/rake_test.rb +0 -100
- data/test/db/oracle/reset_column_information_test.rb +0 -6
- data/test/db/oracle/serialize_test.rb +0 -6
- data/test/db/oracle/simple_test.rb +0 -140
- data/test/db/oracle/specific_test.rb +0 -180
- data/test/db/oracle/transaction_test.rb +0 -31
- data/test/db/oracle/unit_test.rb +0 -31
- data/test/db/postgres.rb +0 -11
- data/test/db/postgres/_rails_test_postgres.32.out +0 -6405
- data/test/db/postgres/a_custom_primary_key_test.rb +0 -50
- data/test/db/postgres/active_schema_unit_test.rb +0 -68
- data/test/db/postgres/array_type_test.rb +0 -101
- data/test/db/postgres/binary_test.rb +0 -6
- data/test/db/postgres/connection_test.rb +0 -63
- data/test/db/postgres/data_types_test.rb +0 -703
- data/test/db/postgres/hstore_test.rb +0 -200
- data/test/db/postgres/information_schema_leak_test.rb +0 -30
- data/test/db/postgres/json_test.rb +0 -86
- data/test/db/postgres/ltree_test.rb +0 -51
- data/test/db/postgres/mixed_case_test.rb +0 -29
- data/test/db/postgres/native_types_test.rb +0 -124
- data/test/db/postgres/rake_test.rb +0 -117
- data/test/db/postgres/reserved_test.rb +0 -22
- data/test/db/postgres/reset_column_information_test.rb +0 -6
- data/test/db/postgres/row_locking_test.rb +0 -21
- data/test/db/postgres/schema_dump_test.rb +0 -95
- data/test/db/postgres/schema_test.rb +0 -115
- data/test/db/postgres/simple_test.rb +0 -260
- data/test/db/postgres/table_alias_length_test.rb +0 -16
- data/test/db/postgres/transaction_test.rb +0 -6
- data/test/db/postgres/unit_test.rb +0 -31
- data/test/db/postgres_config.rb +0 -10
- data/test/db/sqlite3.rb +0 -6
- data/test/db/sqlite3/_rails_test_sqlite3.32.out +0 -6274
- data/test/db/sqlite3/has_many_though_test.rb +0 -6
- data/test/db/sqlite3/rake_test.rb +0 -71
- data/test/db/sqlite3/reset_column_information_test.rb +0 -6
- data/test/db/sqlite3/schema_dump_test.rb +0 -6
- data/test/db/sqlite3/serialize_test.rb +0 -6
- data/test/db/sqlite3/simple_test.rb +0 -268
- data/test/db/sqlite3/transaction_test.rb +0 -32
- data/test/db/sqlite3/type_conversion_test.rb +0 -104
- data/test/has_many_through.rb +0 -61
- data/test/informix_simple_test.rb +0 -48
- data/test/jdbc/db2.rb +0 -36
- data/test/jdbc/oracle.rb +0 -34
- data/test/jdbc_column_test.rb +0 -23
- data/test/jdbc_common.rb +0 -16
- data/test/jdbc_connection_test.rb +0 -196
- data/test/jndi_callbacks_test.rb +0 -33
- data/test/jndi_test.rb +0 -55
- data/test/manualTestDatabase.rb +0 -191
- data/test/models/add_not_null_column_to_table.rb +0 -9
- data/test/models/auto_id.rb +0 -15
- data/test/models/binary.rb +0 -18
- data/test/models/custom_pk_name.rb +0 -15
- data/test/models/data_types.rb +0 -40
- data/test/models/entry.rb +0 -41
- data/test/models/mixed_case.rb +0 -22
- data/test/models/reserved_word.rb +0 -15
- data/test/models/rights_and_roles.rb +0 -57
- data/test/models/string_id.rb +0 -17
- data/test/models/thing.rb +0 -17
- data/test/models/topic.rb +0 -32
- data/test/models/validates_uniqueness_of_string.rb +0 -19
- data/test/rails/mysql.rb +0 -13
- data/test/rails/sqlite3/version.rb +0 -6
- data/test/rails_stub.rb +0 -31
- data/test/rake_test_support.rb +0 -298
- data/test/row_locking.rb +0 -102
- data/test/schema_dump.rb +0 -182
- data/test/serialize.rb +0 -275
- data/test/shared_helper.rb +0 -35
- data/test/simple.rb +0 -1317
- data/test/sybase_jtds_simple_test.rb +0 -28
- data/test/sybase_reset_column_information_test.rb +0 -6
- data/test/test_helper.rb +0 -304
- data/test/transaction.rb +0 -109
@@ -1,35 +0,0 @@
|
|
1
|
-
CREATE TABLE EMPLOYEE (
|
2
|
-
EMPNO CHAR(6) NOT NULL,
|
3
|
-
FIRSTNME VARCHAR(12) NOT NULL,
|
4
|
-
MIDINIT CHAR(1),
|
5
|
-
LASTNAME VARCHAR(15) NOT NULL,
|
6
|
-
WORKDEPT CHAR(3),
|
7
|
-
PHONENO CHAR(4),
|
8
|
-
HIREDATE DATE,
|
9
|
-
JOB CHAR(8),
|
10
|
-
EDLEVEL SMALLINT NOT NULL,
|
11
|
-
SEX CHAR(1),
|
12
|
-
BIRTHDATE DATE,
|
13
|
-
SALARY DECIMAL(9,2),
|
14
|
-
BONUS DECIMAL(9,2),
|
15
|
-
COMM DECIMAL(9,2)
|
16
|
-
);
|
17
|
-
|
18
|
-
ALTER TABLE EMPLOYEE ADD CONSTRAINT PK_EMPLOYEE PRIMARY KEY (EMPNO);
|
19
|
-
|
20
|
-
CREATE TABLE EMP_PHOTO (
|
21
|
-
EMPNO CHAR(6) NOT NULL,
|
22
|
-
PHOTO_FORMAT VARCHAR(10) NOT NULL,
|
23
|
-
PICTURE BLOB(102400)
|
24
|
-
);
|
25
|
-
|
26
|
-
ALTER TABLE EMP_PHOTO ADD CONSTRAINT PK_EMP_PHOTO PRIMARY KEY (EMPNO, PHOTO_FORMAT);
|
27
|
-
|
28
|
-
CREATE TABLE EMP_RESUME (
|
29
|
-
EMPNO CHAR(6) NOT NULL,
|
30
|
-
RESUME_FORMAT VARCHAR(10) NOT NULL,
|
31
|
-
RESUME CLOB(5120)
|
32
|
-
);
|
33
|
-
|
34
|
-
ALTER TABLE EMP_RESUME ADD CONSTRAINT PK_EMP_RESUME PRIMARY KEY (EMPNO, RESUME_FORMAT);
|
35
|
-
|
data/test/db/db2/simple_test.rb
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
class DB2SimpleTest < Test::Unit::TestCase
|
4
|
-
include SimpleTestMethods
|
5
|
-
include ActiveRecord3TestMethods
|
6
|
-
include DirtyAttributeTests
|
7
|
-
include XmlColumnTests
|
8
|
-
|
9
|
-
def xml_sql_type; 'XML'; end
|
10
|
-
|
11
|
-
# For backwards compatibility with how the DB2 code in
|
12
|
-
# jdbc_adapter 0.9.x handled booleans.
|
13
|
-
#
|
14
|
-
# The old DB2 jdbc_db2.rb driver was broken enough that
|
15
|
-
# applications were exposed to the underlying type (was DECIMAL)
|
16
|
-
# and used 0 and 1 as false and true, respectively.
|
17
|
-
#
|
18
|
-
# This driver now uses SMALLINT as a boolean, and properly
|
19
|
-
# type cast's it to a Ruby boolean. Need to make sure we don't
|
20
|
-
# break existing apps!
|
21
|
-
def test_boolean_as_integer
|
22
|
-
e = DbType.first
|
23
|
-
|
24
|
-
# true
|
25
|
-
e.sample_boolean = 1
|
26
|
-
assert_equal true, e.sample_boolean
|
27
|
-
assert_equal true, e.sample_boolean?
|
28
|
-
e.save!
|
29
|
-
|
30
|
-
e = DbType.first
|
31
|
-
assert_equal true, e.sample_boolean
|
32
|
-
assert_equal true, e.sample_boolean?
|
33
|
-
|
34
|
-
# false
|
35
|
-
e.sample_boolean = 0
|
36
|
-
assert_equal false, e.sample_boolean
|
37
|
-
assert_equal false, e.sample_boolean?
|
38
|
-
e.save!
|
39
|
-
|
40
|
-
e = DbType.first
|
41
|
-
assert_equal false, e.sample_boolean
|
42
|
-
assert_equal false, e.sample_boolean?
|
43
|
-
end
|
44
|
-
|
45
|
-
def test_emulates_booleans_by_default
|
46
|
-
assert_true ArJdbc::DB2.emulate_booleans
|
47
|
-
end if ar_version('3.0')
|
48
|
-
|
49
|
-
def test_boolean_emulation_can_be_disabled
|
50
|
-
db_type = DbType.create! :sample_boolean => true
|
51
|
-
column = DbType.columns.find { |col| col.name.to_s == 'sample_boolean' }
|
52
|
-
assert_equal :boolean, column.type
|
53
|
-
ArJdbc::DB2.emulate_booleans = false
|
54
|
-
|
55
|
-
DbType.reset_column_information
|
56
|
-
column = DbType.columns.find { |col| col.name.to_s == 'sample_boolean' }
|
57
|
-
assert_equal :integer, column.type
|
58
|
-
|
59
|
-
assert_equal 1, db_type.reload.sample_boolean
|
60
|
-
ensure
|
61
|
-
ArJdbc::DB2.emulate_booleans = true
|
62
|
-
DbType.reset_column_information
|
63
|
-
end if ar_version('3.0')
|
64
|
-
|
65
|
-
def test_find_by_sql_WITH_statement
|
66
|
-
user = User.create! :login => 'ferko'
|
67
|
-
Entry.create! :title => 'aaa', :user_id => user.id
|
68
|
-
entries = Entry.find_by_sql '' +
|
69
|
-
'WITH EntryAndUser (title, login, updated_on) AS ' +
|
70
|
-
'(' +
|
71
|
-
' SELECT e.title, u.login, e.updated_on ' +
|
72
|
-
' FROM entries e INNER JOIN users u ON e.user_id = u.id ' +
|
73
|
-
')' +
|
74
|
-
' ' +
|
75
|
-
'SELECT * FROM EntryAndUser ORDER BY title ASC'
|
76
|
-
assert entries.first
|
77
|
-
assert entries.first.title
|
78
|
-
assert entries.first.login
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
data/test/db/db2/test_helper.rb
DELETED
data/test/db/db2/unit_test.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'arjdbc/db2'
|
3
|
-
require 'arjdbc/db2/as400'
|
4
|
-
|
5
|
-
class DB2UnitTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@adapter = Object.new
|
9
|
-
def @adapter.zos?; false; end
|
10
|
-
@adapter.extend ArJdbc::DB2
|
11
|
-
|
12
|
-
@column = Object.new
|
13
|
-
class << @column
|
14
|
-
attr_accessor :type
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'quotes decimal column' do
|
19
|
-
adapter, column = new_adapter_stub, new_column_stub
|
20
|
-
assert_equal %q{'123.45'}, adapter.quote("123.45")
|
21
|
-
column.type = :decimal
|
22
|
-
assert_equal %q{123.45}, adapter.quote("123.45", column), "decimal columns should not have quotes"
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'generated primary key' do
|
26
|
-
adapter = new_adapter_stub
|
27
|
-
assert_equal 'int not null generated by default as identity (start with 1) primary key',
|
28
|
-
adapter.modify_types({:string => {}, :integer => {}, :boolean => {}})[:primary_key]
|
29
|
-
end
|
30
|
-
|
31
|
-
test 'selects correct schema' do
|
32
|
-
url = 'jdbc:as400://localhost/schema;naming=system;libraries=lib1,lib2'
|
33
|
-
assert_equal 'schema', new_adapter_stub(:url => url).send(:db2_schema)
|
34
|
-
|
35
|
-
url = 'jdbc:as400://127.0.0.1/SCHEMA1 '
|
36
|
-
assert_equal 'SCHEMA1', new_adapter_stub(:url => url).send(:db2_schema)
|
37
|
-
|
38
|
-
url = 'jdbc:as400://127.0.0.1/SCHEMA2;'
|
39
|
-
assert_equal 'SCHEMA2', new_adapter_stub(:url => url).send(:db2_schema)
|
40
|
-
|
41
|
-
assert_equal nil, new_adapter_stub(:jndi => 'java:comp/env/DB2DS').send(:db2_schema)
|
42
|
-
|
43
|
-
config = { :host => 'localhost', :username => 'db2inst1' }
|
44
|
-
assert_equal 'db2inst1', new_adapter_stub(config).send(:db2_schema)
|
45
|
-
end
|
46
|
-
|
47
|
-
test 'quote column name returns string' do
|
48
|
-
adapter = new_adapter_stub
|
49
|
-
assert_equal 'version', adapter.quote_column_name(:version)
|
50
|
-
assert_equal 'column1', adapter.quote_column_name("column1")
|
51
|
-
end
|
52
|
-
|
53
|
-
private
|
54
|
-
|
55
|
-
def new_adapter_stub(config = {})
|
56
|
-
config = config.merge({ :adapter => 'jdbc' })
|
57
|
-
config[:adapter_spec] ||= config[:url] =~ /as400/ ? ArJdbc::AS400 : ArJdbc::DB2
|
58
|
-
connection = stub('connection'); logger = nil
|
59
|
-
connection.stub_everything
|
60
|
-
adapter = ActiveRecord::ConnectionAdapters::JdbcAdapter.new connection, logger, config
|
61
|
-
def adapter.zos?; false; end
|
62
|
-
adapter
|
63
|
-
end
|
64
|
-
|
65
|
-
def new_column_stub
|
66
|
-
column = Object.new
|
67
|
-
class << column
|
68
|
-
attr_accessor :type
|
69
|
-
end
|
70
|
-
column
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
data/test/db/derby.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
config = { :adapter => 'derby', :database => 'test.derby' }
|
4
|
-
|
5
|
-
ActiveRecord::Base.establish_connection(config)
|
6
|
-
|
7
|
-
at_exit do
|
8
|
-
Dir.glob('test*.derby').each do |dir|
|
9
|
-
FileUtils.rm_rf(dir)
|
10
|
-
File.delete(dir) if File.exist?(dir)
|
11
|
-
end
|
12
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'db/derby'
|
2
|
-
require 'jdbc_common'
|
3
|
-
|
4
|
-
class DerbyMigrationTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
class CreateDummies < ActiveRecord::Migration
|
7
|
-
|
8
|
-
def self.up
|
9
|
-
create_table :dummies, :force => true do |t|
|
10
|
-
t.string :year, :default => "", :null => false
|
11
|
-
end
|
12
|
-
add_index :dummies, :year, :unique => true
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
class ChangeColumn < ActiveRecord::Migration
|
18
|
-
|
19
|
-
def self.up
|
20
|
-
create_table :people, :id => false, :force => true do |t|
|
21
|
-
t.string :id, :limit => 22, :null => false
|
22
|
-
t.string :name, :null => false
|
23
|
-
end
|
24
|
-
change_column(:people, :name, :string, { :limit => 22 })
|
25
|
-
execute("SELECT id FROM people WHERE id = 'some string'")
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.down
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
class CreateIndex < ActiveRecord::Migration
|
34
|
-
def self.up
|
35
|
-
create_table :people, :id => false, :force => true do |t|
|
36
|
-
t.string :id, :limit => 22, :null => false
|
37
|
-
t.string :first_name, :null => false
|
38
|
-
t.string :last_name, :null => false
|
39
|
-
t.string :nickname, :null => false
|
40
|
-
t.string :long_name, :null => false
|
41
|
-
t.string :very_long_name, :null => false
|
42
|
-
t.string :extremely_long_name, :null => false
|
43
|
-
end
|
44
|
-
|
45
|
-
add_index(:people, [:first_name, :last_name, :nickname, :long_name, :very_long_name, :extremely_long_name], :unique => true)
|
46
|
-
|
47
|
-
remove_index(:people, [:first_name, :last_name, :nickname, :long_name, :very_long_name, :extremely_long_name])
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.down
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.shutdown
|
56
|
-
ActiveRecord::Base.connection.execute("DROP TABLE dummies") rescue nil
|
57
|
-
ActiveRecord::Base.connection.execute("DROP TABLE people") rescue nil
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_create_table_column_quoting_vs_keywords
|
61
|
-
CreateDummies.up
|
62
|
-
end
|
63
|
-
|
64
|
-
def test_migrate_change_column_for_non_standard_id
|
65
|
-
ChangeColumn.up
|
66
|
-
ChangeColumn.down
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_migrate_create_index
|
70
|
-
CreateIndex.up
|
71
|
-
CreateIndex.down
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
data/test/db/derby/rake_test.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'rake_test_support'
|
2
|
-
require 'db/derby'
|
3
|
-
|
4
|
-
class DerbyRakeTest < Test::Unit::TestCase
|
5
|
-
include RakeTestSupport
|
6
|
-
|
7
|
-
def db_name; 'test-rake.derby'; end
|
8
|
-
|
9
|
-
def do_teardown
|
10
|
-
drop_rake_test_database(:silence)
|
11
|
-
end
|
12
|
-
|
13
|
-
test 'rake db:create' do
|
14
|
-
Rake::Task["db:create"].invoke
|
15
|
-
assert_true File.directory?('test-rake.derby')
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'rake db:drop' do
|
19
|
-
create_rake_test_database
|
20
|
-
|
21
|
-
Rake::Task["db:drop"].invoke
|
22
|
-
assert_false File.directory?('test-rake.derby')
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'rake db:test:purge' do
|
26
|
-
ActiveRecord::Base.connection.disconnect!
|
27
|
-
# Rake::Task["db:create"].invoke
|
28
|
-
create_rake_test_database do |connection|
|
29
|
-
connection.create_table('users') { |t| t.string :name }
|
30
|
-
end
|
31
|
-
|
32
|
-
Rake::Task["db:test:purge"].invoke
|
33
|
-
|
34
|
-
ActiveRecord::Base.establish_connection db_config.merge :database => db_name
|
35
|
-
assert_false ActiveRecord::Base.connection.table_exists?('users')
|
36
|
-
ActiveRecord::Base.connection.disconnect!
|
37
|
-
end
|
38
|
-
|
39
|
-
test 'rake db:structure:dump (and db:structure:load)' do
|
40
|
-
# NOTE: need to change db name esp. when run with other (rake) tests
|
41
|
-
# since Derby can not handle too much create/rm - gets inconsistent
|
42
|
-
db_name = @db_name = 'test-dump-rake.derby'
|
43
|
-
create_rake_test_database(db_name) do |connection|
|
44
|
-
create_schema_migrations_table(connection)
|
45
|
-
connection.create_table('users') { |t| t.string :name; t.timestamps }
|
46
|
-
end
|
47
|
-
|
48
|
-
structure_sql = File.join('db', structure_sql_filename)
|
49
|
-
begin
|
50
|
-
Dir.mkdir 'db' # db/structure.sql
|
51
|
-
Rake::Task["db:structure:dump"].invoke
|
52
|
-
|
53
|
-
assert File.exists?(structure_sql)
|
54
|
-
assert_match /CREATE TABLE "?USERS"?/i, File.read(structure_sql)
|
55
|
-
|
56
|
-
# db:structure:load
|
57
|
-
ActiveRecord::Base.connection.disconnect!
|
58
|
-
# drop_rake_test_database(:silence)
|
59
|
-
ActiveRecord::Base.establish_connection db_config.merge :database => db_name
|
60
|
-
ActiveRecord::Base.connection.drop_table('users')
|
61
|
-
ActiveRecord::Base.connection.drop_table('schema_migrations')
|
62
|
-
ActiveRecord::Base.connection.disconnect!
|
63
|
-
|
64
|
-
Rake::Task["db:structure:load"].invoke
|
65
|
-
|
66
|
-
ActiveRecord::Base.establish_connection db_config.merge :database => db_name
|
67
|
-
assert ActiveRecord::Base.connection.table_exists?('users')
|
68
|
-
ActiveRecord::Base.connection.disconnect!
|
69
|
-
ensure
|
70
|
-
File.delete(structure_sql) if File.exists?(structure_sql)
|
71
|
-
Dir.rmdir 'db'
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# test 'rake db:charset' do
|
76
|
-
# expect_rake_output('UTF-8')
|
77
|
-
# Rake::Task["db:charset"].invoke
|
78
|
-
# end
|
79
|
-
|
80
|
-
def create_rake_test_database(db_name = self.db_name)
|
81
|
-
ActiveRecord::Base.establish_connection db_config.merge :database => db_name
|
82
|
-
if block_given?
|
83
|
-
yield ActiveRecord::Base.connection
|
84
|
-
end
|
85
|
-
ActiveRecord::Base.connection.disconnect!
|
86
|
-
end
|
87
|
-
|
88
|
-
def drop_rake_test_database(silence = nil)
|
89
|
-
if silence
|
90
|
-
FileUtils.rm_rf(@db_name) if File.exists?(@db_name)
|
91
|
-
else
|
92
|
-
FileUtils.rm_rf(@db_name)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
|
-
require 'row_locking'
|
3
|
-
|
4
|
-
class DerbyRowLockingTest < Test::Unit::TestCase
|
5
|
-
include MigrationSetup
|
6
|
-
include RowLockingTestMethods
|
7
|
-
|
8
|
-
# def self.startup
|
9
|
-
# MigrationSetup.setup!
|
10
|
-
# end
|
11
|
-
#
|
12
|
-
# def setup!; nil; end
|
13
|
-
#
|
14
|
-
# def self.shutdown
|
15
|
-
# MigrationSetup.teardown!
|
16
|
-
# end
|
17
|
-
#
|
18
|
-
# def teardown!; nil; end
|
19
|
-
|
20
|
-
end
|