activerecord-jdbc-adapter 1.0.3-java → 50.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +33 -0
- data/.travis.yml +79 -0
- data/.yardopts +4 -0
- data/CONTRIBUTING.md +50 -0
- data/Gemfile +91 -0
- data/History.md +1191 -0
- data/LICENSE.txt +22 -17
- data/README.md +169 -0
- data/RUNNING_TESTS.md +127 -0
- data/Rakefile +294 -5
- data/Rakefile.jdbc +20 -0
- data/activerecord-jdbc-adapter.gemspec +55 -0
- data/lib/active_record/connection_adapters/as400_adapter.rb +2 -0
- data/lib/active_record/connection_adapters/db2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mariadb_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
- data/lib/activerecord-jdbc-adapter.rb +0 -5
- data/lib/arel/visitors/compat.rb +60 -0
- data/lib/arel/visitors/db2.rb +128 -6
- data/lib/arel/visitors/derby.rb +103 -10
- data/lib/arel/visitors/firebird.rb +79 -0
- data/lib/arel/visitors/h2.rb +25 -0
- data/lib/arel/visitors/hsqldb.rb +18 -10
- data/lib/arel/visitors/postgresql_jdbc.rb +6 -0
- data/lib/arel/visitors/sql_server.rb +225 -0
- data/lib/arel/visitors/sql_server/ng42.rb +293 -0
- data/lib/arjdbc.rb +11 -21
- data/lib/arjdbc/abstract/connection_management.rb +35 -0
- data/lib/arjdbc/abstract/core.rb +64 -0
- data/lib/arjdbc/abstract/database_statements.rb +64 -0
- data/lib/arjdbc/abstract/statement_cache.rb +58 -0
- data/lib/arjdbc/abstract/transaction_support.rb +86 -0
- data/lib/arjdbc/db2.rb +3 -1
- data/lib/arjdbc/db2/adapter.rb +630 -250
- data/lib/arjdbc/db2/as400.rb +130 -0
- data/lib/arjdbc/db2/column.rb +167 -0
- data/lib/arjdbc/db2/connection_methods.rb +44 -0
- data/lib/arjdbc/derby.rb +1 -5
- data/lib/arjdbc/derby/active_record_patch.rb +13 -0
- data/lib/arjdbc/derby/adapter.rb +409 -217
- data/lib/arjdbc/derby/connection_methods.rb +16 -14
- data/lib/arjdbc/derby/schema_creation.rb +15 -0
- data/lib/arjdbc/discover.rb +62 -50
- data/lib/arjdbc/firebird.rb +3 -1
- data/lib/arjdbc/firebird/adapter.rb +365 -62
- data/lib/arjdbc/firebird/connection_methods.rb +23 -0
- data/lib/arjdbc/h2.rb +2 -3
- data/lib/arjdbc/h2/adapter.rb +273 -6
- data/lib/arjdbc/h2/connection_methods.rb +23 -8
- data/lib/arjdbc/hsqldb.rb +2 -3
- data/lib/arjdbc/hsqldb/adapter.rb +204 -77
- data/lib/arjdbc/hsqldb/connection_methods.rb +24 -10
- data/lib/arjdbc/hsqldb/explain_support.rb +35 -0
- data/lib/arjdbc/hsqldb/schema_creation.rb +11 -0
- data/lib/arjdbc/informix.rb +4 -2
- data/lib/arjdbc/informix/adapter.rb +78 -54
- data/lib/arjdbc/informix/connection_methods.rb +8 -9
- data/lib/arjdbc/jdbc.rb +59 -2
- data/lib/arjdbc/jdbc/adapter.rb +356 -166
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +46 -0
- data/lib/arjdbc/jdbc/base_ext.rb +15 -0
- data/lib/arjdbc/jdbc/callbacks.rb +27 -18
- data/lib/arjdbc/jdbc/column.rb +79 -20
- data/lib/arjdbc/jdbc/connection.rb +5 -119
- data/lib/arjdbc/jdbc/connection_methods.rb +32 -4
- data/lib/arjdbc/jdbc/error.rb +65 -0
- data/lib/arjdbc/jdbc/extension.rb +41 -29
- data/lib/arjdbc/jdbc/java.rb +5 -6
- data/lib/arjdbc/jdbc/jdbc.rake +3 -126
- data/lib/arjdbc/jdbc/railtie.rb +2 -9
- data/lib/arjdbc/jdbc/rake_tasks.rb +3 -10
- data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -0
- data/lib/arjdbc/jdbc/type_cast.rb +166 -0
- data/lib/arjdbc/jdbc/type_converter.rb +35 -19
- data/lib/arjdbc/mssql.rb +6 -3
- data/lib/arjdbc/mssql/adapter.rb +630 -298
- data/lib/arjdbc/mssql/column.rb +200 -0
- data/lib/arjdbc/mssql/connection_methods.rb +66 -17
- data/lib/arjdbc/mssql/explain_support.rb +99 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +189 -50
- data/lib/arjdbc/mssql/lock_methods.rb +77 -0
- data/lib/arjdbc/mssql/types.rb +343 -0
- data/lib/arjdbc/mssql/utils.rb +82 -0
- data/lib/arjdbc/mysql.rb +2 -3
- data/lib/arjdbc/mysql/adapter.rb +86 -356
- data/lib/arjdbc/mysql/connection_methods.rb +159 -23
- data/lib/arjdbc/oracle/adapter.rb +714 -263
- data/lib/arjdbc/postgresql.rb +2 -3
- data/lib/arjdbc/postgresql/_bc_time_cast_patch.rb +24 -0
- data/lib/arjdbc/postgresql/adapter.rb +570 -400
- data/lib/arjdbc/postgresql/base/array_decoder.rb +26 -0
- data/lib/arjdbc/postgresql/base/array_encoder.rb +25 -0
- data/lib/arjdbc/postgresql/base/array_parser.rb +95 -0
- data/lib/arjdbc/postgresql/base/pgconn.rb +11 -0
- data/lib/arjdbc/postgresql/column.rb +51 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +57 -18
- data/lib/arjdbc/postgresql/name.rb +24 -0
- data/lib/arjdbc/postgresql/oid_types.rb +192 -0
- data/lib/arjdbc/railtie.rb +11 -0
- data/lib/arjdbc/sqlite3.rb +2 -3
- data/lib/arjdbc/sqlite3/adapter.rb +518 -198
- data/lib/arjdbc/sqlite3/connection_methods.rb +49 -24
- data/lib/arjdbc/sybase.rb +2 -2
- data/lib/arjdbc/sybase/adapter.rb +7 -6
- data/lib/arjdbc/tasks.rb +13 -0
- data/lib/arjdbc/tasks/database_tasks.rb +52 -0
- data/lib/arjdbc/tasks/databases.rake +91 -0
- data/lib/arjdbc/tasks/databases3.rake +215 -0
- data/lib/arjdbc/tasks/databases4.rake +39 -0
- data/lib/arjdbc/tasks/db2_database_tasks.rb +104 -0
- data/lib/arjdbc/tasks/derby_database_tasks.rb +95 -0
- data/lib/arjdbc/tasks/h2_database_tasks.rb +31 -0
- data/lib/arjdbc/tasks/hsqldb_database_tasks.rb +70 -0
- data/lib/arjdbc/tasks/jdbc_database_tasks.rb +169 -0
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +46 -0
- data/lib/arjdbc/util/quoted_cache.rb +60 -0
- data/lib/arjdbc/util/serialized_attributes.rb +98 -0
- data/lib/arjdbc/util/table_copier.rb +110 -0
- data/lib/arjdbc/version.rb +1 -6
- data/lib/generators/jdbc/USAGE +9 -0
- data/lib/generators/jdbc/jdbc_generator.rb +8 -0
- data/lib/jdbc_adapter.rb +1 -1
- data/lib/jdbc_adapter/rake_tasks.rb +3 -2
- data/lib/jdbc_adapter/version.rb +2 -1
- data/pom.xml +114 -0
- data/rails_generators/jdbc_generator.rb +1 -1
- data/rails_generators/templates/config/initializers/jdbc.rb +8 -5
- data/rails_generators/templates/lib/tasks/jdbc.rake +7 -4
- data/rakelib/01-tomcat.rake +51 -0
- data/rakelib/02-test.rake +132 -0
- data/rakelib/bundler_ext.rb +11 -0
- data/rakelib/compile.rake +67 -22
- data/rakelib/db.rake +61 -0
- data/rakelib/rails.rake +204 -29
- data/src/java/arjdbc/ArJdbcModule.java +286 -0
- data/src/java/arjdbc/db2/DB2Module.java +76 -0
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +126 -0
- data/src/java/arjdbc/derby/DerbyModule.java +99 -243
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +152 -0
- data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +174 -0
- data/src/java/arjdbc/{jdbc/JdbcConnectionFactory.java → h2/H2Module.java} +20 -6
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +27 -12
- data/src/java/arjdbc/hsqldb/HSQLDBModule.java +73 -0
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +7 -6
- data/src/java/arjdbc/jdbc/AdapterJavaService.java +7 -29
- data/src/java/arjdbc/jdbc/Callable.java +44 -0
- data/src/java/arjdbc/jdbc/ConnectionFactory.java +132 -0
- data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +157 -0
- data/src/java/arjdbc/jdbc/DriverConnectionFactory.java +63 -0
- data/src/java/arjdbc/jdbc/DriverWrapper.java +119 -0
- data/src/java/arjdbc/jdbc/JdbcResult.java +130 -0
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +3622 -948
- data/src/java/arjdbc/mssql/MSSQLModule.java +90 -0
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +181 -0
- data/src/java/arjdbc/mysql/MySQLModule.java +99 -81
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +294 -0
- data/src/java/arjdbc/oracle/OracleModule.java +80 -0
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +387 -17
- data/src/java/arjdbc/postgresql/ByteaUtils.java +157 -0
- data/src/java/arjdbc/postgresql/PgResultSetMetaDataWrapper.java +23 -0
- data/src/java/arjdbc/postgresql/PostgreSQLModule.java +77 -0
- data/src/java/arjdbc/postgresql/PostgreSQLResult.java +184 -0
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +952 -0
- data/src/java/arjdbc/sqlite3/SQLite3Module.java +73 -0
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +525 -0
- data/src/java/arjdbc/util/CallResultSet.java +826 -0
- data/src/java/arjdbc/util/DateTimeUtils.java +580 -0
- data/src/java/arjdbc/util/ObjectSupport.java +65 -0
- data/src/java/arjdbc/util/QuotingUtils.java +138 -0
- data/src/java/arjdbc/util/StringCache.java +63 -0
- data/src/java/arjdbc/util/StringHelper.java +159 -0
- metadata +245 -268
- data/History.txt +0 -369
- data/Manifest.txt +0 -180
- data/README.txt +0 -181
- data/lib/active_record/connection_adapters/oracle_adapter.rb +0 -1
- 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/arel/visitors/mssql.rb +0 -44
- 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/lib/arjdbc/jdbc/driver.rb +0 -44
- data/lib/arjdbc/jdbc/missing_functionality_helper.rb +0 -87
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +0 -28
- data/lib/arjdbc/jdbc/require_driver.rb +0 -16
- data/lib/arjdbc/mimer.rb +0 -2
- data/lib/arjdbc/mimer/adapter.rb +0 -142
- data/lib/arjdbc/mssql/tsql_helper.rb +0 -61
- data/lib/arjdbc/oracle.rb +0 -3
- data/lib/arjdbc/oracle/connection_methods.rb +0 -11
- data/lib/pg.rb +0 -4
- data/rakelib/package.rake +0 -92
- data/rakelib/test.rake +0 -81
- data/src/java/arjdbc/jdbc/SQLBlock.java +0 -48
- data/src/java/arjdbc/mssql/MssqlRubyJdbcConnection.java +0 -127
- data/src/java/arjdbc/postgresql/PostgresqlRubyJdbcConnection.java +0 -57
- data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +0 -64
- data/test/abstract_db_create.rb +0 -117
- data/test/activerecord/connection_adapters/type_conversion_test.rb +0 -31
- data/test/activerecord/connections/native_jdbc_mysql/connection.rb +0 -25
- data/test/db/db2.rb +0 -11
- data/test/db/derby.rb +0 -12
- data/test/db/h2.rb +0 -11
- data/test/db/hsqldb.rb +0 -13
- data/test/db/informix.rb +0 -11
- data/test/db/jdbc.rb +0 -11
- data/test/db/jndi_config.rb +0 -40
- data/test/db/logger.rb +0 -3
- data/test/db/mssql.rb +0 -9
- data/test/db/mysql.rb +0 -10
- data/test/db/oracle.rb +0 -34
- data/test/db/postgres.rb +0 -9
- data/test/db/sqlite3.rb +0 -11
- data/test/db2_simple_test.rb +0 -66
- data/test/derby_migration_test.rb +0 -68
- data/test/derby_multibyte_test.rb +0 -12
- data/test/derby_simple_test.rb +0 -99
- data/test/generic_jdbc_connection_test.rb +0 -29
- data/test/h2_simple_test.rb +0 -41
- data/test/has_many_through.rb +0 -79
- data/test/helper.rb +0 -5
- data/test/hsqldb_simple_test.rb +0 -6
- data/test/informix_simple_test.rb +0 -48
- data/test/jdbc_common.rb +0 -25
- data/test/jndi_callbacks_test.rb +0 -40
- data/test/jndi_test.rb +0 -25
- data/test/manualTestDatabase.rb +0 -191
- data/test/models/add_not_null_column_to_table.rb +0 -12
- data/test/models/auto_id.rb +0 -18
- data/test/models/data_types.rb +0 -28
- data/test/models/entry.rb +0 -43
- data/test/models/mixed_case.rb +0 -25
- data/test/models/reserved_word.rb +0 -18
- data/test/models/string_id.rb +0 -18
- data/test/models/validates_uniqueness_of_string.rb +0 -19
- data/test/mssql_db_create_test.rb +0 -26
- data/test/mssql_identity_insert_test.rb +0 -19
- data/test/mssql_legacy_types_test.rb +0 -58
- data/test/mssql_limit_offset_test.rb +0 -136
- data/test/mssql_multibyte_test.rb +0 -18
- data/test/mssql_simple_test.rb +0 -55
- data/test/mysql_db_create_test.rb +0 -27
- data/test/mysql_info_test.rb +0 -113
- data/test/mysql_multibyte_test.rb +0 -10
- data/test/mysql_nonstandard_primary_key_test.rb +0 -42
- data/test/mysql_simple_test.rb +0 -49
- data/test/oracle_simple_test.rb +0 -18
- data/test/oracle_specific_test.rb +0 -83
- data/test/pick_rails_version.rb +0 -3
- data/test/postgres_db_create_test.rb +0 -32
- data/test/postgres_drop_db_test.rb +0 -16
- data/test/postgres_mixed_case_test.rb +0 -29
- data/test/postgres_nonseq_pkey_test.rb +0 -38
- data/test/postgres_reserved_test.rb +0 -22
- data/test/postgres_schema_search_path_test.rb +0 -44
- data/test/postgres_simple_test.rb +0 -51
- data/test/postgres_table_alias_length_test.rb +0 -15
- data/test/simple.rb +0 -546
- data/test/sqlite3_simple_test.rb +0 -233
- data/test/sybase_jtds_simple_test.rb +0 -28
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'jdbc_common'
|
|
2
|
-
require 'db/jdbc'
|
|
3
|
-
|
|
4
|
-
class GenericJdbcConnectionTest < Test::Unit::TestCase
|
|
5
|
-
def test_connection_available_through_jdbc_adapter
|
|
6
|
-
ActiveRecord::Base.connection.execute("show databases");
|
|
7
|
-
assert ActiveRecord::Base.connected?
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def test_configure_connection_url
|
|
11
|
-
connection = Object.new
|
|
12
|
-
connection.extend ActiveRecord::ConnectionAdapters::JdbcConnection::ConfigHelper
|
|
13
|
-
connection.config = { :url => "jdbc://somehost", :options => { :hoge => "true", :fuya => "false"} }
|
|
14
|
-
assert_equal "jdbc://somehost?hoge=true&fuya=false", connection.configure_url
|
|
15
|
-
|
|
16
|
-
connection.config = { :url => "jdbc://somehost?param=0", :options => { :hoge => "true", :fuya => "false"} }
|
|
17
|
-
assert_equal "jdbc://somehost?param=0&hoge=true&fuya=false", connection.configure_url
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def test_connection_fails_without_driver_and_url
|
|
21
|
-
conn = ActiveRecord::Base.remove_connection
|
|
22
|
-
assert_raises(ActiveRecord::ConnectionNotEstablished) do
|
|
23
|
-
ActiveRecord::Base.establish_connection :adapter => 'jdbc'
|
|
24
|
-
ActiveRecord::Base.connection
|
|
25
|
-
end
|
|
26
|
-
ensure
|
|
27
|
-
ActiveRecord::Base.establish_connection conn
|
|
28
|
-
end
|
|
29
|
-
end
|
data/test/h2_simple_test.rb
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
require 'jdbc_common'
|
|
2
|
-
require 'db/h2'
|
|
3
|
-
|
|
4
|
-
class H2SimpleTest < Test::Unit::TestCase
|
|
5
|
-
include SimpleTestMethods
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
class H2SchemaTest < Test::Unit::TestCase
|
|
9
|
-
def setup
|
|
10
|
-
@connection = ActiveRecord::Base.connection
|
|
11
|
-
@connection.execute("create schema s1");
|
|
12
|
-
@connection.execute("set schema s1");
|
|
13
|
-
CreateEntries.up
|
|
14
|
-
@connection.execute("create schema s2");
|
|
15
|
-
@connection.execute("set schema s2");
|
|
16
|
-
CreateUsers.up
|
|
17
|
-
@connection.execute("set schema public");
|
|
18
|
-
Entry.set_table_name 's1.entries'
|
|
19
|
-
User.set_table_name 's2.users'
|
|
20
|
-
user = User.create! :login => "something"
|
|
21
|
-
Entry.create! :title => "title", :content => "content", :rating => 123.45, :user => user
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def teardown
|
|
25
|
-
@connection.execute("set schema s1");
|
|
26
|
-
CreateEntries.down
|
|
27
|
-
@connection.execute("set schema s2");
|
|
28
|
-
CreateUsers.down
|
|
29
|
-
@connection.execute("drop schema s1");
|
|
30
|
-
@connection.execute("drop schema s2");
|
|
31
|
-
@connection.execute("set schema public");
|
|
32
|
-
Entry.reset_table_name
|
|
33
|
-
Entry.reset_column_information
|
|
34
|
-
User.reset_table_name
|
|
35
|
-
User.reset_column_information
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def test_find_in_other_schema
|
|
39
|
-
assert !Entry.all(:include => :user).empty?
|
|
40
|
-
end
|
|
41
|
-
end
|
data/test/has_many_through.rb
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
class CreateRbac < ActiveRecord::Migration
|
|
2
|
-
def self.up
|
|
3
|
-
create_table :role_assignments do |t|
|
|
4
|
-
t.column :role_id, :integer
|
|
5
|
-
t.column :user_id, :integer
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
create_table :roles do |t|
|
|
9
|
-
t.column :name, :string
|
|
10
|
-
t.column :description, :string
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
create_table :permission_groups do |t|
|
|
14
|
-
t.column :right_id, :integer
|
|
15
|
-
t.column :role_id, :integer
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
create_table :rights do |t|
|
|
19
|
-
t.column :name, :string
|
|
20
|
-
t.column :controller_name, :string
|
|
21
|
-
t.column :actions, :string
|
|
22
|
-
t.column :hours, :float, :null => false
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def self.down
|
|
27
|
-
drop_table :role_assignments
|
|
28
|
-
drop_table :roles
|
|
29
|
-
drop_table :permission_groups
|
|
30
|
-
drop_table :rights
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
class Right < ActiveRecord::Base
|
|
35
|
-
has_many :permission_groups, :dependent => :destroy
|
|
36
|
-
has_many :roles, :through => :permission_groups
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
class Role < ActiveRecord::Base
|
|
40
|
-
has_many :permission_groups, :dependent => :destroy
|
|
41
|
-
has_many :rights, :through => :permission_groups
|
|
42
|
-
has_many :role_assignments, :dependent => :destroy
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
class PermissionGroup < ActiveRecord::Base
|
|
46
|
-
belongs_to :right
|
|
47
|
-
belongs_to :role
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
class RoleAssignment < ActiveRecord::Base
|
|
51
|
-
belongs_to :user
|
|
52
|
-
belongs_to :role
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
module HasManyThroughMethods
|
|
56
|
-
def setup
|
|
57
|
-
CreateRbac.up
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def teardown
|
|
61
|
-
CreateRbac.down
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def test_has_many_through
|
|
65
|
-
admin_role = Role.create( {:name => "Administrator", :description => "System defined super user - access to right and role management."} )
|
|
66
|
-
admin_role.save
|
|
67
|
-
|
|
68
|
-
assert_equal(0, admin_role.rights.sum(:hours))
|
|
69
|
-
|
|
70
|
-
role_rights = Right.create( {:name => "Administrator - Full Access To Roles", :actions => "*", :controller_name => "Admin::RolesController", :hours => 0} )
|
|
71
|
-
right_rights = Right.create( {:name => "Administrator - Full Access To Rights", :actions => "*", :controller_name => "Admin::RightsController", :hours => 1.5} )
|
|
72
|
-
|
|
73
|
-
admin_role.rights << role_rights
|
|
74
|
-
admin_role.rights << right_rights
|
|
75
|
-
admin_role.save
|
|
76
|
-
|
|
77
|
-
assert_equal(1.5, admin_role.rights.sum(:hours))
|
|
78
|
-
end
|
|
79
|
-
end
|
data/test/helper.rb
DELETED
data/test/hsqldb_simple_test.rb
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
#
|
|
3
|
-
# To run this script, run the following:
|
|
4
|
-
#
|
|
5
|
-
# CREATE DATABASE weblog_development;
|
|
6
|
-
#
|
|
7
|
-
# TODO: Finish the explanation.
|
|
8
|
-
|
|
9
|
-
require 'jdbc_common'
|
|
10
|
-
require 'db/informix'
|
|
11
|
-
|
|
12
|
-
class InformixSimpleTest < Test::Unit::TestCase
|
|
13
|
-
include SimpleTestMethods
|
|
14
|
-
|
|
15
|
-
# Informix does not like "= NULL".
|
|
16
|
-
def test_equals_null
|
|
17
|
-
Entry.create!(:title => "Foo")
|
|
18
|
-
entry = Entry.find(:first, :conditions => ["content = NULL"])
|
|
19
|
-
assert_equal "Foo", entry.title
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Informix does not like "!= NULL" or "<> NULL".
|
|
23
|
-
def test_not_equals_null
|
|
24
|
-
Entry.create!(:title => "Foo", :content => "Bar")
|
|
25
|
-
entry = Entry.find_by_title("Foo", :conditions => ["content != NULL"])
|
|
26
|
-
assert_equal "Foo", entry.title
|
|
27
|
-
entry = Entry.find_by_title("Foo", :conditions => ["content <> NULL"])
|
|
28
|
-
assert_equal "Foo", entry.title
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
class InformixMultibyteTest < Test::Unit::TestCase
|
|
33
|
-
include MultibyteTestMethods
|
|
34
|
-
|
|
35
|
-
# Overriding the included test since we can't create text fields via a
|
|
36
|
-
# simple insert in Informix.
|
|
37
|
-
def test_select_multibyte_string
|
|
38
|
-
Entry.create!(:title => 'テスト', :content => '本文')
|
|
39
|
-
entry = Entry.find(:first)
|
|
40
|
-
assert_equal "テスト", entry.title
|
|
41
|
-
assert_equal "本文", entry.content
|
|
42
|
-
assert_equal entry, Entry.find_by_title("テスト")
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
class InformixHasManyThroughTest < Test::Unit::TestCase
|
|
47
|
-
include HasManyThroughMethods
|
|
48
|
-
end
|
data/test/jdbc_common.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Simple method to reduce the boilerplate
|
|
2
|
-
def jruby?
|
|
3
|
-
defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
|
4
|
-
end
|
|
5
|
-
|
|
6
|
-
require 'rubygems'
|
|
7
|
-
require 'pick_rails_version'
|
|
8
|
-
require 'arjdbc' if jruby?
|
|
9
|
-
puts "Using activerecord version #{ActiveRecord::VERSION::STRING}"
|
|
10
|
-
puts "Specify version with AR_VERSION=={version} or RUBYLIB={path}"
|
|
11
|
-
require 'models/auto_id'
|
|
12
|
-
require 'models/entry'
|
|
13
|
-
require 'models/data_types'
|
|
14
|
-
require 'models/add_not_null_column_to_table'
|
|
15
|
-
require 'models/validates_uniqueness_of_string'
|
|
16
|
-
require 'models/string_id'
|
|
17
|
-
require 'simple'
|
|
18
|
-
require 'has_many_through'
|
|
19
|
-
require 'helper'
|
|
20
|
-
require 'test/unit'
|
|
21
|
-
|
|
22
|
-
# Comment/uncomment to enable logging to be loaded for any of the database adapters
|
|
23
|
-
require 'db/logger' if $DEBUG || ENV['DEBUG']
|
|
24
|
-
|
|
25
|
-
|
data/test/jndi_callbacks_test.rb
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
require 'jdbc_common'
|
|
2
|
-
require 'db/jndi_config'
|
|
3
|
-
|
|
4
|
-
begin
|
|
5
|
-
require 'mocha'
|
|
6
|
-
|
|
7
|
-
class JndiConnectionPoolCallbacksTest < Test::Unit::TestCase
|
|
8
|
-
def setup
|
|
9
|
-
@connection = mock "JdbcConnection"
|
|
10
|
-
@connection.stubs(:jndi_connection?).returns(true)
|
|
11
|
-
@connection.stubs(:adapter=)
|
|
12
|
-
@logger = mock "logger"
|
|
13
|
-
@config = JNDI_CONFIG
|
|
14
|
-
Entry.connection_pool.disconnect!
|
|
15
|
-
assert !Entry.connection_pool.connected?
|
|
16
|
-
class << Entry.connection_pool; public :instance_variable_set; end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def teardown
|
|
20
|
-
@connection.stubs(:disconnect!)
|
|
21
|
-
Entry.connection_pool.disconnect!
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def test_should_call_hooks_on_checkout_and_checkin
|
|
25
|
-
@connection.stubs(:active?).returns(true)
|
|
26
|
-
@connection.expects(:disconnect!)
|
|
27
|
-
@adapter = ActiveRecord::ConnectionAdapters::JdbcAdapter.new @connection, @logger, @config
|
|
28
|
-
Entry.connection_pool.instance_variable_set "@connections", [@adapter]
|
|
29
|
-
|
|
30
|
-
@connection.expects(:reconnect!)
|
|
31
|
-
Entry.connection_pool.checkout
|
|
32
|
-
|
|
33
|
-
@connection.expects(:disconnect!)
|
|
34
|
-
Entry.connection_pool.checkin @adapter
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
rescue LoadError
|
|
39
|
-
warn "mocha not found, disabling mocha-based tests"
|
|
40
|
-
end if ActiveRecord::Base.respond_to?(:connection_pool)
|
data/test/jndi_test.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# In order to run these tests, you need to have a few things on your
|
|
2
|
-
# classpath. First, you're going to need the Sun File system
|
|
3
|
-
# context. You can get that here:
|
|
4
|
-
#
|
|
5
|
-
# http://java.sun.com/products/jndi/serviceproviders.html.
|
|
6
|
-
#
|
|
7
|
-
# Make sure that you put both the fscontext.jar and the
|
|
8
|
-
# providerutil.jar on your classpath.
|
|
9
|
-
#
|
|
10
|
-
# To support the connection pooling in the test, you'll need
|
|
11
|
-
# commons-dbcp, commons-pool, and commons-collections.
|
|
12
|
-
#
|
|
13
|
-
# Finally, you'll need the jdbc driver, which is derby, for this test.
|
|
14
|
-
|
|
15
|
-
require 'jdbc_common'
|
|
16
|
-
require 'db/jndi_config'
|
|
17
|
-
|
|
18
|
-
class DerbyJndiTest < Test::Unit::TestCase
|
|
19
|
-
include SimpleTestMethods
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
at_exit {
|
|
23
|
-
require 'fileutils'
|
|
24
|
-
FileUtils.rm_rf 'derby-testdb'
|
|
25
|
-
}
|
data/test/manualTestDatabase.rb
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env jruby
|
|
2
|
-
|
|
3
|
-
if ARGV.length < 2
|
|
4
|
-
$stderr.puts "syntax: #{__FILE__} [filename] [configuration-name]"
|
|
5
|
-
$stderr.puts " where filename points to a YAML database configuration file"
|
|
6
|
-
$stderr.puts " and the configuration name is in this file"
|
|
7
|
-
exit
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
|
11
|
-
|
|
12
|
-
require 'yaml'
|
|
13
|
-
require 'rubygems'
|
|
14
|
-
RAILS_CONNECTION_ADAPTERS = ['mysql', 'jdbc']
|
|
15
|
-
require 'active_record'
|
|
16
|
-
|
|
17
|
-
cfg = (File.open(ARGV[0]) {|f| YAML.load(f) })[ARGV[1]]
|
|
18
|
-
|
|
19
|
-
ActiveRecord::Base.establish_connection(cfg)
|
|
20
|
-
|
|
21
|
-
ActiveRecord::Schema.define do
|
|
22
|
-
drop_table :authors rescue nil
|
|
23
|
-
drop_table :author rescue nil
|
|
24
|
-
|
|
25
|
-
create_table :author, :force => true do |t|
|
|
26
|
-
t.column :name, :string, :null => false
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Exercise all types, and add_column
|
|
30
|
-
add_column :author, :description, :text
|
|
31
|
-
add_column :author, :descr, :string, :limit => 50
|
|
32
|
-
add_column :author, :age, :integer, :null => false, :default => 17
|
|
33
|
-
add_column :author, :weight, :float
|
|
34
|
-
add_column :author, :born, :datetime
|
|
35
|
-
add_column :author, :died, :timestamp
|
|
36
|
-
add_column :author, :wakeup_time, :time
|
|
37
|
-
add_column :author, :birth_date, :date
|
|
38
|
-
add_column :author, :private_key, :binary
|
|
39
|
-
add_column :author, :female, :boolean, :default => true
|
|
40
|
-
|
|
41
|
-
change_column :author, :descr, :string, :limit => 100 if /db2|derby/ !~ ARGV[1]
|
|
42
|
-
change_column_default :author, :female, false if /db2|derby|mssql|firebird/ !~ ARGV[1]
|
|
43
|
-
remove_column :author, :died if /db2|derby/ !~ ARGV[1]
|
|
44
|
-
rename_column :author, :wakeup_time, :waking_time if /db2|derby|mimer/ !~ ARGV[1]
|
|
45
|
-
|
|
46
|
-
add_index :author, :name, :unique if /db2/ !~ ARGV[1]
|
|
47
|
-
add_index :author, [:age,:female], :name => :is_age_female if /db2/ !~ ARGV[1]
|
|
48
|
-
|
|
49
|
-
remove_index :author, :name if /db2/ !~ ARGV[1]
|
|
50
|
-
remove_index :author, :name => :is_age_female if /db2/ !~ ARGV[1]
|
|
51
|
-
|
|
52
|
-
rename_table :author, :authors if /db2|firebird|mimer/ !~ ARGV[1]
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
create_table :products, :force => true do |t|
|
|
56
|
-
t.column :title, :string
|
|
57
|
-
t.column :description, :text
|
|
58
|
-
t.column :image_url, :string
|
|
59
|
-
end
|
|
60
|
-
add_column :products, :price, :float, :default => 0.0
|
|
61
|
-
create_table :orders, :force => true do |t|
|
|
62
|
-
t.column :name, :string
|
|
63
|
-
t.column :address, :text
|
|
64
|
-
t.column :email, :string
|
|
65
|
-
t.column :pay_type, :string, :limit => 10
|
|
66
|
-
end
|
|
67
|
-
create_table :line_items, :force => true do |t|
|
|
68
|
-
t.column :product_id, :integer, :null => false
|
|
69
|
-
t.column :order_id, :integer, :null => false
|
|
70
|
-
t.column :quantity, :integer, :null => false
|
|
71
|
-
t.column :total_price, :float, :null => false
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
class Author < ActiveRecord::Base;
|
|
76
|
-
set_table_name "author" if /db2|firebird|mimer/ =~ ARGV[1]
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
class Order < ActiveRecord::Base
|
|
80
|
-
has_many :line_items
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
class Product < ActiveRecord::Base
|
|
84
|
-
has_many :orders, :through => :line_items
|
|
85
|
-
has_many :line_items
|
|
86
|
-
|
|
87
|
-
def self.find_products_for_sale
|
|
88
|
-
find(:all, :order => "title")
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
class LineItem < ActiveRecord::Base
|
|
93
|
-
belongs_to :order
|
|
94
|
-
belongs_to :product
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
Product.create(:title => 'Pragmatic Project Automation',
|
|
98
|
-
:description =>
|
|
99
|
-
%{<p>
|
|
100
|
-
<em>Pragmatic Project Automation</em> shows you how to improve the
|
|
101
|
-
consistency and repeatability of your project's procedures using
|
|
102
|
-
automation to reduce risk and errors.
|
|
103
|
-
</p>
|
|
104
|
-
<p>
|
|
105
|
-
Simply put, we're going to put this thing called a computer to work
|
|
106
|
-
for you doing the mundane (but important) project stuff. That means
|
|
107
|
-
you'll have more time and energy to do the really
|
|
108
|
-
exciting---and difficult---stuff, like writing quality code.
|
|
109
|
-
</p>},
|
|
110
|
-
:image_url => '/images/auto.jpg',
|
|
111
|
-
:price => 29.95)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
Product.create(:title => 'Pragmatic Version Control',
|
|
115
|
-
:description =>
|
|
116
|
-
%{<p>
|
|
117
|
-
This book is a recipe-based approach to using Subversion that will
|
|
118
|
-
get you up and
|
|
119
|
-
running quickly---and correctly. All projects need version control:
|
|
120
|
-
it's a foundational piece of any project's infrastructure. Yet half
|
|
121
|
-
of all project teams in the U.S. don't use any version control at all.
|
|
122
|
-
Many others don't use it well, and end up experiencing time-consuming problems.
|
|
123
|
-
</p>},
|
|
124
|
-
:image_url => '/images/svn.jpg',
|
|
125
|
-
:price => 28.50)
|
|
126
|
-
|
|
127
|
-
# . . .
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
Product.create(:title => 'Pragmatic Unit Testing (C#)',
|
|
131
|
-
:description =>
|
|
132
|
-
%{<p>
|
|
133
|
-
Pragmatic programmers use feedback to drive their development and
|
|
134
|
-
personal processes. The most valuable feedback you can get while
|
|
135
|
-
coding comes from unit testing.
|
|
136
|
-
</p>
|
|
137
|
-
<p>
|
|
138
|
-
Without good tests in place, coding can become a frustrating game of
|
|
139
|
-
"whack-a-mole." That's the carnival game where the player strikes at a
|
|
140
|
-
mechanical mole; it retreats and another mole pops up on the opposite side
|
|
141
|
-
of the field. The moles pop up and down so fast that you end up flailing
|
|
142
|
-
your mallet helplessly as the moles continue to pop up where you least
|
|
143
|
-
expect them.
|
|
144
|
-
</p>},
|
|
145
|
-
:image_url => '/images/utc.jpg',
|
|
146
|
-
:price => 27.75)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
1.times do
|
|
152
|
-
$stderr.print '.'
|
|
153
|
-
Author.destroy_all
|
|
154
|
-
Author.create(:name => "Arne Svensson", :age => 30)
|
|
155
|
-
if /db2|derby|mimer/ !~ ARGV[1]
|
|
156
|
-
Author.create(:name => "Pelle Gogolsson", :age => 15, :waking_time => Time.now, :private_key => "afbafddsfgsdfg")
|
|
157
|
-
else
|
|
158
|
-
Author.create(:name => "Pelle Gogolsson", :age => 15, :wakeup_time => Time.now, :private_key => "afbafddsfgsdfg")
|
|
159
|
-
end
|
|
160
|
-
Author.find(:first)
|
|
161
|
-
Author.find(:all)
|
|
162
|
-
arne = Author.find(:first)
|
|
163
|
-
arne.destroy
|
|
164
|
-
|
|
165
|
-
pelle = Author.find(:first)
|
|
166
|
-
pelle.name = "Pelle Sweitchon"
|
|
167
|
-
pelle.description = "dfsssdddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
|
|
168
|
-
pelle.descr = "adsfasdf"
|
|
169
|
-
pelle.age = 79
|
|
170
|
-
pelle.weight = 57.6
|
|
171
|
-
pelle.born = Time.gm(1982,8,13,10,15,3,0)
|
|
172
|
-
pelle.female = false
|
|
173
|
-
pelle.save
|
|
174
|
-
|
|
175
|
-
prods = Product.find :all
|
|
176
|
-
order = Order.new(:name => "Dalai Lama", :address => "Great Road 32", :email => "abc@dot.com", :pay_type => "cash")
|
|
177
|
-
order.line_items << LineItem.new(:product => prods[0], :quantity => 3, :total_price => (prods[0].price * 3))
|
|
178
|
-
order.line_items << LineItem.new(:product => prods[2], :quantity => 1, :total_price => (prods[2].price))
|
|
179
|
-
order.save
|
|
180
|
-
|
|
181
|
-
puts "order: #{order.line_items.inspect}, with id: #{order.id} and name: #{order.name}"
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
ActiveRecord::Schema.define do
|
|
185
|
-
drop_table :line_items
|
|
186
|
-
drop_table :orders
|
|
187
|
-
drop_table :products
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
drop_table((/db2|firebird|mimer/=~ARGV[1]? :author : :authors ))
|
|
191
|
-
end
|