activerecord-jdbc-adapter 0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +61 -0
- data/LICENSE +21 -0
- data/Manifest.txt +64 -0
- data/README.txt +116 -0
- data/Rakefile +146 -0
- data/lib/active_record/connection_adapters/derby_adapter.rb +13 -0
- data/lib/active_record/connection_adapters/h2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/hsqldb_adapter.rb +13 -0
- data/lib/active_record/connection_adapters/jdbc_adapter.rb +575 -0
- data/lib/active_record/connection_adapters/jdbc_adapter_spec.rb +10 -0
- data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mysql_adapter.rb +13 -0
- data/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +13 -0
- data/lib/jdbc_adapter.rb +32 -0
- data/lib/jdbc_adapter/jdbc_db2.rb +104 -0
- data/lib/jdbc_adapter/jdbc_derby.rb +362 -0
- data/lib/jdbc_adapter/jdbc_firebird.rb +109 -0
- data/lib/jdbc_adapter/jdbc_hsqldb.rb +168 -0
- data/lib/jdbc_adapter/jdbc_mimer.rb +134 -0
- data/lib/jdbc_adapter/jdbc_mssql.rb +356 -0
- data/lib/jdbc_adapter/jdbc_mysql.rb +168 -0
- data/lib/jdbc_adapter/jdbc_oracle.rb +340 -0
- data/lib/jdbc_adapter/jdbc_postgre.rb +347 -0
- data/lib/jdbc_adapter/missing_functionality_helper.rb +72 -0
- data/lib/jdbc_adapter/version.rb +5 -0
- data/lib/jdbc_adapter_internal.jar +0 -0
- data/lib/tasks/jdbc_databases.rake +72 -0
- data/src/java/JDBCDerbySpec.java +323 -0
- data/src/java/JDBCMySQLSpec.java +89 -0
- data/src/java/JdbcAdapterInternalService.java +953 -0
- data/test/activerecord/connection_adapters/type_conversion_test.rb +31 -0
- data/test/activerecord/connections/native_jdbc_mysql/connection.rb +25 -0
- data/test/db/derby.rb +18 -0
- data/test/db/h2.rb +11 -0
- data/test/db/hsqldb.rb +15 -0
- data/test/db/jdbc.rb +11 -0
- data/test/db/jndi_config.rb +30 -0
- data/test/db/logger.rb +3 -0
- data/test/db/mysql.rb +9 -0
- data/test/db/postgres.rb +9 -0
- data/test/derby_multibyte_test.rb +12 -0
- data/test/derby_simple_test.rb +12 -0
- data/test/generic_jdbc_connection_test.rb +9 -0
- data/test/h2_simple_test.rb +7 -0
- data/test/hsqldb_simple_test.rb +6 -0
- data/test/jdbc_adapter/jdbc_db2_test.rb +21 -0
- data/test/jdbc_common.rb +6 -0
- data/test/jndi_test.rb +37 -0
- data/test/manualTestDatabase.rb +195 -0
- data/test/minirunit.rb +109 -0
- data/test/minirunit/testConnect.rb +14 -0
- data/test/minirunit/testH2.rb +73 -0
- data/test/minirunit/testHsqldb.rb +73 -0
- data/test/minirunit/testLoadActiveRecord.rb +3 -0
- data/test/minirunit/testMysql.rb +83 -0
- data/test/minirunit/testRawSelect.rb +24 -0
- data/test/models/auto_id.rb +18 -0
- data/test/models/data_types.rb +18 -0
- data/test/models/entry.rb +20 -0
- data/test/mysql_multibyte_test.rb +6 -0
- data/test/mysql_simple_test.rb +13 -0
- data/test/postgres_simple_test.rb +12 -0
- data/test/simple.rb +157 -0
- metadata +112 -0
@@ -0,0 +1,13 @@
|
|
1
|
+
# To run this script, run the following in a mysql instance:
|
2
|
+
#
|
3
|
+
# drop database if exists weblog_development;
|
4
|
+
# create database weblog_development;
|
5
|
+
# grant all on weblog_development.* to blog@localhost;
|
6
|
+
# flush privileges;
|
7
|
+
|
8
|
+
require 'jdbc_common'
|
9
|
+
require 'db/mysql'
|
10
|
+
|
11
|
+
class MysqlSimpleTest < Test::Unit::TestCase
|
12
|
+
include SimpleTestMethods
|
13
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# To run this script, set up the following postgres user and database:
|
2
|
+
#
|
3
|
+
# sudo -u postgres createuser -D -A -P blog
|
4
|
+
# sudo -u postgres createdb -O blog weblog_development
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'jdbc_common'
|
8
|
+
require 'db/postgres'
|
9
|
+
|
10
|
+
class PostgresSimpleTest < Test::Unit::TestCase
|
11
|
+
include SimpleTestMethods
|
12
|
+
end
|
data/test/simple.rb
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
module MigrationSetup
|
2
|
+
def setup
|
3
|
+
CreateEntries.up
|
4
|
+
CreateAutoIds.up
|
5
|
+
|
6
|
+
@connection = ActiveRecord::Base.connection
|
7
|
+
end
|
8
|
+
|
9
|
+
def teardown
|
10
|
+
CreateEntries.down
|
11
|
+
CreateAutoIds.down
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module FixtureSetup
|
16
|
+
include MigrationSetup
|
17
|
+
def setup
|
18
|
+
super
|
19
|
+
@title = "First post!"
|
20
|
+
@content = "Hello from JRuby on Rails!"
|
21
|
+
@new_title = "First post updated title"
|
22
|
+
@rating = 205
|
23
|
+
Entry.create :title => @title, :content => @content, :rating => @rating
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module SimpleTestMethods
|
28
|
+
include FixtureSetup
|
29
|
+
|
30
|
+
def test_entries_created
|
31
|
+
assert ActiveRecord::Base.connection.tables.find{|t| t =~ /^entries$/i}, "entries not created"
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_entries_empty
|
35
|
+
Entry.delete_all
|
36
|
+
assert_equal 0, Entry.count
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_create_new_entry
|
40
|
+
Entry.delete_all
|
41
|
+
|
42
|
+
post = Entry.new
|
43
|
+
post.title = @title
|
44
|
+
post.content = @content
|
45
|
+
post.rating = @rating
|
46
|
+
post.save
|
47
|
+
|
48
|
+
assert_equal 1, Entry.count
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_create_partial_new_entry
|
52
|
+
new_entry = Entry.create(:title => "Blah")
|
53
|
+
new_entry2 = Entry.create(:title => "Bloh")
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_find_and_update_entry
|
57
|
+
post = Entry.find(:first)
|
58
|
+
assert_equal @title, post.title
|
59
|
+
assert_equal @content, post.content
|
60
|
+
assert_equal @rating, post.rating
|
61
|
+
|
62
|
+
post.title = @new_title
|
63
|
+
post.save
|
64
|
+
|
65
|
+
post = Entry.find(:first)
|
66
|
+
assert_equal @new_title, post.title
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_destroy_entry
|
70
|
+
prev_count = Entry.count
|
71
|
+
post = Entry.find(:first)
|
72
|
+
post.destroy
|
73
|
+
|
74
|
+
assert_equal prev_count - 1, Entry.count
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_indexes
|
78
|
+
# Only test indexes if we have implemented it for the particular adapter
|
79
|
+
if @connection.respond_to?(:indexes)
|
80
|
+
indexes = @connection.indexes(:entries)
|
81
|
+
assert_equal(0, indexes.size)
|
82
|
+
|
83
|
+
index_name = "entries_index"
|
84
|
+
@connection.add_index(:entries, :updated_on, :name => index_name)
|
85
|
+
|
86
|
+
indexes = @connection.indexes(:entries)
|
87
|
+
assert_equal(1, indexes.size)
|
88
|
+
assert_equal "entries", indexes.first.table
|
89
|
+
assert_equal index_name, indexes.first.name
|
90
|
+
assert !indexes.first.unique
|
91
|
+
assert_equal ["updated_on"], indexes.first.columns
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_dumping_schema
|
96
|
+
require 'active_record/schema_dumper'
|
97
|
+
@connection.add_index :entries, :title
|
98
|
+
StringIO.open do |io|
|
99
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, io)
|
100
|
+
assert_match(/add_index "entries",/, io.string)
|
101
|
+
end
|
102
|
+
@connection.remove_index :entries, :title
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_nil_values
|
107
|
+
test = AutoId.create('value' => '')
|
108
|
+
assert_nil AutoId.find(test.id).value
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_invalid
|
112
|
+
e = Entry.new(:title => @title, :content => @content, :rating => ' ')
|
113
|
+
p e.valid?
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
module MultibyteTestMethods
|
119
|
+
include MigrationSetup
|
120
|
+
|
121
|
+
def setup
|
122
|
+
super
|
123
|
+
config = ActiveRecord::Base.connection.config
|
124
|
+
jdbc_driver = ActiveRecord::ConnectionAdapters::JdbcDriver.new(config[:driver])
|
125
|
+
jdbc_driver.load
|
126
|
+
@java_con = jdbc_driver.connection(config[:url], config[:username], config[:password])
|
127
|
+
@java_con.setAutoCommit(true)
|
128
|
+
end
|
129
|
+
|
130
|
+
def teardown
|
131
|
+
@java_con.close
|
132
|
+
super
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_select_multibyte_string
|
136
|
+
@java_con.createStatement().execute("insert into entries (title, content) values ('テスト', '本文')")
|
137
|
+
entry = Entry.find(:first)
|
138
|
+
assert_equal "テスト", entry.title
|
139
|
+
assert_equal "本文", entry.content
|
140
|
+
assert_equal entry, Entry.find_by_title("テスト")
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_update_multibyte_string
|
144
|
+
Entry.create!(:title => "テスト", :content => "本文")
|
145
|
+
rs = @java_con.createStatement().executeQuery("select title, content from entries")
|
146
|
+
assert rs.next
|
147
|
+
assert_equal "テスト", rs.getString(1)
|
148
|
+
assert_equal "本文", rs.getString(2)
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_chinese_word
|
152
|
+
chinese_word = '中文'
|
153
|
+
new_entry = Entry.create(:title => chinese_word)
|
154
|
+
new_entry.reload
|
155
|
+
assert_equal chinese_word, new_entry.title
|
156
|
+
end
|
157
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.4
|
3
|
+
specification_version: 1
|
4
|
+
name: activerecord-jdbc-adapter
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: "0.6"
|
7
|
+
date: 2007-12-13 00:00:00 -08:00
|
8
|
+
summary: JDBC adapter for ActiveRecord, for use within JRuby on Rails.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: nick@nicksieger.com, ola.bini@gmail.com
|
12
|
+
homepage: http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter
|
13
|
+
rubyforge_project: jruby-extras
|
14
|
+
description: ActiveRecord-JDBC is a database adapter for Rails' ActiveRecord component that can be used with JRuby[http://www.jruby.org/]. It allows use of virtually any JDBC-compliant database with your JRuby on Rails application.
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Nick Sieger, Ola Bini and JRuby contributors
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- Manifest.txt
|
34
|
+
- README.txt
|
35
|
+
- Rakefile
|
36
|
+
- LICENSE
|
37
|
+
- lib/active_record/connection_adapters/derby_adapter.rb
|
38
|
+
- lib/active_record/connection_adapters/h2_adapter.rb
|
39
|
+
- lib/active_record/connection_adapters/hsqldb_adapter.rb
|
40
|
+
- lib/active_record/connection_adapters/jdbc_adapter.rb
|
41
|
+
- lib/active_record/connection_adapters/jdbc_adapter_spec.rb
|
42
|
+
- lib/active_record/connection_adapters/jndi_adapter.rb
|
43
|
+
- lib/active_record/connection_adapters/mysql_adapter.rb
|
44
|
+
- lib/active_record/connection_adapters/oracle_adapter.rb
|
45
|
+
- lib/active_record/connection_adapters/postgresql_adapter.rb
|
46
|
+
- lib/jdbc_adapter/jdbc_db2.rb
|
47
|
+
- lib/jdbc_adapter/jdbc_derby.rb
|
48
|
+
- lib/jdbc_adapter/jdbc_firebird.rb
|
49
|
+
- lib/jdbc_adapter/jdbc_hsqldb.rb
|
50
|
+
- lib/jdbc_adapter/jdbc_mimer.rb
|
51
|
+
- lib/jdbc_adapter/jdbc_mssql.rb
|
52
|
+
- lib/jdbc_adapter/jdbc_mysql.rb
|
53
|
+
- lib/jdbc_adapter/jdbc_oracle.rb
|
54
|
+
- lib/jdbc_adapter/jdbc_postgre.rb
|
55
|
+
- lib/jdbc_adapter/missing_functionality_helper.rb
|
56
|
+
- lib/jdbc_adapter/version.rb
|
57
|
+
- lib/jdbc_adapter.rb
|
58
|
+
- lib/jdbc_adapter_internal.jar
|
59
|
+
- test/activerecord/connection_adapters/type_conversion_test.rb
|
60
|
+
- test/activerecord/connections/native_jdbc_mysql/connection.rb
|
61
|
+
- test/db/derby.rb
|
62
|
+
- test/db/h2.rb
|
63
|
+
- test/db/hsqldb.rb
|
64
|
+
- test/db/jdbc.rb
|
65
|
+
- test/db/jndi_config.rb
|
66
|
+
- test/db/logger.rb
|
67
|
+
- test/db/mysql.rb
|
68
|
+
- test/db/postgres.rb
|
69
|
+
- test/derby_multibyte_test.rb
|
70
|
+
- test/derby_simple_test.rb
|
71
|
+
- test/generic_jdbc_connection_test.rb
|
72
|
+
- test/h2_simple_test.rb
|
73
|
+
- test/hsqldb_simple_test.rb
|
74
|
+
- test/jdbc_adapter/jdbc_db2_test.rb
|
75
|
+
- test/jdbc_common.rb
|
76
|
+
- test/jndi_test.rb
|
77
|
+
- test/manualTestDatabase.rb
|
78
|
+
- test/minirunit/testConnect.rb
|
79
|
+
- test/minirunit/testH2.rb
|
80
|
+
- test/minirunit/testHsqldb.rb
|
81
|
+
- test/minirunit/testLoadActiveRecord.rb
|
82
|
+
- test/minirunit/testMysql.rb
|
83
|
+
- test/minirunit/testRawSelect.rb
|
84
|
+
- test/minirunit.rb
|
85
|
+
- test/models/auto_id.rb
|
86
|
+
- test/models/data_types.rb
|
87
|
+
- test/models/entry.rb
|
88
|
+
- test/mysql_multibyte_test.rb
|
89
|
+
- test/mysql_simple_test.rb
|
90
|
+
- test/postgres_simple_test.rb
|
91
|
+
- test/simple.rb
|
92
|
+
- lib/tasks/jdbc_databases.rake
|
93
|
+
- src/java/JdbcAdapterInternalService.java
|
94
|
+
- src/java/JDBCDerbySpec.java
|
95
|
+
- src/java/JDBCMySQLSpec.java
|
96
|
+
test_files: []
|
97
|
+
|
98
|
+
rdoc_options:
|
99
|
+
- --main
|
100
|
+
- README.txt
|
101
|
+
extra_rdoc_files:
|
102
|
+
- History.txt
|
103
|
+
- Manifest.txt
|
104
|
+
- README.txt
|
105
|
+
executables: []
|
106
|
+
|
107
|
+
extensions: []
|
108
|
+
|
109
|
+
requirements: []
|
110
|
+
|
111
|
+
dependencies: []
|
112
|
+
|