activerecord-jdbc-adapter 1.2.9.1 → 1.3.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Appraisals +12 -4
- data/Gemfile +3 -3
- data/Gemfile.lock +19 -19
- data/History.txt +90 -16
- data/LICENSE.txt +2 -1
- data/README.md +14 -1
- data/activerecord-jdbc-adapter.gemspec +2 -2
- data/gemfiles/rails23.gemfile +5 -5
- data/gemfiles/rails23.gemfile.lock +27 -27
- data/gemfiles/rails30.gemfile +3 -3
- data/gemfiles/rails30.gemfile.lock +8 -8
- data/gemfiles/rails31.gemfile +4 -4
- data/gemfiles/rails31.gemfile.lock +18 -18
- data/gemfiles/rails32.gemfile +4 -4
- data/gemfiles/rails32.gemfile.lock +17 -17
- data/gemfiles/rails40.gemfile +17 -0
- data/gemfiles/rails40.gemfile.lock +126 -0
- data/lib/activerecord-jdbc-adapter.rb +0 -7
- data/lib/arjdbc.rb +6 -5
- data/lib/arjdbc/db2.rb +1 -1
- data/lib/arjdbc/db2/adapter.rb +52 -29
- data/lib/arjdbc/db2/connection_methods.rb +13 -14
- data/lib/arjdbc/derby.rb +1 -1
- data/lib/arjdbc/derby/adapter.rb +29 -9
- data/lib/arjdbc/derby/connection_methods.rb +17 -20
- data/lib/arjdbc/firebird.rb +1 -1
- data/lib/arjdbc/h2.rb +2 -2
- data/lib/arjdbc/h2/adapter.rb +1 -1
- data/lib/arjdbc/h2/connection_methods.rb +12 -16
- data/lib/arjdbc/hsqldb.rb +1 -1
- data/lib/arjdbc/hsqldb/connection_methods.rb +13 -16
- data/lib/arjdbc/informix.rb +1 -1
- data/lib/arjdbc/informix/connection_methods.rb +8 -10
- data/lib/arjdbc/jdbc.rb +1 -1
- data/lib/arjdbc/jdbc/adapter.rb +125 -53
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/base_ext.rb +34 -9
- data/lib/arjdbc/jdbc/column.rb +15 -2
- data/lib/arjdbc/jdbc/connection.rb +0 -2
- data/lib/arjdbc/jdbc/connection_methods.rb +10 -3
- data/lib/arjdbc/jdbc/driver.rb +2 -2
- data/lib/arjdbc/jdbc/extension.rb +35 -21
- data/lib/arjdbc/jdbc/java.rb +0 -2
- data/lib/arjdbc/jdbc/missing_functionality_helper.rb +35 -25
- data/lib/arjdbc/jdbc/railtie.rb +2 -9
- data/lib/arjdbc/mimer.rb +1 -1
- data/lib/arjdbc/mssql.rb +2 -2
- data/lib/arjdbc/mssql/adapter.rb +271 -92
- data/lib/arjdbc/mssql/connection_methods.rb +30 -32
- data/lib/arjdbc/mssql/explain_support.rb +107 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +48 -18
- data/lib/arjdbc/mysql.rb +1 -1
- data/lib/arjdbc/mysql/adapter.rb +63 -14
- data/lib/arjdbc/mysql/connection_methods.rb +22 -24
- data/lib/arjdbc/mysql/explain_support.rb +2 -5
- data/lib/arjdbc/oracle.rb +1 -1
- data/lib/arjdbc/oracle/adapter.rb +78 -38
- data/lib/arjdbc/oracle/connection_methods.rb +9 -10
- data/lib/arjdbc/postgresql.rb +1 -1
- data/lib/arjdbc/postgresql/adapter.rb +964 -380
- data/lib/arjdbc/postgresql/column_cast.rb +136 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +19 -21
- data/lib/arjdbc/postgresql/explain_support.rb +3 -6
- data/lib/arjdbc/railtie.rb +9 -0
- data/lib/arjdbc/sqlite3.rb +1 -1
- data/lib/arjdbc/sqlite3/adapter.rb +73 -26
- data/lib/arjdbc/sqlite3/connection_methods.rb +27 -28
- data/lib/arjdbc/sqlite3/explain_support.rb +2 -5
- data/lib/arjdbc/sybase.rb +1 -1
- data/lib/arjdbc/version.rb +5 -4
- data/pom.xml +8 -0
- data/rakelib/02-test.rake +57 -51
- data/rakelib/compile.rake +17 -5
- data/rakelib/rails.rake +42 -31
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +4 -3
- data/src/java/arjdbc/derby/DerbyModule.java +98 -85
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +70 -0
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +0 -4
- data/src/java/arjdbc/jdbc/AdapterJavaService.java +26 -15
- data/src/java/arjdbc/jdbc/Callable.java +44 -0
- data/src/java/arjdbc/jdbc/JdbcConnectionFactory.java +10 -2
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +1675 -834
- data/src/java/arjdbc/jdbc/SQLBlock.java +9 -3
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +73 -36
- data/src/java/arjdbc/mysql/MySQLModule.java +11 -10
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +86 -80
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +27 -7
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +214 -0
- data/src/java/arjdbc/postgresql/PostgresqlRubyJdbcConnection.java +25 -67
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +52 -49
- data/src/java/arjdbc/util/QuotingUtils.java +6 -6
- data/test/abstract_db_create.rb +11 -11
- data/test/activerecord/connection_adapters/type_conversion_test.rb +18 -12
- data/test/db/db2.rb +1 -1
- data/test/{db2_binary_test.rb → db/db2/binary_test.rb} +0 -0
- data/test/db/db2/has_many_through_test.rb +6 -0
- data/test/{db2_reset_column_information_test.rb → db/db2/reset_column_information_test.rb} +1 -2
- data/test/{db2_serialize_test.rb → db/db2/serialize_test.rb} +0 -0
- data/test/{db2_simple_test.rb → db/db2/simple_test.rb} +1 -8
- data/test/db/db2/test_helper.rb +6 -0
- data/test/{db2_test.rb → db/db2/unit_test.rb} +1 -1
- data/test/db/derby.rb +1 -1
- data/test/{derby_binary_test.rb → db/derby/binary_test.rb} +0 -0
- data/test/{derby_migration_test.rb → db/derby/migration_test.rb} +0 -0
- data/test/{derby_reset_column_information_test.rb → db/derby/reset_column_information_test.rb} +0 -0
- data/test/{derby_row_locking_test.rb → db/derby/row_locking_test.rb} +1 -4
- data/test/db/derby/schema_dump_test.rb +5 -0
- data/test/{derby_serialize_test.rb → db/derby/serialize_test.rb} +0 -0
- data/test/{derby_simple_test.rb → db/derby/simple_test.rb} +23 -38
- data/test/db/derby/test_helper.rb +6 -0
- data/test/db/derby/unit_test.rb +32 -0
- data/test/db/derby/xml_column_test.rb +17 -0
- data/test/db/h2.rb +1 -1
- data/test/{h2_binary_test.rb → db/h2/binary_test.rb} +0 -0
- data/test/{h2_change_column_test.rb → db/h2/change_column_test.rb} +1 -0
- data/test/{h2_schema_dump_test.rb → db/h2/schema_dump_test.rb} +0 -0
- data/test/{h2_serialize_test.rb → db/h2/serialize_test.rb} +0 -0
- data/test/{h2_simple_test.rb → db/h2/simple_test.rb} +3 -1
- data/test/db/hsqldb.rb +1 -1
- data/test/{hsqldb_binary_test.rb → db/hsqldb/binary_test.rb} +0 -0
- data/test/{hsqldb_schema_dump_test.rb → db/hsqldb/schema_dump_test.rb} +0 -0
- data/test/{hsqldb_serialize_test.rb → db/hsqldb/serialize_test.rb} +0 -0
- data/test/{hsqldb_simple_test.rb → db/hsqldb/simple_test.rb} +3 -1
- data/test/db/informix.rb +1 -1
- data/test/db/jdbc.rb +3 -2
- data/test/db/jdbc_derby.rb +1 -1
- data/test/db/jdbc_h2.rb +1 -1
- data/test/db/jdbc_mysql.rb +1 -1
- data/test/db/jdbc_postgres.rb +1 -1
- data/test/db/jndi_config.rb +1 -2
- data/test/db/jndi_pooled_config.rb +2 -3
- data/test/db/mssql.rb +2 -2
- data/test/{mssql_binary_test.rb → db/mssql/binary_test.rb} +0 -0
- data/test/{mssql_db_create_test.rb → db/mssql/db_create_test.rb} +1 -1
- data/test/db/mssql/exec_proc_test.rb +46 -0
- data/test/{mssql_identity_insert_test.rb → db/mssql/identity_insert_test.rb} +0 -0
- data/test/db/mssql/ignore_system_views_test.rb +40 -0
- data/test/{mssql_limit_offset_test.rb → db/mssql/limit_offset_test.rb} +10 -1
- data/test/{mssql_multibyte_test.rb → db/mssql/multibyte_test.rb} +0 -0
- data/test/db/mssql/multiple_connections_test.rb +71 -0
- data/test/{mssql_reset_column_information_test.rb → db/mssql/reset_column_information_test.rb} +0 -0
- data/test/{mssql_row_locking_test.rb → db/mssql/row_locking_test.rb} +0 -0
- data/test/{mssql_serialize_test.rb → db/mssql/serialize_test.rb} +1 -1
- data/test/db/mssql/simple_test.rb +140 -0
- data/test/db/mssql/transaction_test.rb +6 -0
- data/test/db/mssql/types_test.rb +205 -0
- data/test/{mssql_test.rb → db/mssql/unit_test.rb} +2 -2
- data/test/db/mysql.rb +1 -2
- data/test/db/mysql/_rails_test_mysql.32.out +6768 -0
- data/test/{mysql_binary_test.rb → db/mysql/binary_test.rb} +0 -0
- data/test/db/mysql/connection_test.rb +51 -0
- data/test/{mysql_db_create_test.rb → db/mysql/db_create_test.rb} +0 -0
- data/test/{mysql_index_length_test.rb → db/mysql/index_length_test.rb} +0 -0
- data/test/{mysql_multibyte_test.rb → db/mysql/multibyte_test.rb} +0 -0
- data/test/{mysql_nonstandard_primary_key_test.rb → db/mysql/nonstandard_primary_key_test.rb} +0 -0
- data/test/{mysql_reset_column_information_test.rb → db/mysql/reset_column_information_test.rb} +0 -0
- data/test/{mysql_schema_dump_test.rb → db/mysql/schema_dump_test.rb} +9 -1
- data/test/{mysql_serialize_test.rb → db/mysql/serialize_test.rb} +0 -0
- data/test/{mysql_simple_test.rb → db/mysql/simple_test.rb} +16 -8
- data/test/db/mysql/transaction_test.rb +6 -0
- data/test/db/mysql/types_test.rb +30 -0
- data/test/{mysql_test.rb → db/mysql/unit_test.rb} +1 -1
- data/test/db/mysql_config.rb +1 -1
- data/test/db/oracle.rb +1 -1
- data/test/{oracle_binary_test.rb → db/oracle/binary_test.rb} +0 -0
- data/test/{oracle_limit_test.rb → db/oracle/limit_test.rb} +0 -0
- data/test/db/oracle/multibyte_test.rb +22 -0
- data/test/{oracle_reset_column_information_test.rb → db/oracle/reset_column_information_test.rb} +0 -0
- data/test/{oracle_serialize_test.rb → db/oracle/serialize_test.rb} +0 -0
- data/test/{oracle_simple_test.rb → db/oracle/simple_test.rb} +14 -19
- data/test/{oracle_specific_test.rb → db/oracle/specific_test.rb} +62 -16
- data/test/db/oracle/transaction_test.rb +31 -0
- data/test/db/oracle/unit_test.rb +31 -0
- data/test/db/postgres.rb +1 -1
- data/test/db/postgres/_rails_test_postgres.32.out +6777 -0
- data/test/db/postgres/a_custom_primary_key_test.rb +50 -0
- data/test/db/postgres/array_type_test.rb +101 -0
- data/test/{postgres_binary_test.rb → db/postgres/binary_test.rb} +0 -0
- data/test/db/postgres/connection_test.rb +55 -0
- data/test/db/postgres/data_types_test.rb +703 -0
- data/test/{postgres_db_create_test.rb → db/postgres/db_create_test.rb} +1 -1
- data/test/{postgres_drop_db_test.rb → db/postgres/db_drop_test.rb} +2 -0
- data/test/db/postgres/hstore_test.rb +200 -0
- data/test/db/postgres/information_schema_leak_test.rb +30 -0
- data/test/db/postgres/json_test.rb +86 -0
- data/test/db/postgres/ltree_test.rb +50 -0
- data/test/{postgres_mixed_case_test.rb → db/postgres/mixed_case_test.rb} +0 -0
- data/test/db/postgres/native_types_test.rb +128 -0
- data/test/{postgres_reserved_test.rb → db/postgres/reserved_test.rb} +0 -0
- data/test/{postgres_reset_column_information_test.rb → db/postgres/reset_column_information_test.rb} +0 -0
- data/test/{postgres_row_locking_test.rb → db/postgres/row_locking_test.rb} +0 -0
- data/test/{postgres_schema_dump_test.rb → db/postgres/schema_dump_test.rb} +4 -4
- data/test/db/postgres/schema_test.rb +113 -0
- data/test/{postgres_simple_test.rb → db/postgres/simple_test.rb} +48 -8
- data/test/{postgres_table_alias_length_test.rb → db/postgres/table_alias_length_test.rb} +2 -1
- data/test/db/postgres/transaction_test.rb +6 -0
- data/test/{postgres_test.rb → db/postgres/unit_test.rb} +3 -3
- data/test/db/sqlite3.rb +1 -1
- data/test/db/sqlite3/_rails_test_sqlite3.32.out +6502 -0
- data/test/db/sqlite3/has_many_though_test.rb +6 -0
- data/test/{sqlite3_reset_column_information_test.rb → db/sqlite3/reset_column_information_test.rb} +0 -0
- data/test/{sqlite3_schema_dump_test.rb → db/sqlite3/schema_dump_test.rb} +0 -0
- data/test/{sqlite3_serialize_test.rb → db/sqlite3/serialize_test.rb} +0 -0
- data/test/{sqlite3_simple_test.rb → db/sqlite3/simple_test.rb} +63 -63
- data/test/db/sqlite3/transaction_test.rb +32 -0
- data/test/{sqlite3_type_conversion_test.rb → db/sqlite3/type_conversion_test.rb} +0 -0
- data/test/has_many_through.rb +29 -64
- data/test/jdbc/oracle.rb +11 -0
- data/test/jndi_test.rb +16 -4
- data/test/models/auto_id.rb +1 -1
- data/test/models/rights_and_roles.rb +57 -0
- data/test/row_locking.rb +3 -0
- data/test/schema_dump.rb +24 -10
- data/test/simple.rb +359 -104
- data/test/test_helper.rb +4 -2
- data/test/transaction.rb +109 -0
- metadata +119 -86
- 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/test/derby_schema_dump_test.rb +0 -9
- data/test/mssql_ignore_system_views_test.rb +0 -30
- data/test/mssql_legacy_types_test.rb +0 -58
- data/test/mssql_null_test.rb +0 -14
- data/test/mssql_simple_test.rb +0 -51
- data/test/postgres_information_schema_leak_test.rb +0 -28
- data/test/postgres_native_type_mapping_test.rb +0 -93
- data/test/postgres_nonseq_pkey_test.rb +0 -38
- data/test/postgres_schema_search_path_test.rb +0 -48
- data/test/postgres_type_conversion_test.rb +0 -33
@@ -1,51 +0,0 @@
|
|
1
|
-
# AR's 2.2 version of this method is sufficient, but we need it for
|
2
|
-
# older versions
|
3
|
-
if ActiveRecord::VERSION::MAJOR <= 2 && ActiveRecord::VERSION::MINOR < 2
|
4
|
-
module ActiveRecord
|
5
|
-
module ConnectionAdapters # :nodoc:
|
6
|
-
module SchemaStatements
|
7
|
-
# Convert the speficied column type to a SQL string.
|
8
|
-
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
|
9
|
-
if native = native_database_types[type]
|
10
|
-
column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
|
11
|
-
|
12
|
-
if type == :decimal # ignore limit, use precision and scale
|
13
|
-
scale ||= native[:scale]
|
14
|
-
|
15
|
-
if precision ||= native[:precision]
|
16
|
-
if scale
|
17
|
-
column_type_sql << "(#{precision},#{scale})"
|
18
|
-
else
|
19
|
-
column_type_sql << "(#{precision})"
|
20
|
-
end
|
21
|
-
elsif scale
|
22
|
-
raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified"
|
23
|
-
end
|
24
|
-
|
25
|
-
elsif limit ||= native.is_a?(Hash) && native[:limit]
|
26
|
-
column_type_sql << "(#{limit})"
|
27
|
-
end
|
28
|
-
|
29
|
-
column_type_sql
|
30
|
-
else
|
31
|
-
type
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
module ActiveRecord
|
40
|
-
module ConnectionAdapters
|
41
|
-
module CompatibilityMethods
|
42
|
-
def self.needed?(base)
|
43
|
-
!base.instance_methods.include?("quote_table_name")
|
44
|
-
end
|
45
|
-
|
46
|
-
def quote_table_name(name)
|
47
|
-
quote_column_name(name)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
data/lib/arjdbc/jdbc/core_ext.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
module ActiveRecord # :nodoc:
|
2
|
-
# Represents exceptions that have propagated up through the JDBC API.
|
3
|
-
class JDBCError < ActiveRecordError
|
4
|
-
# The vendor code or error number that came from the database
|
5
|
-
attr_accessor :errno
|
6
|
-
|
7
|
-
# The full Java SQLException object that was raised
|
8
|
-
attr_accessor :sql_exception
|
9
|
-
end
|
10
|
-
|
11
|
-
module ConnectionAdapters # :nodoc:
|
12
|
-
# Allows properly re-wrapping/re-defining methods that may already
|
13
|
-
# be alias_method_chain'd.
|
14
|
-
module ShadowCoreMethods
|
15
|
-
def alias_chained_method(meth, feature, target)
|
16
|
-
if instance_methods.include?("#{meth}_without_#{feature}")
|
17
|
-
alias_method "#{meth}_without_#{feature}".to_sym, target
|
18
|
-
else
|
19
|
-
alias_method meth, target if meth != target
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/arjdbc/jdbc/discover.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module ArJdbc
|
2
|
-
def self.discover_extensions
|
3
|
-
if defined?(::Gem) && ::Gem.respond_to?(:find_files)
|
4
|
-
files = ::Gem.find_files('arjdbc/discover')
|
5
|
-
else
|
6
|
-
files = $LOAD_PATH.map do |p|
|
7
|
-
discover = File.join(p, 'arjdbc', 'discover.rb')
|
8
|
-
File.exist?(discover) ? discover : nil
|
9
|
-
end.compact
|
10
|
-
end
|
11
|
-
files.each do |f|
|
12
|
-
puts "Loading #{f}" if $DEBUG
|
13
|
-
require f
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
discover_extensions
|
18
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'db/mssql'
|
3
|
-
|
4
|
-
class MSSQLIgnoreSystemViewsTest < Test::Unit::TestCase
|
5
|
-
include MigrationSetup
|
6
|
-
|
7
|
-
def test_system_views_ignored
|
8
|
-
if ActiveRecord::Base.connection.sqlserver_version == "2000"
|
9
|
-
assert_equal false, table_exists?("sys.views"), %{table_exists?("sys.views")}
|
10
|
-
assert_equal false, table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
|
11
|
-
else
|
12
|
-
assert_equal true, table_exists?("sys.views"), %{table_exists?("sys.views")}
|
13
|
-
assert_equal true, table_exists?("information_schema.views"), %{table_exists?("information_schema.views")}
|
14
|
-
end
|
15
|
-
assert_equal false, table_exists?("dbo.views"), %{table_exists?("dbo.views")}
|
16
|
-
assert_equal false, table_exists?(:views), %{table_exists?(:views)}
|
17
|
-
ActiveRecord::Schema.define { suppress_messages { create_table :views } }
|
18
|
-
assert_equal true, table_exists?(:views), %{table_exists?(:views)}
|
19
|
-
ActiveRecord::Schema.define { suppress_messages { drop_table :views } }
|
20
|
-
assert_equal false, table_exists?(:views), %{table_exists?(:views)}
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def table_exists?(*args)
|
26
|
-
ActiveRecord::Base.connection.table_exists?(*args)
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'db/mssql'
|
3
|
-
|
4
|
-
ActiveRecord::Schema.verbose = false
|
5
|
-
|
6
|
-
class CreateArticles < ActiveRecord::Migration
|
7
|
-
|
8
|
-
def self.up
|
9
|
-
execute <<-SQL
|
10
|
-
CREATE TABLE articles (
|
11
|
-
[id] int NOT NULL IDENTITY(1, 1) PRIMARY KEY,
|
12
|
-
[title] VARCHAR(100),
|
13
|
-
[author] VARCHAR(60) DEFAULT 'anonymous',
|
14
|
-
[body] TEXT
|
15
|
-
)
|
16
|
-
SQL
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.down
|
20
|
-
drop_table "articles"
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
class Article < ActiveRecord::Base
|
26
|
-
end
|
27
|
-
|
28
|
-
class MsSQLLegacyTypesTest < Test::Unit::TestCase
|
29
|
-
|
30
|
-
def setup
|
31
|
-
CreateArticles.up
|
32
|
-
ActiveRecord::Base.connection
|
33
|
-
end
|
34
|
-
|
35
|
-
def teardown
|
36
|
-
CreateArticles.down
|
37
|
-
ActiveRecord::Base.clear_active_connections!
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_varchar_column
|
41
|
-
Article.create!(:title => "Blah blah")
|
42
|
-
article = Article.first
|
43
|
-
assert_equal("Blah blah", article.title)
|
44
|
-
end
|
45
|
-
|
46
|
-
SAMPLE_TEXT = "Lorem ipsum dolor sit amet ..."
|
47
|
-
|
48
|
-
def test_text_column
|
49
|
-
Article.create!(:body => SAMPLE_TEXT)
|
50
|
-
article = Article.first
|
51
|
-
assert_equal(SAMPLE_TEXT, article.body)
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_varchar_default_value
|
55
|
-
assert_equal("anonymous", Article.new.author)
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
data/test/mssql_null_test.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'db/mssql'
|
3
|
-
|
4
|
-
class MsSQLNullTest < Test::Unit::TestCase
|
5
|
-
include MigrationSetup
|
6
|
-
|
7
|
-
[nil, "NULL", "null", "(null)", "(NULL)"].each_with_index do |v, i|
|
8
|
-
define_method "test_null_#{i}" do
|
9
|
-
entry = Entry.create!(:title => v, :content => v)
|
10
|
-
entry = Entry.find(entry.id)
|
11
|
-
assert_equal [v, v], [entry.title, entry.content], "writing #{v.inspect} should read back as #{v.inspect} for both string and text columns"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
data/test/mssql_simple_test.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'db/mssql'
|
3
|
-
|
4
|
-
class MSSQLSimpleTest < Test::Unit::TestCase
|
5
|
-
include SimpleTestMethods
|
6
|
-
include ActiveRecord3TestMethods
|
7
|
-
include DirtyAttributeTests
|
8
|
-
|
9
|
-
# MS SQL 2005 doesn't have a DATE class, only TIMESTAMP
|
10
|
-
|
11
|
-
# String comparisons are insensitive by default
|
12
|
-
undef_method :test_validates_uniqueness_of_strings_case_sensitive
|
13
|
-
|
14
|
-
def test_does_not_munge_quoted_strings
|
15
|
-
example_quoted_values = [%{'quoted'}, %{D\'oh!}]
|
16
|
-
example_quoted_values.each do |value|
|
17
|
-
entry = Entry.create!(:title => value)
|
18
|
-
entry.reload
|
19
|
-
assert_equal(value, entry.title)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_change_column_default
|
24
|
-
Entry.connection.change_column "entries", "title", :string, :default => "new default"
|
25
|
-
Entry.reset_column_information
|
26
|
-
assert_equal("new default", Entry.new.title)
|
27
|
-
|
28
|
-
Entry.connection.change_column "entries", "title", :string, :default => nil
|
29
|
-
Entry.reset_column_information
|
30
|
-
assert_equal(nil, Entry.new.title)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_change_column_nullability
|
34
|
-
Entry.connection.change_column "entries", "title", :string, :null => true
|
35
|
-
Entry.reset_column_information
|
36
|
-
title_column = Entry.columns.find { |c| c.name == "title" }
|
37
|
-
assert(title_column.null)
|
38
|
-
|
39
|
-
Entry.connection.change_column "entries", "title", :string, :null => false
|
40
|
-
Entry.reset_column_information
|
41
|
-
title_column = Entry.columns.find { |c| c.name == "title" }
|
42
|
-
assert(!title_column.null)
|
43
|
-
end
|
44
|
-
|
45
|
-
# ACTIVERECORD_JDBC-124
|
46
|
-
def test_model_does_not_have_row_num_column
|
47
|
-
entry = Entry.first
|
48
|
-
assert_false entry.attributes.keys.include?("_row_num")
|
49
|
-
assert_false entry.respond_to?(:_row_num)
|
50
|
-
end
|
51
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
|
3
|
-
class CreateISLSchema < ActiveRecord::Migration
|
4
|
-
def self.up
|
5
|
-
execute "CREATE TABLE domains (id int, name varchar(16))"
|
6
|
-
end
|
7
|
-
|
8
|
-
def self.down
|
9
|
-
execute "DROP TABLE domains"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
class Domain < ActiveRecord::Base
|
14
|
-
end
|
15
|
-
|
16
|
-
class PostgresInformationSchemaLeakTest < Test::Unit::TestCase
|
17
|
-
def setup
|
18
|
-
CreateISLSchema.up
|
19
|
-
end
|
20
|
-
|
21
|
-
def teardown
|
22
|
-
CreateISLSchema.down
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_columns
|
26
|
-
assert_equal(%w{id name}, Domain.column_names)
|
27
|
-
end
|
28
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'db/postgres'
|
3
|
-
|
4
|
-
class CreateNativeTypeMappingTestSchema < ActiveRecord::Migration
|
5
|
-
def self.up
|
6
|
-
execute "DROP SEQUENCE IF EXISTS seq_pk_customers"
|
7
|
-
execute "CREATE SEQUENCE seq_pk_customers"
|
8
|
-
columns = [
|
9
|
-
"bigint_serial_should_be_integer bigint default nextval('seq_pk_customers')",
|
10
|
-
"integer_serial_should_be_integer integer default nextval('seq_pk_customers')",
|
11
|
-
"varchar_should_be_string varchar(2)",
|
12
|
-
"timestamp_should_be_datetime timestamp",
|
13
|
-
"bytea_should_be_binary bytea",
|
14
|
-
"double_precision_should_be_float double precision",
|
15
|
-
"real_should_be_float real",
|
16
|
-
"bool_should_be_boolean bool",
|
17
|
-
"interval_should_be_string interval",
|
18
|
-
"bigint_should_be_integer bigint"
|
19
|
-
]
|
20
|
-
columns << "uuid_should_be_string uuid" if PG_VERSION >= 80300
|
21
|
-
table_sql = %Q{
|
22
|
-
CREATE TABLE customers (
|
23
|
-
#{columns.join(",\n")}
|
24
|
-
)}
|
25
|
-
execute table_sql
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.down
|
29
|
-
execute "DROP TABLE customers"
|
30
|
-
execute "DROP SEQUENCE IF EXISTS seq_pk_customers"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class Customer < ActiveRecord::Base
|
35
|
-
end
|
36
|
-
|
37
|
-
class PostgresNativeTypeMappingTest < Test::Unit::TestCase
|
38
|
-
def setup
|
39
|
-
CreateNativeTypeMappingTestSchema.up
|
40
|
-
end
|
41
|
-
|
42
|
-
def teardown
|
43
|
-
CreateNativeTypeMappingTestSchema.down
|
44
|
-
end
|
45
|
-
|
46
|
-
def column_type(column_name)
|
47
|
-
Customer.columns.detect { |c| c.name == column_name }.type
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_uuid_column_should_map_to_string
|
51
|
-
assert_equal :string, column_type("uuid_should_be_string") if PG_VERSION >= 80300
|
52
|
-
end
|
53
|
-
|
54
|
-
def test_bigint_serial_should_be_mapped_to_integer
|
55
|
-
assert_equal :integer, column_type("bigint_serial_should_be_integer")
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_integer_serial_should_be_mapped_to_integer
|
59
|
-
assert_equal :integer, column_type("integer_serial_should_be_integer")
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_varchar_should_be_mapped_to_string
|
63
|
-
assert_equal :string, column_type("varchar_should_be_string")
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_timestamp_should_be_mapped_to_datetime
|
67
|
-
assert_equal :datetime, column_type("timestamp_should_be_datetime")
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_bytea_should_be_mapped_to_binary
|
71
|
-
assert_equal :binary, column_type("bytea_should_be_binary")
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_double_precision_should_be_mapped_to_float
|
75
|
-
assert_equal :float, column_type("double_precision_should_be_float")
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_real_should_be_mapped_to_float
|
79
|
-
assert_equal :float, column_type("real_should_be_float")
|
80
|
-
end
|
81
|
-
|
82
|
-
def test_bool_should_be_mapped_to_boolean
|
83
|
-
assert_equal :boolean, column_type("bool_should_be_boolean")
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_interval_should_be_mapped_to_string
|
87
|
-
assert_equal :string, column_type("interval_should_be_string")
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_bigint_should_be_mapped_to_integer
|
91
|
-
assert_equal :integer, column_type("bigint_should_be_integer")
|
92
|
-
end
|
93
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'db/postgres'
|
3
|
-
|
4
|
-
class CreateUrls < ActiveRecord::Migration
|
5
|
-
def self.up
|
6
|
-
create_table 'urls', :id => false do |t|
|
7
|
-
t.text :uhash, :null => false
|
8
|
-
t.text :url, :null => false
|
9
|
-
end
|
10
|
-
execute "ALTER TABLE urls ADD PRIMARY KEY (uhash)"
|
11
|
-
end
|
12
|
-
def self.down
|
13
|
-
drop_table 'urls'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class Url < ActiveRecord::Base
|
18
|
-
self.primary_key = :uhash
|
19
|
-
#Shouldn't be needed: set_sequence_name nil
|
20
|
-
end
|
21
|
-
|
22
|
-
class PostgresNonSeqPKey < Test::Unit::TestCase
|
23
|
-
def setup
|
24
|
-
CreateUrls.up
|
25
|
-
end
|
26
|
-
|
27
|
-
def teardown
|
28
|
-
CreateUrls.down
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_create
|
32
|
-
url = Url.create! do |u|
|
33
|
-
u.uhash = 'uhash'
|
34
|
-
u.url = 'http://url'
|
35
|
-
end
|
36
|
-
assert_equal( 'uhash', url.uhash )
|
37
|
-
end
|
38
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'jdbc_common'
|
2
|
-
require 'db/postgres'
|
3
|
-
|
4
|
-
class CreateSchema < ActiveRecord::Migration
|
5
|
-
def self.up
|
6
|
-
execute "CREATE SCHEMA test"
|
7
|
-
execute "CREATE TABLE test.people (id serial, name text)"
|
8
|
-
execute "INSERT INTO test.people (name) VALUES ('Alex')"
|
9
|
-
execute "CREATE TABLE public.people (id serial, wrongname text)"
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.down
|
13
|
-
execute "DROP SCHEMA test CASCADE"
|
14
|
-
execute "DROP TABLE people"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Person < ActiveRecord::Base
|
19
|
-
establish_connection POSTGRES_CONFIG.merge(:schema_search_path => 'test,public')
|
20
|
-
end
|
21
|
-
|
22
|
-
class PostgresSchemaSearchPathTest < Test::Unit::TestCase
|
23
|
-
def setup
|
24
|
-
CreateSchema.up
|
25
|
-
end
|
26
|
-
|
27
|
-
def teardown
|
28
|
-
CreateSchema.down
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_columns
|
32
|
-
assert_equal(%w{id name}, Person.column_names)
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_find_right
|
36
|
-
assert_not_nil Person.find_by_name("Alex")
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_find_wrong
|
40
|
-
assert_raise NoMethodError do
|
41
|
-
Person.find_by_wrongname("Alex")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
def test_column_information
|
45
|
-
assert Person.columns.map{|col| col.name}.include?("name")
|
46
|
-
assert !Person.columns.map{|col| col.name}.include?("wrongname")
|
47
|
-
end
|
48
|
-
end
|