activerecord-jdbc-adapter 0.9.7-java → 1.0.0.beta1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/Manifest.txt +71 -38
- data/lib/active_record/connection_adapters/cachedb_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/derby_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/h2_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/hsqldb_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/informix_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/jdbc_adapter.rb +1 -661
- data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/oracle_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -13
- data/lib/activerecord-jdbc-adapter.rb +2 -2
- data/lib/arjdbc.rb +29 -0
- data/lib/arjdbc/cachedb.rb +3 -0
- data/lib/arjdbc/cachedb/adapter.rb +20 -0
- data/lib/arjdbc/cachedb/connection_methods.rb +10 -0
- data/lib/arjdbc/db2.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_db2.rb → arjdbc/db2/adapter.rb} +1 -17
- data/lib/arjdbc/derby.rb +7 -0
- data/lib/{jdbc_adapter/jdbc_derby.rb → arjdbc/derby/adapter.rb} +8 -26
- data/lib/arjdbc/derby/connection_methods.rb +18 -0
- data/lib/arjdbc/discover.rb +99 -0
- data/lib/arjdbc/firebird.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_firebird.rb → arjdbc/firebird/adapter.rb} +12 -16
- data/lib/arjdbc/h2.rb +4 -0
- data/lib/arjdbc/h2/adapter.rb +15 -0
- data/lib/arjdbc/h2/connection_methods.rb +12 -0
- data/lib/arjdbc/hsqldb.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_hsqldb.rb → arjdbc/hsqldb/adapter.rb} +6 -58
- data/lib/arjdbc/hsqldb/connection_methods.rb +14 -0
- data/lib/arjdbc/informix.rb +3 -0
- data/lib/{jdbc_adapter/jdbc_informix.rb → arjdbc/informix/adapter.rb} +6 -19
- data/lib/arjdbc/informix/connection_methods.rb +10 -0
- data/lib/arjdbc/jdbc.rb +2 -0
- data/lib/arjdbc/jdbc/adapter.rb +235 -0
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/callbacks.rb +44 -0
- data/lib/arjdbc/jdbc/column.rb +38 -0
- data/lib/arjdbc/jdbc/compatibility.rb +51 -0
- data/lib/arjdbc/jdbc/connection.rb +97 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +16 -0
- data/lib/arjdbc/jdbc/core_ext.rb +24 -0
- data/lib/arjdbc/jdbc/discover.rb +18 -0
- data/lib/arjdbc/jdbc/driver.rb +44 -0
- data/lib/arjdbc/jdbc/extension.rb +47 -0
- data/lib/arjdbc/jdbc/java.rb +14 -0
- data/lib/{jdbc_adapter → arjdbc/jdbc}/jdbc.rake +0 -0
- data/lib/{jdbc_adapter → arjdbc/jdbc}/missing_functionality_helper.rb +5 -5
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +28 -0
- data/lib/{jdbc_adapter → arjdbc/jdbc}/railtie.rb +1 -1
- data/lib/{jdbc_adapter → arjdbc/jdbc}/rake_tasks.rb +0 -0
- data/lib/arjdbc/jdbc/require_driver.rb +16 -0
- data/lib/arjdbc/jdbc/type_converter.rb +119 -0
- data/lib/arjdbc/mimer.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_mimer.rb → arjdbc/mimer/adapter.rb} +16 -19
- data/lib/arjdbc/mssql.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_mssql.rb → arjdbc/mssql/adapter.rb} +19 -31
- data/lib/arjdbc/mssql/connection_methods.rb +13 -0
- data/lib/{jdbc_adapter → arjdbc/mssql}/tsql_helper.rb +1 -1
- data/lib/arjdbc/mysql.rb +4 -0
- data/lib/arjdbc/mysql/adapter.rb +388 -0
- data/lib/arjdbc/mysql/connection_methods.rb +26 -0
- data/lib/arjdbc/oracle.rb +3 -0
- data/lib/{jdbc_adapter/jdbc_oracle.rb → arjdbc/oracle/adapter.rb} +9 -17
- data/lib/arjdbc/oracle/connection_methods.rb +11 -0
- data/lib/arjdbc/postgresql.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_postgre.rb → arjdbc/postgresql/adapter.rb} +7 -36
- data/lib/arjdbc/postgresql/connection_methods.rb +21 -0
- data/lib/arjdbc/sqlite3.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_sqlite3.rb → arjdbc/sqlite3/adapter.rb} +106 -104
- data/lib/arjdbc/sqlite3/connection_methods.rb +33 -0
- data/lib/arjdbc/sybase.rb +2 -0
- data/lib/arjdbc/sybase/adapter.rb +46 -0
- data/lib/arjdbc/version.rb +8 -0
- data/lib/jdbc_adapter.rb +2 -27
- data/lib/jdbc_adapter/version.rb +3 -5
- data/rails_generators/templates/config/initializers/jdbc.rb +1 -1
- data/rakelib/compile.rake +3 -2
- data/rakelib/package.rake +3 -3
- data/src/java/{jdbc_adapter/JdbcDerbySpec.java → arjdbc/derby/DerbyModule.java} +32 -32
- data/src/java/{jdbc_adapter/JdbcAdapterInternalService.java → arjdbc/jdbc/AdapterJavaService.java} +13 -7
- data/src/java/{jdbc_adapter → arjdbc/jdbc}/JdbcConnectionFactory.java +6 -6
- data/src/java/{jdbc_adapter → arjdbc/jdbc}/RubyJdbcConnection.java +91 -16
- data/src/java/arjdbc/jdbc/SQLBlock.java +48 -0
- data/src/java/{jdbc_adapter → arjdbc/mssql}/MssqlRubyJdbcConnection.java +5 -2
- data/src/java/{jdbc_adapter/JdbcMySQLSpec.java → arjdbc/mysql/MySQLModule.java} +12 -12
- data/src/java/{jdbc_adapter/PostgresRubyJdbcConnection.java → arjdbc/postgresql/PostgresqlRubyJdbcConnection.java} +11 -9
- data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +64 -0
- data/test/abstract_db_create.rb +4 -1
- data/test/activerecord/connection_adapters/type_conversion_test.rb +1 -1
- data/test/db/cachedb.rb +0 -0
- data/test/db/derby.rb +12 -14
- data/test/db/hsqldb.rb +3 -2
- data/test/db/jndi_config.rb +4 -4
- data/test/db/sqlite3.rb +2 -6
- data/test/db2_simple_test.rb +23 -0
- data/test/derby_migration_test.rb +50 -3
- data/test/jdbc_common.rb +1 -1
- data/test/jndi_callbacks_test.rb +1 -0
- data/test/postgres_nonseq_pkey_test.rb +0 -2
- data/test/postgres_schema_search_path_test.rb +0 -2
- data/test/simple.rb +3 -3
- data/test/sybase_jtds_simple_test.rb +22 -0
- metadata +82 -46
- data/lib/active_record/connection_adapters/jdbc_adapter_spec.rb +0 -26
- data/lib/jdbc_adapter/jdbc_adapter_internal.jar +0 -0
- data/lib/jdbc_adapter/jdbc_cachedb.rb +0 -33
- data/lib/jdbc_adapter/jdbc_mysql.rb +0 -260
- data/lib/jdbc_adapter/jdbc_sybase.rb +0 -50
- data/src/java/jdbc_adapter/SQLBlock.java +0 -27
- data/src/java/jdbc_adapter/Sqlite3RubyJdbcConnection.java +0 -41
- data/test/jdbc_adapter/jdbc_db2_test.rb +0 -26
- data/test/jdbc_adapter/jdbc_sybase_test.rb +0 -33
- data/test/minirunit.rb +0 -109
- data/test/minirunit/testConnect.rb +0 -14
- data/test/minirunit/testH2.rb +0 -73
- data/test/minirunit/testHsqldb.rb +0 -73
- data/test/minirunit/testLoadActiveRecord.rb +0 -3
- data/test/minirunit/testMysql.rb +0 -83
- data/test/minirunit/testRawSelect.rb +0 -24
data/test/jdbc_common.rb
CHANGED
@@ -5,7 +5,7 @@ end
|
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
7
|
require 'pick_rails_version'
|
8
|
-
require '
|
8
|
+
require 'arjdbc' if jruby?
|
9
9
|
puts "Using activerecord version #{ActiveRecord::VERSION::STRING}"
|
10
10
|
puts "Specify version with AR_VERSION=={version} or RUBYLIB={path}"
|
11
11
|
require 'models/auto_id'
|
data/test/jndi_callbacks_test.rb
CHANGED
@@ -21,6 +21,7 @@ class JndiConnectionPoolCallbacksTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_should_call_hooks_on_checkout_and_checkin
|
24
|
+
@connection.stubs(:active?).returns(true)
|
24
25
|
@connection.expects(:disconnect!)
|
25
26
|
@adapter = ActiveRecord::ConnectionAdapters::JdbcAdapter.new @connection, @logger, @config
|
26
27
|
Entry.connection_pool.instance_variable_set "@connections", [@adapter]
|
data/test/simple.rb
CHANGED
@@ -62,7 +62,7 @@ module SimpleTestMethods
|
|
62
62
|
value = ActiveRecord::Base.connection.insert("INSERT INTO entries (title, content, rating) VALUES('insert_title', 'some content', 1)")
|
63
63
|
assert !value.nil?
|
64
64
|
entry = Entry.find_by_title('insert_title')
|
65
|
-
assert_equal
|
65
|
+
assert_equal entry.id, value
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
@@ -287,7 +287,7 @@ module SimpleTestMethods
|
|
287
287
|
|
288
288
|
if jruby?
|
289
289
|
def test_connection_valid
|
290
|
-
assert_raises(ActiveRecord::
|
290
|
+
assert_raises(ActiveRecord::JDBCError) do
|
291
291
|
@connection.raw_connection.with_connection_retry_guard do |c|
|
292
292
|
begin
|
293
293
|
stmt = c.createStatement
|
@@ -303,7 +303,7 @@ module SimpleTestMethods
|
|
303
303
|
|
304
304
|
# ENEBO: Is this really ar-jdbc-specific or a bug in our adapter?
|
305
305
|
def test_fetching_columns_for_nonexistent_table_should_raise
|
306
|
-
assert_raises(ActiveRecord::
|
306
|
+
assert_raises(ActiveRecord::JDBCError) do
|
307
307
|
Animal.columns
|
308
308
|
end
|
309
309
|
end
|
@@ -4,3 +4,25 @@ require 'db/sybase_jtds'
|
|
4
4
|
class SybaseJtdsSimpleTest < Test::Unit::TestCase
|
5
5
|
include SimpleTestMethods
|
6
6
|
end
|
7
|
+
|
8
|
+
class SybaseAdapterSelectionTest < Test::Unit::TestCase
|
9
|
+
class MockConnection
|
10
|
+
def adapter=(adapt)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_jtds_selection_using_dialect
|
15
|
+
config = {
|
16
|
+
:driver => 'net.sourceforge.jtds.Driver',
|
17
|
+
:dialect => 'sybase'
|
18
|
+
}
|
19
|
+
adapt = JdbcAdapter.new(MockConnection.new, nil, config)
|
20
|
+
assert adapt.kind_of?(ArJdbc::Sybase), "Should be a sybase adapter"
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_jtds_selection_not_using_dialect
|
24
|
+
config = { :driver => 'net.sourceforge.jtds.Driver' }
|
25
|
+
adapt = JdbcAdapter.new(MockConnection.new, nil, config)
|
26
|
+
assert adapt.kind_of?(ArJdbc::MsSQL), "Should be a MsSQL apdater"
|
27
|
+
end
|
28
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-jdbc-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
|
+
- 1
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 0
|
9
|
+
- beta1
|
10
|
+
version: 1.0.0.beta1
|
10
11
|
platform: java
|
11
12
|
authors:
|
12
13
|
- Nick Sieger, Ola Bini and JRuby contributors
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-07-20 00:00:00 -05:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
@@ -53,6 +54,7 @@ files:
|
|
53
54
|
- Rakefile
|
54
55
|
- LICENSE.txt
|
55
56
|
- lib/activerecord-jdbc-adapter.rb
|
57
|
+
- lib/arjdbc.rb
|
56
58
|
- lib/jdbc_adapter.rb
|
57
59
|
- lib/pg.rb
|
58
60
|
- lib/active_record/connection_adapters/cachedb_adapter.rb
|
@@ -61,7 +63,6 @@ files:
|
|
61
63
|
- lib/active_record/connection_adapters/hsqldb_adapter.rb
|
62
64
|
- lib/active_record/connection_adapters/informix_adapter.rb
|
63
65
|
- lib/active_record/connection_adapters/jdbc_adapter.rb
|
64
|
-
- lib/active_record/connection_adapters/jdbc_adapter_spec.rb
|
65
66
|
- lib/active_record/connection_adapters/jndi_adapter.rb
|
66
67
|
- lib/active_record/connection_adapters/mssql_adapter.rb
|
67
68
|
- lib/active_record/connection_adapters/mysql_adapter.rb
|
@@ -73,26 +74,68 @@ files:
|
|
73
74
|
- lib/arel/engines/sql/compilers/h2_compiler.rb
|
74
75
|
- lib/arel/engines/sql/compilers/hsqldb_compiler.rb
|
75
76
|
- lib/arel/engines/sql/compilers/jdbc_compiler.rb
|
77
|
+
- lib/arjdbc/cachedb.rb
|
78
|
+
- lib/arjdbc/db2.rb
|
79
|
+
- lib/arjdbc/derby.rb
|
80
|
+
- lib/arjdbc/discover.rb
|
81
|
+
- lib/arjdbc/firebird.rb
|
82
|
+
- lib/arjdbc/h2.rb
|
83
|
+
- lib/arjdbc/hsqldb.rb
|
84
|
+
- lib/arjdbc/informix.rb
|
85
|
+
- lib/arjdbc/jdbc.rb
|
86
|
+
- lib/arjdbc/mimer.rb
|
87
|
+
- lib/arjdbc/mssql.rb
|
88
|
+
- lib/arjdbc/mysql.rb
|
89
|
+
- lib/arjdbc/oracle.rb
|
90
|
+
- lib/arjdbc/postgresql.rb
|
91
|
+
- lib/arjdbc/sqlite3.rb
|
92
|
+
- lib/arjdbc/sybase.rb
|
93
|
+
- lib/arjdbc/version.rb
|
94
|
+
- lib/arjdbc/cachedb/adapter.rb
|
95
|
+
- lib/arjdbc/cachedb/connection_methods.rb
|
96
|
+
- lib/arjdbc/db2/adapter.rb
|
97
|
+
- lib/arjdbc/derby/adapter.rb
|
98
|
+
- lib/arjdbc/derby/connection_methods.rb
|
99
|
+
- lib/arjdbc/firebird/adapter.rb
|
100
|
+
- lib/arjdbc/h2/adapter.rb
|
101
|
+
- lib/arjdbc/h2/connection_methods.rb
|
102
|
+
- lib/arjdbc/hsqldb/adapter.rb
|
103
|
+
- lib/arjdbc/hsqldb/connection_methods.rb
|
104
|
+
- lib/arjdbc/informix/adapter.rb
|
105
|
+
- lib/arjdbc/informix/connection_methods.rb
|
106
|
+
- lib/arjdbc/jdbc/adapter.rb
|
107
|
+
- lib/arjdbc/jdbc/callbacks.rb
|
108
|
+
- lib/arjdbc/jdbc/column.rb
|
109
|
+
- lib/arjdbc/jdbc/compatibility.rb
|
110
|
+
- lib/arjdbc/jdbc/connection.rb
|
111
|
+
- lib/arjdbc/jdbc/connection_methods.rb
|
112
|
+
- lib/arjdbc/jdbc/core_ext.rb
|
113
|
+
- lib/arjdbc/jdbc/discover.rb
|
114
|
+
- lib/arjdbc/jdbc/driver.rb
|
115
|
+
- lib/arjdbc/jdbc/extension.rb
|
116
|
+
- lib/arjdbc/jdbc/java.rb
|
117
|
+
- lib/arjdbc/jdbc/missing_functionality_helper.rb
|
118
|
+
- lib/arjdbc/jdbc/quoted_primary_key.rb
|
119
|
+
- lib/arjdbc/jdbc/railtie.rb
|
120
|
+
- lib/arjdbc/jdbc/rake_tasks.rb
|
121
|
+
- lib/arjdbc/jdbc/require_driver.rb
|
122
|
+
- lib/arjdbc/jdbc/type_converter.rb
|
123
|
+
- lib/arjdbc/mimer/adapter.rb
|
124
|
+
- lib/arjdbc/mssql/adapter.rb
|
125
|
+
- lib/arjdbc/mssql/connection_methods.rb
|
126
|
+
- lib/arjdbc/mssql/tsql_helper.rb
|
127
|
+
- lib/arjdbc/mysql/adapter.rb
|
128
|
+
- lib/arjdbc/mysql/connection_methods.rb
|
129
|
+
- lib/arjdbc/oracle/adapter.rb
|
130
|
+
- lib/arjdbc/oracle/connection_methods.rb
|
131
|
+
- lib/arjdbc/postgresql/adapter.rb
|
132
|
+
- lib/arjdbc/postgresql/connection_methods.rb
|
133
|
+
- lib/arjdbc/sqlite3/adapter.rb
|
134
|
+
- lib/arjdbc/sqlite3/connection_methods.rb
|
135
|
+
- lib/arjdbc/sybase/adapter.rb
|
76
136
|
- lib/generators/jdbc/jdbc_generator.rb
|
77
|
-
- lib/jdbc_adapter/jdbc_cachedb.rb
|
78
|
-
- lib/jdbc_adapter/jdbc_db2.rb
|
79
|
-
- lib/jdbc_adapter/jdbc_derby.rb
|
80
|
-
- lib/jdbc_adapter/jdbc_firebird.rb
|
81
|
-
- lib/jdbc_adapter/jdbc_hsqldb.rb
|
82
|
-
- lib/jdbc_adapter/jdbc_informix.rb
|
83
|
-
- lib/jdbc_adapter/jdbc_mimer.rb
|
84
|
-
- lib/jdbc_adapter/jdbc_mssql.rb
|
85
|
-
- lib/jdbc_adapter/jdbc_mysql.rb
|
86
|
-
- lib/jdbc_adapter/jdbc_oracle.rb
|
87
|
-
- lib/jdbc_adapter/jdbc_postgre.rb
|
88
|
-
- lib/jdbc_adapter/jdbc_sqlite3.rb
|
89
|
-
- lib/jdbc_adapter/jdbc_sybase.rb
|
90
|
-
- lib/jdbc_adapter/missing_functionality_helper.rb
|
91
|
-
- lib/jdbc_adapter/railtie.rb
|
92
|
-
- lib/jdbc_adapter/rake_tasks.rb
|
93
|
-
- lib/jdbc_adapter/tsql_helper.rb
|
94
137
|
- lib/jdbc_adapter/version.rb
|
95
|
-
- lib/
|
138
|
+
- lib/arjdbc/jdbc/adapter_java.jar
|
96
139
|
- test/abstract_db_create.rb
|
97
140
|
- test/cachedb_simple_test.rb
|
98
141
|
- test/db2_simple_test.rb
|
@@ -109,7 +152,6 @@ files:
|
|
109
152
|
- test/jndi_callbacks_test.rb
|
110
153
|
- test/jndi_test.rb
|
111
154
|
- test/manualTestDatabase.rb
|
112
|
-
- test/minirunit.rb
|
113
155
|
- test/mssql_db_create_test.rb
|
114
156
|
- test/mssql_identity_insert_test.rb
|
115
157
|
- test/mssql_legacy_types_test.rb
|
@@ -148,14 +190,6 @@ files:
|
|
148
190
|
- test/db/oracle.rb
|
149
191
|
- test/db/postgres.rb
|
150
192
|
- test/db/sqlite3.rb
|
151
|
-
- test/jdbc_adapter/jdbc_db2_test.rb
|
152
|
-
- test/jdbc_adapter/jdbc_sybase_test.rb
|
153
|
-
- test/minirunit/testConnect.rb
|
154
|
-
- test/minirunit/testH2.rb
|
155
|
-
- test/minirunit/testHsqldb.rb
|
156
|
-
- test/minirunit/testLoadActiveRecord.rb
|
157
|
-
- test/minirunit/testMysql.rb
|
158
|
-
- test/minirunit/testRawSelect.rb
|
159
193
|
- test/models/add_not_null_column_to_table.rb
|
160
194
|
- test/models/auto_id.rb
|
161
195
|
- test/models/data_types.rb
|
@@ -164,16 +198,16 @@ files:
|
|
164
198
|
- test/models/reserved_word.rb
|
165
199
|
- test/models/string_id.rb
|
166
200
|
- test/models/validates_uniqueness_of_string.rb
|
167
|
-
- lib/
|
168
|
-
- src/java/
|
169
|
-
- src/java/
|
170
|
-
- src/java/
|
171
|
-
- src/java/
|
172
|
-
- src/java/
|
173
|
-
- src/java/
|
174
|
-
- src/java/
|
175
|
-
- src/java/
|
176
|
-
- src/java/
|
201
|
+
- lib/arjdbc/jdbc/jdbc.rake
|
202
|
+
- src/java/arjdbc/derby/DerbyModule.java
|
203
|
+
- src/java/arjdbc/jdbc/AdapterJavaService.java
|
204
|
+
- src/java/arjdbc/jdbc/JdbcConnectionFactory.java
|
205
|
+
- src/java/arjdbc/jdbc/RubyJdbcConnection.java
|
206
|
+
- src/java/arjdbc/jdbc/SQLBlock.java
|
207
|
+
- src/java/arjdbc/mssql/MssqlRubyJdbcConnection.java
|
208
|
+
- src/java/arjdbc/mysql/MySQLModule.java
|
209
|
+
- src/java/arjdbc/postgresql/PostgresqlRubyJdbcConnection.java
|
210
|
+
- src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java
|
177
211
|
- rakelib/compile.rake
|
178
212
|
- rakelib/package.rake
|
179
213
|
- rakelib/rails.rake
|
@@ -202,11 +236,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
202
236
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
203
237
|
none: false
|
204
238
|
requirements:
|
205
|
-
- - "
|
239
|
+
- - ">"
|
206
240
|
- !ruby/object:Gem::Version
|
207
241
|
segments:
|
208
|
-
-
|
209
|
-
|
242
|
+
- 1
|
243
|
+
- 3
|
244
|
+
- 1
|
245
|
+
version: 1.3.1
|
210
246
|
requirements: []
|
211
247
|
|
212
248
|
rubyforge_project: jruby-extras
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module JdbcSpec
|
2
|
-
module ActiveRecordExtensions
|
3
|
-
def self.add_method_to_remove_from_ar_base(meth)
|
4
|
-
@methods ||= []
|
5
|
-
@methods << meth
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.extended(klass)
|
9
|
-
(@methods || []).each {|m| (class << klass; self; end).instance_eval { remove_method(m) rescue nil } }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'jdbc_adapter/jdbc_mimer'
|
15
|
-
require 'jdbc_adapter/jdbc_hsqldb'
|
16
|
-
require 'jdbc_adapter/jdbc_oracle'
|
17
|
-
require 'jdbc_adapter/jdbc_postgre'
|
18
|
-
require 'jdbc_adapter/jdbc_mysql'
|
19
|
-
require 'jdbc_adapter/jdbc_derby'
|
20
|
-
require 'jdbc_adapter/jdbc_firebird'
|
21
|
-
require 'jdbc_adapter/jdbc_db2'
|
22
|
-
require 'jdbc_adapter/jdbc_mssql'
|
23
|
-
require 'jdbc_adapter/jdbc_cachedb'
|
24
|
-
require 'jdbc_adapter/jdbc_sqlite3'
|
25
|
-
require 'jdbc_adapter/jdbc_sybase'
|
26
|
-
require 'jdbc_adapter/jdbc_informix'
|
Binary file
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'jdbc_adapter/tsql_helper'
|
2
|
-
|
3
|
-
module ::JdbcSpec
|
4
|
-
module ActiveRecordExtensions
|
5
|
-
def cachedb_connection( config )
|
6
|
-
config[:port] ||= 1972
|
7
|
-
config[:url] ||= "jdbc:Cache://#{config[:host]}:#{config[:port]}/#{ config[:database]}"
|
8
|
-
config[:driver] ||= "com.intersys.jdbc.CacheDriver"
|
9
|
-
jdbc_connection( config )
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
module CacheDB
|
14
|
-
include TSqlMethods
|
15
|
-
|
16
|
-
def self.adapter_matcher(name, *)
|
17
|
-
name =~ /cache/i ? self : false
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.column_selector
|
21
|
-
[ /cache/i, lambda { | cfg, col | col.extend( ::JdbcSpec::CacheDB::Column ) } ]
|
22
|
-
end
|
23
|
-
|
24
|
-
module Column
|
25
|
-
end
|
26
|
-
|
27
|
-
def create_table(name, options = { })
|
28
|
-
super(name, options)
|
29
|
-
primary_key = options[:primary_key] || "id"
|
30
|
-
execute "ALTER TABLE #{name} ADD CONSTRAINT #{name}_PK PRIMARY KEY(#{primary_key})" unless options[:id] == false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,260 +0,0 @@
|
|
1
|
-
require 'active_record/connection_adapters/abstract/schema_definitions'
|
2
|
-
|
3
|
-
module ::JdbcSpec
|
4
|
-
# Don't need to load native mysql adapter
|
5
|
-
$LOADED_FEATURES << "active_record/connection_adapters/mysql_adapter.rb"
|
6
|
-
|
7
|
-
module ActiveRecordExtensions
|
8
|
-
add_method_to_remove_from_ar_base(:mysql_connection)
|
9
|
-
|
10
|
-
def mysql_connection(config)
|
11
|
-
require File.dirname(__FILE__) + "/../active_record/connection_adapters/mysql_adapter"
|
12
|
-
config[:port] ||= 3306
|
13
|
-
url_options = "zeroDateTimeBehavior=convertToNull&jdbcCompliantTruncation=false&useUnicode=true&characterEncoding="
|
14
|
-
url_options << (config[:encoding] || 'utf8')
|
15
|
-
if config[:url]
|
16
|
-
config[:url] = config[:url]['?'] ? "#{config[:url]}&#{url_options}" : "#{config[:url]}?#{url_options}"
|
17
|
-
else
|
18
|
-
config[:url] = "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}?#{url_options}"
|
19
|
-
end
|
20
|
-
config[:driver] = "com.mysql.jdbc.Driver"
|
21
|
-
connection = jdbc_connection(config)
|
22
|
-
::JdbcSpec::MySQL.kill_cancel_timer(connection.raw_connection)
|
23
|
-
connection
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
module MySQL
|
28
|
-
def self.adapter_matcher(name, *)
|
29
|
-
name =~ /mysql/i ? self : false
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.column_selector
|
33
|
-
[/mysql/i, lambda {|cfg,col| col.extend(::JdbcSpec::MySQL::Column)}]
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.extended(adapter)
|
37
|
-
adapter.execute("SET SQL_AUTO_IS_NULL=0")
|
38
|
-
end
|
39
|
-
|
40
|
-
module Column
|
41
|
-
TYPES_ALLOWING_EMPTY_STRING_DEFAULT = Set.new([:binary, :string, :text])
|
42
|
-
|
43
|
-
def simplified_type(field_type)
|
44
|
-
return :boolean if field_type =~ /tinyint\(1\)|bit/i
|
45
|
-
return :string if field_type =~ /enum/i
|
46
|
-
super
|
47
|
-
end
|
48
|
-
|
49
|
-
def init_column(name, default, *args)
|
50
|
-
@original_default = default
|
51
|
-
@default = nil if missing_default_forged_as_empty_string?
|
52
|
-
end
|
53
|
-
|
54
|
-
# MySQL misreports NOT NULL column default when none is given.
|
55
|
-
# We can't detect this for columns which may have a legitimate ''
|
56
|
-
# default (string, text, binary) but we can for others (integer,
|
57
|
-
# datetime, boolean, and the rest).
|
58
|
-
#
|
59
|
-
# Test whether the column has default '', is not null, and is not
|
60
|
-
# a type allowing default ''.
|
61
|
-
def missing_default_forged_as_empty_string?
|
62
|
-
!null && @original_default == '' && !TYPES_ALLOWING_EMPTY_STRING_DEFAULT.include?(type)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def modify_types(tp)
|
67
|
-
tp[:primary_key] = "int(11) DEFAULT NULL auto_increment PRIMARY KEY"
|
68
|
-
tp[:decimal] = { :name => "decimal" }
|
69
|
-
tp[:timestamp] = { :name => "datetime" }
|
70
|
-
tp[:datetime][:limit] = nil
|
71
|
-
tp
|
72
|
-
end
|
73
|
-
|
74
|
-
def adapter_name #:nodoc:
|
75
|
-
'mysql'
|
76
|
-
end
|
77
|
-
|
78
|
-
# QUOTING ==================================================
|
79
|
-
|
80
|
-
def quote(value, column = nil)
|
81
|
-
return value.quoted_id if value.respond_to?(:quoted_id)
|
82
|
-
|
83
|
-
if column && column.type == :primary_key
|
84
|
-
value.to_s
|
85
|
-
elsif column && String === value && column.type == :binary && column.class.respond_to?(:string_to_binary)
|
86
|
-
s = column.class.string_to_binary(value).unpack("H*")[0]
|
87
|
-
"x'#{s}'"
|
88
|
-
elsif BigDecimal === value
|
89
|
-
"'#{value.to_s("F")}'"
|
90
|
-
else
|
91
|
-
super
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def quoted_true
|
96
|
-
"1"
|
97
|
-
end
|
98
|
-
|
99
|
-
def quoted_false
|
100
|
-
"0"
|
101
|
-
end
|
102
|
-
|
103
|
-
def begin_db_transaction #:nodoc:
|
104
|
-
@connection.begin
|
105
|
-
rescue Exception
|
106
|
-
# Transactions aren't supported
|
107
|
-
end
|
108
|
-
|
109
|
-
def commit_db_transaction #:nodoc:
|
110
|
-
@connection.commit
|
111
|
-
rescue Exception
|
112
|
-
# Transactions aren't supported
|
113
|
-
end
|
114
|
-
|
115
|
-
def rollback_db_transaction #:nodoc:
|
116
|
-
@connection.rollback
|
117
|
-
rescue Exception
|
118
|
-
# Transactions aren't supported
|
119
|
-
end
|
120
|
-
|
121
|
-
def supports_savepoints? #:nodoc:
|
122
|
-
true
|
123
|
-
end
|
124
|
-
|
125
|
-
def create_savepoint
|
126
|
-
execute("SAVEPOINT #{current_savepoint_name}")
|
127
|
-
end
|
128
|
-
|
129
|
-
def rollback_to_savepoint
|
130
|
-
execute("ROLLBACK TO SAVEPOINT #{current_savepoint_name}")
|
131
|
-
end
|
132
|
-
|
133
|
-
def release_savepoint
|
134
|
-
execute("RELEASE SAVEPOINT #{current_savepoint_name}")
|
135
|
-
end
|
136
|
-
|
137
|
-
def disable_referential_integrity(&block) #:nodoc:
|
138
|
-
old = select_value("SELECT @@FOREIGN_KEY_CHECKS")
|
139
|
-
begin
|
140
|
-
update("SET FOREIGN_KEY_CHECKS = 0")
|
141
|
-
yield
|
142
|
-
ensure
|
143
|
-
update("SET FOREIGN_KEY_CHECKS = #{old}")
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
# SCHEMA STATEMENTS ========================================
|
148
|
-
|
149
|
-
def structure_dump #:nodoc:
|
150
|
-
if supports_views?
|
151
|
-
sql = "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE'"
|
152
|
-
else
|
153
|
-
sql = "SHOW TABLES"
|
154
|
-
end
|
155
|
-
|
156
|
-
select_all(sql).inject("") do |structure, table|
|
157
|
-
table.delete('Table_type')
|
158
|
-
|
159
|
-
hash = show_create_table(table.to_a.first.last)
|
160
|
-
|
161
|
-
if(table = hash["Create Table"])
|
162
|
-
structure += table + ";\n\n"
|
163
|
-
elsif(view = hash["Create View"])
|
164
|
-
structure += view + ";\n\n"
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
def recreate_database(name, options = {}) #:nodoc:
|
170
|
-
drop_database(name)
|
171
|
-
create_database(name, options)
|
172
|
-
end
|
173
|
-
|
174
|
-
def character_set(options) #:nodoc:
|
175
|
-
str = "CHARACTER SET `#{options[:charset] || 'utf8'}`"
|
176
|
-
str += " COLLATE `#{options[:collation]}`" if options[:collation]
|
177
|
-
str
|
178
|
-
end
|
179
|
-
private :character_set
|
180
|
-
|
181
|
-
def create_database(name, options = {}) #:nodoc:
|
182
|
-
execute "CREATE DATABASE `#{name}` DEFAULT #{character_set(options)}"
|
183
|
-
end
|
184
|
-
|
185
|
-
def drop_database(name) #:nodoc:
|
186
|
-
execute "DROP DATABASE IF EXISTS `#{name}`"
|
187
|
-
end
|
188
|
-
|
189
|
-
def current_database
|
190
|
-
select_one("SELECT DATABASE() as db")["db"]
|
191
|
-
end
|
192
|
-
|
193
|
-
def create_table(name, options = {}) #:nodoc:
|
194
|
-
super(name, {:options => "ENGINE=InnoDB #{character_set(options)}"}.merge(options))
|
195
|
-
end
|
196
|
-
|
197
|
-
def rename_table(name, new_name)
|
198
|
-
execute "RENAME TABLE #{quote_table_name(name)} TO #{quote_table_name(new_name)}"
|
199
|
-
end
|
200
|
-
|
201
|
-
def change_column_default(table_name, column_name, default) #:nodoc:
|
202
|
-
current_type = select_one("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE '#{column_name}'")["Type"]
|
203
|
-
|
204
|
-
execute("ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(column_name)} #{current_type} DEFAULT #{quote(default)}")
|
205
|
-
end
|
206
|
-
|
207
|
-
def change_column(table_name, column_name, type, options = {}) #:nodoc:
|
208
|
-
unless options_include_default?(options)
|
209
|
-
if column = columns(table_name).find { |c| c.name == column_name.to_s }
|
210
|
-
options[:default] = column.default
|
211
|
-
else
|
212
|
-
raise "No such column: #{table_name}.#{column_name}"
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
change_column_sql = "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_column_name(column_name)} #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}"
|
217
|
-
add_column_options!(change_column_sql, options)
|
218
|
-
execute(change_column_sql)
|
219
|
-
end
|
220
|
-
|
221
|
-
def rename_column(table_name, column_name, new_column_name) #:nodoc:
|
222
|
-
cols = select_one("SHOW COLUMNS FROM #{quote_table_name(table_name)} LIKE '#{column_name}'")
|
223
|
-
current_type = cols["Type"] || cols["COLUMN_TYPE"]
|
224
|
-
execute "ALTER TABLE #{quote_table_name(table_name)} CHANGE #{quote_table_name(column_name)} #{quote_column_name(new_column_name)} #{current_type}"
|
225
|
-
end
|
226
|
-
|
227
|
-
def add_limit_offset!(sql, options) #:nodoc:
|
228
|
-
if limit = options[:limit]
|
229
|
-
unless offset = options[:offset]
|
230
|
-
sql << " LIMIT #{limit}"
|
231
|
-
else
|
232
|
-
sql << " LIMIT #{offset}, #{limit}"
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
def show_variable(var)
|
238
|
-
res = execute("show variables like '#{var}'")
|
239
|
-
row = res.detect {|row| row["Variable_name"] == var }
|
240
|
-
row && row["Value"]
|
241
|
-
end
|
242
|
-
|
243
|
-
def charset
|
244
|
-
show_variable("character_set_database")
|
245
|
-
end
|
246
|
-
|
247
|
-
def collation
|
248
|
-
show_variable("collation_database")
|
249
|
-
end
|
250
|
-
|
251
|
-
private
|
252
|
-
def show_create_table(table)
|
253
|
-
select_one("SHOW CREATE TABLE #{quote_table_name(table)}")
|
254
|
-
end
|
255
|
-
|
256
|
-
def supports_views?
|
257
|
-
false
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|