activerecord-jdbc-adapter 0.7 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +1 -1
- data/README.txt +2 -0
- data/Rakefile +5 -3
- data/lib/active_record/connection_adapters/jdbc_adapter.rb +5 -0
- data/lib/jdbc_adapter.rb +0 -8
- data/lib/jdbc_adapter/jdbc_adapter_internal.jar +0 -0
- data/lib/jdbc_adapter/jdbc_hsqldb.rb +4 -0
- data/lib/jdbc_adapter/jdbc_mysql.rb +6 -2
- data/lib/{tasks/jdbc_databases.rake → jdbc_adapter/rake_tasks.rb} +12 -34
- data/lib/jdbc_adapter/version.rb +1 -1
- data/src/java/jdbc_adapter/JdbcAdapterInternalService.java +3 -3
- data/test/h2_simple_test.rb +0 -1
- data/test/simple.rb +12 -0
- metadata +3 -3
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
@@ -22,6 +22,7 @@ lib/jdbc_adapter/jdbc_mysql.rb
|
|
22
22
|
lib/jdbc_adapter/jdbc_oracle.rb
|
23
23
|
lib/jdbc_adapter/jdbc_postgre.rb
|
24
24
|
lib/jdbc_adapter/missing_functionality_helper.rb
|
25
|
+
lib/jdbc_adapter/rake_tasks.rb
|
25
26
|
lib/jdbc_adapter/version.rb
|
26
27
|
lib/jdbc_adapter.rb
|
27
28
|
lib/jdbc_adapter/jdbc_adapter_internal.jar
|
@@ -59,7 +60,6 @@ test/mysql_multibyte_test.rb
|
|
59
60
|
test/mysql_simple_test.rb
|
60
61
|
test/postgres_simple_test.rb
|
61
62
|
test/simple.rb
|
62
|
-
lib/tasks/jdbc_databases.rake
|
63
63
|
src/java/jdbc_adapter/JdbcAdapterInternalService.java
|
64
64
|
src/java/jdbc_adapter/JdbcConnectionFactory.java
|
65
65
|
src/java/jdbc_adapter/JdbcDerbySpec.java
|
data/README.txt
CHANGED
@@ -25,6 +25,7 @@ What's there, and what is not there:
|
|
25
25
|
* remove_column
|
26
26
|
* rename_column
|
27
27
|
* HSQLDB - Complete
|
28
|
+
* H2 - Complete
|
28
29
|
|
29
30
|
Other databases will require testing and likely a custom configuration module. Please join the jruby-extras mailing-list[http://rubyforge.org/mail/?group_id=2014] to help us discover support for more databases.
|
30
31
|
|
@@ -41,6 +42,7 @@ To use ActiveRecord-JDBC with JRuby on Rails:
|
|
41
42
|
* postgresql (<tt>activerecord-jdbcpostgresql-adapter</tt>)
|
42
43
|
* derby (<tt>activerecord-jdbcderby-adapter</tt>)
|
43
44
|
* hsqldb (<tt>activerecord-jdbchsqldb-adapter</tt>)
|
45
|
+
* h2 (<tt>activerecord-jdbch2-adapter</tt>)
|
44
46
|
|
45
47
|
2. If you're using Rails 2.0, you may skip to the next step. For Rails prior to version 2.0, you'll need to add one-time setup to your config/environment.rb file in your Rails application. Add the following lines just before the <code>Rails::Initializer</code>. (If you're using ActiveRecord-JDBC under the old gem name used in versions 0.5 and earlier, replace 'activerecord-jdbc-adapter' with 'ActiveRecord-JDBC' below.)
|
46
48
|
|
data/Rakefile
CHANGED
@@ -18,9 +18,11 @@ end
|
|
18
18
|
|
19
19
|
desc "Compile the native Java code."
|
20
20
|
task :java_compile do
|
21
|
-
|
21
|
+
pkg_classes = File.join(*%w(pkg classes))
|
22
|
+
jar_name = File.join(*%w(lib jdbc_adapter jdbc_adapter_internal.jar))
|
23
|
+
mkdir_p pkg_classes
|
22
24
|
sh "javac -target 1.4 -source 1.4 -d pkg/classes #{java_classpath_arg} #{FileList['src/java/**/*.java'].join(' ')}"
|
23
|
-
sh "jar cf
|
25
|
+
sh "jar cf #{jar_name} -C #{pkg_classes} ."
|
24
26
|
end
|
25
27
|
file "lib/jdbc_adapter/jdbc_adapter_internal.jar" => :java_compile
|
26
28
|
|
@@ -40,7 +42,7 @@ end
|
|
40
42
|
|
41
43
|
if RUBY_PLATFORM =~ /java/
|
42
44
|
# TODO: add more databases into the standard tests here.
|
43
|
-
task :test => [:test_mysql, :test_jdbc, :test_derby, :test_hsqldb]
|
45
|
+
task :test => [:test_mysql, :test_jdbc, :test_derby, :test_hsqldb, :test_h2]
|
44
46
|
else
|
45
47
|
task :test => [:test_mysql]
|
46
48
|
end
|
@@ -4,6 +4,11 @@ require 'active_record/connection_adapters/jdbc_adapter_spec'
|
|
4
4
|
require 'jdbc_adapter/jdbc_adapter_internal'
|
5
5
|
require 'bigdecimal'
|
6
6
|
|
7
|
+
begin
|
8
|
+
require 'jdbc_adapter/rake_tasks'
|
9
|
+
rescue LoadError
|
10
|
+
end if defined?(RAILS_ROOT)
|
11
|
+
|
7
12
|
module ActiveRecord
|
8
13
|
module ConnectionAdapters # :nodoc:
|
9
14
|
module SchemaStatements
|
data/lib/jdbc_adapter.rb
CHANGED
@@ -19,14 +19,6 @@ if RUBY_PLATFORM =~ /java/
|
|
19
19
|
require 'active_record/connection_adapters/jdbc_adapter'
|
20
20
|
end
|
21
21
|
end
|
22
|
-
if defined?(RAILS_ROOT)
|
23
|
-
to_file = File.expand_path(File.join(RAILS_ROOT, 'lib', 'tasks', 'jdbc_databases.rake'))
|
24
|
-
from_file = File.expand_path(File.join(File.dirname(__FILE__), 'tasks', 'jdbc_databases.rake'))
|
25
|
-
if !File.exist?(to_file) || (File.mtime(to_file) < File.mtime(from_file))
|
26
|
-
require 'fileutils'
|
27
|
-
FileUtils.cp from_file, to_file, :verbose => true
|
28
|
-
end
|
29
|
-
end
|
30
22
|
else
|
31
23
|
warn "ActiveRecord-JDBC is for use with JRuby only"
|
32
24
|
end
|
Binary file
|
@@ -164,5 +164,9 @@ module ::JdbcSpec
|
|
164
164
|
def tables
|
165
165
|
@connection.tables.select {|row| row.to_s !~ /^system_/i }
|
166
166
|
end
|
167
|
+
|
168
|
+
def remove_index(table_name, options = {})
|
169
|
+
execute "DROP INDEX #{quote_column_name(index_name(table_name, options))}"
|
170
|
+
end
|
167
171
|
end
|
168
172
|
end
|
@@ -7,7 +7,11 @@ module ::JdbcSpec
|
|
7
7
|
warn "AR-JDBC MySQL on JRuby does not support sockets"
|
8
8
|
end
|
9
9
|
config[:port] ||= 3306
|
10
|
-
config[:url]
|
10
|
+
if config[:url]
|
11
|
+
config[:url] = config[:url]['?'] ? "#{config[:url]}&#{MySQL::URL_OPTIONS}" : "#{config[:url]}?#{MySQL::URL_OPTIONS}"
|
12
|
+
else
|
13
|
+
config[:url] = "jdbc:mysql://#{config[:host]}:#{config[:port]}/#{config[:database]}?#{MySQL::URL_OPTIONS}"
|
14
|
+
end
|
11
15
|
config[:driver] = "com.mysql.jdbc.Driver"
|
12
16
|
jdbc_connection(config)
|
13
17
|
end
|
@@ -207,4 +211,4 @@ module ::JdbcSpec
|
|
207
211
|
false
|
208
212
|
end
|
209
213
|
end
|
210
|
-
end
|
214
|
+
end
|
@@ -1,42 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
deps = deps.collect {|d| d.to_s }
|
10
|
-
task = @tasks[task_name.to_s] = task_class.new(task_name, self)
|
11
|
-
task.application = self
|
12
|
-
task.add_comment(@last_comment)
|
13
|
-
@last_comment = nil
|
14
|
-
task.enhance(deps, &block)
|
15
|
-
task
|
16
|
-
end
|
17
|
-
end
|
18
|
-
class Task
|
19
|
-
class << self
|
20
|
-
def redefine_task(args, &block)
|
21
|
-
Rake.application.redefine_task(self, args, &block)
|
22
|
-
end
|
23
|
-
end
|
1
|
+
if defined?(namespace) && RUBY_PLATFORM =~ /java/ && ENV["SKIP_AR_JDBC_RAKE_REDEFINES"].nil?
|
2
|
+
def redefine_task(*args, &block)
|
3
|
+
task_name = Hash === args.first ? args.first.keys[0] : args.first
|
4
|
+
existing_task = Rake::Task[task_name]
|
5
|
+
class << existing_task; public :instance_variable_set; end
|
6
|
+
existing_task.instance_variable_set "@prerequisites", FileList[]
|
7
|
+
existing_task.instance_variable_set "@actions", []
|
8
|
+
task(*args, &block)
|
24
9
|
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def redefine_task(args, &block)
|
28
|
-
Rake::Task.redefine_task(args, &block)
|
29
|
-
end
|
30
10
|
|
31
|
-
if RUBY_PLATFORM =~ /java/
|
32
11
|
namespace :db do
|
33
|
-
redefine_task :drop => :environment do
|
34
|
-
begin
|
12
|
+
redefine_task :drop => :environment do
|
13
|
+
begin
|
35
14
|
config = ActiveRecord::Base.configurations[environment_name]
|
36
15
|
ActiveRecord::Base.establish_connection(config)
|
37
16
|
db = ActiveRecord::Base.connection.database_name
|
38
17
|
ActiveRecord::Base.connection.recreate_database(db)
|
39
|
-
rescue
|
18
|
+
rescue
|
40
19
|
end
|
41
20
|
end
|
42
21
|
|
@@ -66,7 +45,6 @@ if RUBY_PLATFORM =~ /java/
|
|
66
45
|
db = ActiveRecord::Base.connection.database_name
|
67
46
|
ActiveRecord::Base.connection.recreate_database(db)
|
68
47
|
end
|
69
|
-
end
|
48
|
+
end
|
70
49
|
end
|
71
50
|
end
|
72
|
-
|
data/lib/jdbc_adapter/version.rb
CHANGED
@@ -668,7 +668,7 @@ public class JdbcAdapterInternalService implements BasicLibraryService {
|
|
668
668
|
int[] col_scale = new int[col_count];
|
669
669
|
|
670
670
|
for(int i=0;i<col_count;i++) {
|
671
|
-
col_names[i] =
|
671
|
+
col_names[i] = RubyString.newUnicodeString(runtime, metadata.getColumnName(i+1).toLowerCase());
|
672
672
|
col_types[i] = metadata.getColumnType(i+1);
|
673
673
|
col_scale[i] = metadata.getScale(i+1);
|
674
674
|
}
|
@@ -707,7 +707,7 @@ public class JdbcAdapterInternalService implements BasicLibraryService {
|
|
707
707
|
if(storesUpper && !HAS_SMALL.matcher(s1).find()) {
|
708
708
|
s1 = s1.toLowerCase();
|
709
709
|
}
|
710
|
-
col_names[i] =
|
710
|
+
col_names[i] = RubyString.newUnicodeString(runtime, s1);
|
711
711
|
col_types[i] = metadata.getColumnType(i+1);
|
712
712
|
col_scale[i] = metadata.getScale(i+1);
|
713
713
|
}
|
@@ -741,7 +741,7 @@ public class JdbcAdapterInternalService implements BasicLibraryService {
|
|
741
741
|
int[] col_scale = new int[col_count];
|
742
742
|
|
743
743
|
for (int i=0;i<col_count;i++) {
|
744
|
-
col_names[i] =
|
744
|
+
col_names[i] = RubyString.newUnicodeString(runtime, metadata.getColumnName(i+1));
|
745
745
|
col_types[i] = metadata.getColumnType(i+1);
|
746
746
|
col_scale[i] = metadata.getScale(i+1);
|
747
747
|
}
|
data/test/h2_simple_test.rb
CHANGED
data/test/simple.rb
CHANGED
@@ -167,6 +167,18 @@ module MultibyteTestMethods
|
|
167
167
|
super
|
168
168
|
end
|
169
169
|
|
170
|
+
def test_multibyte_aliasing
|
171
|
+
str = "テスト"
|
172
|
+
quoted_alias = Entry.connection.quote_column_name(str)
|
173
|
+
sql = "SELECT title AS #{quoted_alias} from entries"
|
174
|
+
records = Entry.connection.select_all(sql)
|
175
|
+
records.each do |rec|
|
176
|
+
rec.keys.each do |key|
|
177
|
+
assert_equal str, key
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
170
182
|
def test_select_multibyte_string
|
171
183
|
@java_con.createStatement().execute("insert into entries (title, content) values ('テスト', '本文')")
|
172
184
|
entry = Entry.find(:first)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: activerecord-jdbc-adapter
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date:
|
6
|
+
version: 0.7.1
|
7
|
+
date: 2008-01-06 00:00:00 -06:00
|
8
8
|
summary: JDBC adapter for ActiveRecord, for use within JRuby on Rails.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -53,6 +53,7 @@ files:
|
|
53
53
|
- lib/jdbc_adapter/jdbc_oracle.rb
|
54
54
|
- lib/jdbc_adapter/jdbc_postgre.rb
|
55
55
|
- lib/jdbc_adapter/missing_functionality_helper.rb
|
56
|
+
- lib/jdbc_adapter/rake_tasks.rb
|
56
57
|
- lib/jdbc_adapter/version.rb
|
57
58
|
- lib/jdbc_adapter.rb
|
58
59
|
- lib/jdbc_adapter/jdbc_adapter_internal.jar
|
@@ -90,7 +91,6 @@ files:
|
|
90
91
|
- test/mysql_simple_test.rb
|
91
92
|
- test/postgres_simple_test.rb
|
92
93
|
- test/simple.rb
|
93
|
-
- lib/tasks/jdbc_databases.rake
|
94
94
|
- src/java/jdbc_adapter/JdbcAdapterInternalService.java
|
95
95
|
- src/java/jdbc_adapter/JdbcConnectionFactory.java
|
96
96
|
- src/java/jdbc_adapter/JdbcDerbySpec.java
|