Merge pull request #15137 from sgrif/sg-remove-dead-code
Remove dead test code for unsupported adapters
This commit is contained in:
commit
7359f8190d
@ -123,17 +123,8 @@ def [](name)
|
|||||||
# Default is (38,0).
|
# Default is (38,0).
|
||||||
# * DB2: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..62].
|
# * DB2: <tt>:precision</tt> [1..63], <tt>:scale</tt> [0..62].
|
||||||
# Default unknown.
|
# Default unknown.
|
||||||
# * Firebird: <tt>:precision</tt> [1..18], <tt>:scale</tt> [0..18].
|
|
||||||
# Default (9,0). Internal types NUMERIC and DECIMAL have different
|
|
||||||
# storage rules, decimal being better.
|
|
||||||
# * FrontBase?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
|
|
||||||
# Default (38,0). WARNING Max <tt>:precision</tt>/<tt>:scale</tt> for
|
|
||||||
# NUMERIC is 19, and DECIMAL is 38.
|
|
||||||
# * SqlServer?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
|
# * SqlServer?: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
|
||||||
# Default (38,0).
|
# Default (38,0).
|
||||||
# * Sybase: <tt>:precision</tt> [1..38], <tt>:scale</tt> [0..38].
|
|
||||||
# Default (38,0).
|
|
||||||
# * OpenBase?: Documentation unclear. Claims storage in <tt>double</tt>.
|
|
||||||
#
|
#
|
||||||
# This method returns <tt>self</tt>.
|
# This method returns <tt>self</tt>.
|
||||||
#
|
#
|
||||||
|
@ -195,7 +195,7 @@ def initialize
|
|||||||
# == Database support
|
# == Database support
|
||||||
#
|
#
|
||||||
# Migrations are currently supported in MySQL, PostgreSQL, SQLite,
|
# Migrations are currently supported in MySQL, PostgreSQL, SQLite,
|
||||||
# SQL Server, Sybase, and Oracle (all supported databases except DB2).
|
# SQL Server, and Oracle (all supported databases except DB2).
|
||||||
#
|
#
|
||||||
# == More examples
|
# == More examples
|
||||||
#
|
#
|
||||||
|
@ -198,7 +198,7 @@ def reset_sequence_name #:nodoc:
|
|||||||
# given block. This is required for Oracle and is useful for any
|
# given block. This is required for Oracle and is useful for any
|
||||||
# database which relies on sequences for primary key generation.
|
# database which relies on sequences for primary key generation.
|
||||||
#
|
#
|
||||||
# If a sequence name is not explicitly set when using Oracle or Firebird,
|
# If a sequence name is not explicitly set when using Oracle,
|
||||||
# it will default to the commonly used pattern of: #{table_name}_seq
|
# it will default to the commonly used pattern of: #{table_name}_seq
|
||||||
#
|
#
|
||||||
# If a sequence name is not explicitly set when using PostgreSQL, it
|
# If a sequence name is not explicitly set when using PostgreSQL, it
|
||||||
|
@ -46,9 +46,7 @@ def test_indexes
|
|||||||
@connection.add_index :accounts, :firm_id, :name => idx_name
|
@connection.add_index :accounts, :firm_id, :name => idx_name
|
||||||
indexes = @connection.indexes("accounts")
|
indexes = @connection.indexes("accounts")
|
||||||
assert_equal "accounts", indexes.first.table
|
assert_equal "accounts", indexes.first.table
|
||||||
# OpenBase does not have the concept of a named index
|
assert_equal idx_name, indexes.first.name
|
||||||
# Indexes are merely properties of columns.
|
|
||||||
assert_equal idx_name, indexes.first.name unless current_adapter?(:OpenBaseAdapter)
|
|
||||||
assert !indexes.first.unique
|
assert !indexes.first.unique
|
||||||
assert_equal ["firm_id"], indexes.first.columns
|
assert_equal ["firm_id"], indexes.first.columns
|
||||||
else
|
else
|
||||||
@ -127,14 +125,12 @@ def test_reset_empty_table_with_custom_pk
|
|||||||
assert_equal 1, Movie.create(:name => 'fight club').id
|
assert_equal 1, Movie.create(:name => 'fight club').id
|
||||||
end
|
end
|
||||||
|
|
||||||
if ActiveRecord::Base.connection.adapter_name != "FrontBase"
|
def test_reset_table_with_non_integer_pk
|
||||||
def test_reset_table_with_non_integer_pk
|
Subscriber.delete_all
|
||||||
Subscriber.delete_all
|
Subscriber.connection.reset_pk_sequence! 'subscribers'
|
||||||
Subscriber.connection.reset_pk_sequence! 'subscribers'
|
sub = Subscriber.new(:name => 'robert drake')
|
||||||
sub = Subscriber.new(:name => 'robert drake')
|
sub.id = 'bob drake'
|
||||||
sub.id = 'bob drake'
|
assert_nothing_raised { sub.save! }
|
||||||
assert_nothing_raised { sub.save! }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -144,7 +140,7 @@ def test_uniqueness_violations_are_translated_to_specific_exception
|
|||||||
@connection.execute "INSERT INTO subscribers(nick) VALUES('me')"
|
@connection.execute "INSERT INTO subscribers(nick) VALUES('me')"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
unless current_adapter?(:SQLite3Adapter)
|
unless current_adapter?(:SQLite3Adapter)
|
||||||
def test_foreign_key_violations_are_translated_to_specific_exception
|
def test_foreign_key_violations_are_translated_to_specific_exception
|
||||||
assert_raises(ActiveRecord::InvalidForeignKey) do
|
assert_raises(ActiveRecord::InvalidForeignKey) do
|
||||||
@ -157,7 +153,7 @@ def test_foreign_key_violations_are_translated_to_specific_exception
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_foreign_key_violations_are_translated_to_specific_exception_with_validate_false
|
def test_foreign_key_violations_are_translated_to_specific_exception_with_validate_false
|
||||||
klass_has_fk = Class.new(ActiveRecord::Base) do
|
klass_has_fk = Class.new(ActiveRecord::Base) do
|
||||||
self.table_name = 'fk_test_has_fk'
|
self.table_name = 'fk_test_has_fk'
|
||||||
|
@ -534,21 +534,13 @@ def test_eager_with_has_many_and_limit
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_eager_with_has_many_and_limit_and_conditions
|
def test_eager_with_has_many_and_limit_and_conditions
|
||||||
if current_adapter?(:OpenBaseAdapter)
|
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => "posts.body = 'hello'", :order => "posts.id").to_a
|
||||||
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => "FETCHBLOB(posts.body) = 'hello'", :order => "posts.id").to_a
|
|
||||||
else
|
|
||||||
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => "posts.body = 'hello'", :order => "posts.id").to_a
|
|
||||||
end
|
|
||||||
assert_equal 2, posts.size
|
assert_equal 2, posts.size
|
||||||
assert_equal [4,5], posts.collect { |p| p.id }
|
assert_equal [4,5], posts.collect { |p| p.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_eager_with_has_many_and_limit_and_conditions_array
|
def test_eager_with_has_many_and_limit_and_conditions_array
|
||||||
if current_adapter?(:OpenBaseAdapter)
|
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "posts.body = ?", 'hello' ], :order => "posts.id").to_a
|
||||||
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "FETCHBLOB(posts.body) = ?", 'hello' ], :order => "posts.id").to_a
|
|
||||||
else
|
|
||||||
posts = Post.all.merge!(:includes => [ :author, :comments ], :limit => 2, :where => [ "posts.body = ?", 'hello' ], :order => "posts.id").to_a
|
|
||||||
end
|
|
||||||
assert_equal 2, posts.size
|
assert_equal 2, posts.size
|
||||||
assert_equal [4,5], posts.collect { |p| p.id }
|
assert_equal [4,5], posts.collect { |p| p.id }
|
||||||
end
|
end
|
||||||
@ -940,13 +932,7 @@ def test_preconfigured_includes_with_has_many_and_habtm
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_count_with_include
|
def test_count_with_include
|
||||||
if current_adapter?(:SybaseAdapter)
|
assert_equal 3, authors(:david).posts_with_comments.where("length(comments.body) > 15").references(:comments).count
|
||||||
assert_equal 3, authors(:david).posts_with_comments.where("len(comments.body) > 15").references(:comments).count
|
|
||||||
elsif current_adapter?(:OpenBaseAdapter)
|
|
||||||
assert_equal 3, authors(:david).posts_with_comments.where("length(FETCHBLOB(comments.body)) > 15").references(:comments).count
|
|
||||||
else
|
|
||||||
assert_equal 3, authors(:david).posts_with_comments.where("length(comments.body) > 15").references(:comments).count
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_load_with_sti_sharing_association
|
def test_load_with_sti_sharing_association
|
||||||
|
@ -160,19 +160,11 @@ def test_table_exists
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_preserving_date_objects
|
def test_preserving_date_objects
|
||||||
if current_adapter?(:SybaseAdapter)
|
# Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
|
||||||
# Sybase ctlib does not (yet?) support the date type; use datetime instead.
|
assert_kind_of(
|
||||||
assert_kind_of(
|
Date, Topic.find(1).last_read,
|
||||||
Time, Topic.find(1).last_read,
|
"The last_read attribute should be of the Date class"
|
||||||
"The last_read attribute should be of the Time class"
|
)
|
||||||
)
|
|
||||||
else
|
|
||||||
# Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
|
|
||||||
assert_kind_of(
|
|
||||||
Date, Topic.find(1).last_read,
|
|
||||||
"The last_read attribute should be of the Date class"
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_previously_changed
|
def test_previously_changed
|
||||||
@ -480,8 +472,8 @@ def test_default_values
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Oracle, and Sybase do not have a TIME datatype.
|
# Oracle does not have a TIME datatype.
|
||||||
unless current_adapter?(:OracleAdapter, :SybaseAdapter)
|
unless current_adapter?(:OracleAdapter)
|
||||||
def test_utc_as_time_zone
|
def test_utc_as_time_zone
|
||||||
with_timezone_config default: :utc do
|
with_timezone_config default: :utc do
|
||||||
attributes = { "bonus_time" => "5:42:00AM" }
|
attributes = { "bonus_time" => "5:42:00AM" }
|
||||||
@ -515,12 +507,7 @@ def test_default_values_on_empty_strings
|
|||||||
topic = Topic.find(topic.id)
|
topic = Topic.find(topic.id)
|
||||||
assert_nil topic.last_read
|
assert_nil topic.last_read
|
||||||
|
|
||||||
# Sybase adapter does not allow nulls in boolean columns
|
assert_nil topic.approved
|
||||||
if current_adapter?(:SybaseAdapter)
|
|
||||||
assert topic.approved == false
|
|
||||||
else
|
|
||||||
assert_nil topic.approved
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_equality
|
def test_equality
|
||||||
@ -685,8 +672,8 @@ def test_group_weirds_by_from
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_attributes_on_dummy_time
|
def test_attributes_on_dummy_time
|
||||||
# Oracle, and Sybase do not have a TIME datatype.
|
# Oracle does not have a TIME datatype.
|
||||||
return true if current_adapter?(:OracleAdapter, :SybaseAdapter)
|
return true if current_adapter?(:OracleAdapter)
|
||||||
|
|
||||||
with_timezone_config default: :local do
|
with_timezone_config default: :local do
|
||||||
attributes = {
|
attributes = {
|
||||||
@ -699,8 +686,8 @@ def test_attributes_on_dummy_time
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_attributes_on_dummy_time_with_invalid_time
|
def test_attributes_on_dummy_time_with_invalid_time
|
||||||
# Oracle, and Sybase do not have a TIME datatype.
|
# Oracle does not have a TIME datatype.
|
||||||
return true if current_adapter?(:OracleAdapter, :SybaseAdapter)
|
return true if current_adapter?(:OracleAdapter)
|
||||||
|
|
||||||
attributes = {
|
attributes = {
|
||||||
"bonus_time" => "not a time"
|
"bonus_time" => "not a time"
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
require "cases/helper"
|
require "cases/helper"
|
||||||
|
|
||||||
# Without using prepared statements, it makes no sense to test
|
# Without using prepared statements, it makes no sense to test
|
||||||
# BLOB data with DB2 or Firebird, because the length of a statement
|
# BLOB data with DB2, because the length of a statement
|
||||||
# is limited to 32KB.
|
# is limited to 32KB.
|
||||||
unless current_adapter?(:SybaseAdapter, :DB2Adapter, :FirebirdAdapter)
|
unless current_adapter?(:DB2Adapter)
|
||||||
require 'models/binary'
|
require 'models/binary'
|
||||||
|
|
||||||
class BinaryTest < ActiveRecord::TestCase
|
class BinaryTest < ActiveRecord::TestCase
|
||||||
|
@ -18,7 +18,7 @@ def test_nil_defaults_for_not_null_columns
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if current_adapter?(:PostgreSQLAdapter, :FirebirdAdapter, :OpenBaseAdapter, :OracleAdapter)
|
if current_adapter?(:PostgreSQLAdapter, :OracleAdapter)
|
||||||
def test_default_integers
|
def test_default_integers
|
||||||
default = Default.new
|
default = Default.new
|
||||||
assert_instance_of Fixnum, default.positive_integer
|
assert_instance_of Fixnum, default.positive_integer
|
||||||
|
@ -95,16 +95,8 @@ def test_base_class_activerecord_error
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_a_bad_type_column
|
def test_a_bad_type_column
|
||||||
#SQLServer need to turn Identity Insert On before manually inserting into the Identity column
|
|
||||||
if current_adapter?(:SybaseAdapter)
|
|
||||||
Company.connection.execute "SET IDENTITY_INSERT companies ON"
|
|
||||||
end
|
|
||||||
Company.connection.insert "INSERT INTO companies (id, #{QUOTED_TYPE}, name) VALUES(100, 'bad_class!', 'Not happening')"
|
Company.connection.insert "INSERT INTO companies (id, #{QUOTED_TYPE}, name) VALUES(100, 'bad_class!', 'Not happening')"
|
||||||
|
|
||||||
#We then need to turn it back Off before continuing.
|
|
||||||
if current_adapter?(:SybaseAdapter)
|
|
||||||
Company.connection.execute "SET IDENTITY_INSERT companies OFF"
|
|
||||||
end
|
|
||||||
assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) }
|
assert_raise(ActiveRecord::SubclassNotFound) { Company.find(100) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -339,8 +339,6 @@ def test_destroy_dependents
|
|||||||
def add_counter_column_to(model, col='test_count')
|
def add_counter_column_to(model, col='test_count')
|
||||||
model.connection.add_column model.table_name, col, :integer, :null => false, :default => 0
|
model.connection.add_column model.table_name, col, :integer, :null => false, :default => 0
|
||||||
model.reset_column_information
|
model.reset_column_information
|
||||||
# OpenBase does not set a value to existing rows when adding a not null default column
|
|
||||||
model.update_all(col => 0) if current_adapter?(:OpenBaseAdapter)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_counter_column_from(model, col = :test_count)
|
def remove_counter_column_from(model, col = :test_count)
|
||||||
@ -367,7 +365,7 @@ def counter_test(model, expected_count)
|
|||||||
# is so cumbersome. Will deadlock Ruby threads if the underlying db.execute
|
# is so cumbersome. Will deadlock Ruby threads if the underlying db.execute
|
||||||
# blocks, so separate script called by Kernel#system is needed.
|
# blocks, so separate script called by Kernel#system is needed.
|
||||||
# (See exec vs. async_exec in the PostgreSQL adapter.)
|
# (See exec vs. async_exec in the PostgreSQL adapter.)
|
||||||
unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter) || in_memory_db?
|
unless in_memory_db?
|
||||||
class PessimisticLockingTest < ActiveRecord::TestCase
|
class PessimisticLockingTest < ActiveRecord::TestCase
|
||||||
self.use_transactional_fixtures = false
|
self.use_transactional_fixtures = false
|
||||||
fixtures :people, :readers
|
fixtures :people, :readers
|
||||||
|
@ -204,9 +204,9 @@ def test_create_table_without_a_block
|
|||||||
connection.create_table table_name
|
connection.create_table table_name
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sybase, and SQLite3 will not allow you to add a NOT NULL
|
# SQLite3 will not allow you to add a NOT NULL
|
||||||
# column to a table without a default value.
|
# column to a table without a default value.
|
||||||
unless current_adapter?(:SybaseAdapter, :SQLite3Adapter)
|
unless current_adapter?(:SQLite3Adapter)
|
||||||
def test_add_column_not_null_without_default
|
def test_add_column_not_null_without_default
|
||||||
connection.create_table :testings do |t|
|
connection.create_table :testings do |t|
|
||||||
t.column :foo, :string
|
t.column :foo, :string
|
||||||
@ -225,18 +225,11 @@ def test_add_column_not_null_with_default
|
|||||||
end
|
end
|
||||||
|
|
||||||
con = connection
|
con = connection
|
||||||
connection.enable_identity_insert("testings", true) if current_adapter?(:SybaseAdapter)
|
|
||||||
connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}) values (1, 'hello')"
|
connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}) values (1, 'hello')"
|
||||||
connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter)
|
|
||||||
assert_nothing_raised {connection.add_column :testings, :bar, :string, :null => false, :default => "default" }
|
assert_nothing_raised {connection.add_column :testings, :bar, :string, :null => false, :default => "default" }
|
||||||
|
|
||||||
assert_raises(ActiveRecord::StatementInvalid) do
|
assert_raises(ActiveRecord::StatementInvalid) do
|
||||||
unless current_adapter?(:OpenBaseAdapter)
|
connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)"
|
||||||
connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) values (2, 'hello', NULL)"
|
|
||||||
else
|
|
||||||
connection.insert("INSERT INTO testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}, #{con.quote_column_name('bar')}) VALUES (2, 'hello', NULL)",
|
|
||||||
"Testing Insert","id",2)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def test_native_decimal_insert_manual_vs_automatic
|
|||||||
# Do a manual insertion
|
# Do a manual insertion
|
||||||
if current_adapter?(:OracleAdapter)
|
if current_adapter?(:OracleAdapter)
|
||||||
connection.execute "insert into test_models (id, wealth) values (people_seq.nextval, 12345678901234567890.0123456789)"
|
connection.execute "insert into test_models (id, wealth) values (people_seq.nextval, 12345678901234567890.0123456789)"
|
||||||
elsif current_adapter?(:OpenBaseAdapter) || (current_adapter?(:MysqlAdapter) && Mysql.client_version < 50003) #before mysql 5.0.3 decimals stored as strings
|
elsif current_adapter?(:MysqlAdapter) && Mysql.client_version < 50003 #before mysql 5.0.3 decimals stored as strings
|
||||||
connection.execute "insert into test_models (wealth) values ('12345678901234567890.0123456789')"
|
connection.execute "insert into test_models (wealth) values ('12345678901234567890.0123456789')"
|
||||||
elsif current_adapter?(:PostgreSQLAdapter)
|
elsif current_adapter?(:PostgreSQLAdapter)
|
||||||
connection.execute "insert into test_models (wealth) values (12345678901234567890.0123456789)"
|
connection.execute "insert into test_models (wealth) values (12345678901234567890.0123456789)"
|
||||||
@ -160,8 +160,8 @@ def test_native_types
|
|||||||
assert_equal Fixnum, bob.age.class
|
assert_equal Fixnum, bob.age.class
|
||||||
assert_equal Time, bob.birthday.class
|
assert_equal Time, bob.birthday.class
|
||||||
|
|
||||||
if current_adapter?(:OracleAdapter, :SybaseAdapter)
|
if current_adapter?(:OracleAdapter)
|
||||||
# Sybase, and Oracle don't differentiate between date/time
|
# Oracle doesn't differentiate between date/time
|
||||||
assert_equal Time, bob.favorite_day.class
|
assert_equal Time, bob.favorite_day.class
|
||||||
else
|
else
|
||||||
assert_equal Date, bob.favorite_day.class
|
assert_equal Date, bob.favorite_day.class
|
||||||
|
@ -26,28 +26,25 @@ def setup
|
|||||||
ActiveRecord::Base.primary_key_prefix_type = nil
|
ActiveRecord::Base.primary_key_prefix_type = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
unless current_adapter?(:OpenBaseAdapter)
|
def test_rename_index
|
||||||
def test_rename_index
|
# keep the names short to make Oracle and similar behave
|
||||||
# keep the names short to make Oracle and similar behave
|
connection.add_index(table_name, [:foo], :name => 'old_idx')
|
||||||
connection.add_index(table_name, [:foo], :name => 'old_idx')
|
connection.rename_index(table_name, 'old_idx', 'new_idx')
|
||||||
connection.rename_index(table_name, 'old_idx', 'new_idx')
|
|
||||||
|
|
||||||
# if the adapter doesn't support the indexes call, pick defaults that let the test pass
|
# if the adapter doesn't support the indexes call, pick defaults that let the test pass
|
||||||
assert_not connection.index_name_exists?(table_name, 'old_idx', false)
|
assert_not connection.index_name_exists?(table_name, 'old_idx', false)
|
||||||
assert connection.index_name_exists?(table_name, 'new_idx', true)
|
assert connection.index_name_exists?(table_name, 'new_idx', true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_double_add_index
|
def test_double_add_index
|
||||||
|
connection.add_index(table_name, [:foo], :name => 'some_idx')
|
||||||
|
assert_raises(ArgumentError) {
|
||||||
connection.add_index(table_name, [:foo], :name => 'some_idx')
|
connection.add_index(table_name, [:foo], :name => 'some_idx')
|
||||||
assert_raises(ArgumentError) {
|
}
|
||||||
connection.add_index(table_name, [:foo], :name => 'some_idx')
|
end
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_remove_nonexistent_index
|
def test_remove_nonexistent_index
|
||||||
# we do this by name, so OpenBase is a wash as noted above
|
assert_raise(ArgumentError) { connection.remove_index(table_name, "no_such_index") }
|
||||||
assert_raise(ArgumentError) { connection.remove_index(table_name, "no_such_index") }
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_add_index_works_with_long_index_names
|
def test_add_index_works_with_long_index_names
|
||||||
@ -126,50 +123,37 @@ def test_add_index
|
|||||||
connection.add_index("testings", "last_name")
|
connection.add_index("testings", "last_name")
|
||||||
connection.remove_index("testings", "last_name")
|
connection.remove_index("testings", "last_name")
|
||||||
|
|
||||||
# Orcl nds shrt indx nms. Sybs 2.
|
connection.add_index("testings", ["last_name", "first_name"])
|
||||||
# OpenBase does not have named indexes. You must specify a single column name
|
connection.remove_index("testings", :column => ["last_name", "first_name"])
|
||||||
unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter)
|
|
||||||
|
# Oracle adapter cannot have specified index name larger than 30 characters
|
||||||
|
# Oracle adapter is shortening index name when just column list is given
|
||||||
|
unless current_adapter?(:OracleAdapter)
|
||||||
connection.add_index("testings", ["last_name", "first_name"])
|
connection.add_index("testings", ["last_name", "first_name"])
|
||||||
connection.remove_index("testings", :column => ["last_name", "first_name"])
|
connection.remove_index("testings", :name => :index_testings_on_last_name_and_first_name)
|
||||||
|
|
||||||
# Oracle adapter cannot have specified index name larger than 30 characters
|
|
||||||
# Oracle adapter is shortening index name when just column list is given
|
|
||||||
unless current_adapter?(:OracleAdapter)
|
|
||||||
connection.add_index("testings", ["last_name", "first_name"])
|
|
||||||
connection.remove_index("testings", :name => :index_testings_on_last_name_and_first_name)
|
|
||||||
connection.add_index("testings", ["last_name", "first_name"])
|
|
||||||
connection.remove_index("testings", "last_name_and_first_name")
|
|
||||||
end
|
|
||||||
connection.add_index("testings", ["last_name", "first_name"])
|
connection.add_index("testings", ["last_name", "first_name"])
|
||||||
connection.remove_index("testings", ["last_name", "first_name"])
|
connection.remove_index("testings", "last_name_and_first_name")
|
||||||
|
|
||||||
connection.add_index("testings", ["last_name"], :length => 10)
|
|
||||||
connection.remove_index("testings", "last_name")
|
|
||||||
|
|
||||||
connection.add_index("testings", ["last_name"], :length => {:last_name => 10})
|
|
||||||
connection.remove_index("testings", ["last_name"])
|
|
||||||
|
|
||||||
connection.add_index("testings", ["last_name", "first_name"], :length => 10)
|
|
||||||
connection.remove_index("testings", ["last_name", "first_name"])
|
|
||||||
|
|
||||||
connection.add_index("testings", ["last_name", "first_name"], :length => {:last_name => 10, :first_name => 20})
|
|
||||||
connection.remove_index("testings", ["last_name", "first_name"])
|
|
||||||
end
|
end
|
||||||
|
connection.add_index("testings", ["last_name", "first_name"])
|
||||||
|
connection.remove_index("testings", ["last_name", "first_name"])
|
||||||
|
|
||||||
# quoting
|
connection.add_index("testings", ["last_name"], :length => 10)
|
||||||
# Note: changed index name from "key" to "key_idx" since "key" is a Firebird reserved word
|
connection.remove_index("testings", "last_name")
|
||||||
# OpenBase does not have named indexes. You must specify a single column name
|
|
||||||
unless current_adapter?(:OpenBaseAdapter)
|
|
||||||
connection.add_index("testings", ["key"], :name => "key_idx", :unique => true)
|
|
||||||
connection.remove_index("testings", :name => "key_idx", :unique => true)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sybase adapter does not support indexes on :boolean columns
|
connection.add_index("testings", ["last_name"], :length => {:last_name => 10})
|
||||||
# OpenBase does not have named indexes. You must specify a single column
|
connection.remove_index("testings", ["last_name"])
|
||||||
unless current_adapter?(:SybaseAdapter, :OpenBaseAdapter)
|
|
||||||
connection.add_index("testings", %w(last_name first_name administrator), :name => "named_admin")
|
connection.add_index("testings", ["last_name", "first_name"], :length => 10)
|
||||||
connection.remove_index("testings", :name => "named_admin")
|
connection.remove_index("testings", ["last_name", "first_name"])
|
||||||
end
|
|
||||||
|
connection.add_index("testings", ["last_name", "first_name"], :length => {:last_name => 10, :first_name => 20})
|
||||||
|
connection.remove_index("testings", ["last_name", "first_name"])
|
||||||
|
|
||||||
|
connection.add_index("testings", ["key"], :name => "key_idx", :unique => true)
|
||||||
|
connection.remove_index("testings", :name => "key_idx", :unique => true)
|
||||||
|
|
||||||
|
connection.add_index("testings", %w(last_name first_name administrator), :name => "named_admin")
|
||||||
|
connection.remove_index("testings", :name => "named_admin")
|
||||||
|
|
||||||
# Selected adapters support index sort order
|
# Selected adapters support index sort order
|
||||||
if current_adapter?(:SQLite3Adapter, :MysqlAdapter, :Mysql2Adapter, :PostgreSQLAdapter)
|
if current_adapter?(:SQLite3Adapter, :MysqlAdapter, :Mysql2Adapter, :PostgreSQLAdapter)
|
||||||
|
@ -42,13 +42,8 @@ def test_rename_table_for_sqlite_should_work_with_reserved_words
|
|||||||
def test_rename_table
|
def test_rename_table
|
||||||
rename_table :test_models, :octopi
|
rename_table :test_models, :octopi
|
||||||
|
|
||||||
# Using explicit id in insert for compatibility across all databases
|
|
||||||
connection.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter)
|
|
||||||
|
|
||||||
connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
|
connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
|
||||||
|
|
||||||
connection.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter)
|
|
||||||
|
|
||||||
assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
|
assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -57,10 +52,7 @@ def test_rename_table_with_an_index
|
|||||||
|
|
||||||
rename_table :test_models, :octopi
|
rename_table :test_models, :octopi
|
||||||
|
|
||||||
# Using explicit id in insert for compatibility across all databases
|
|
||||||
connection.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter)
|
|
||||||
connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
|
connection.execute "INSERT INTO octopi (#{connection.quote_column_name('id')}, #{connection.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')"
|
||||||
connection.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter)
|
|
||||||
|
|
||||||
assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
|
assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', connection.select_value("SELECT url FROM octopi WHERE id=1")
|
||||||
index = connection.indexes(:octopi).first
|
index = connection.indexes(:octopi).first
|
||||||
|
@ -240,8 +240,8 @@ def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_at
|
|||||||
Topic.skip_time_zone_conversion_for_attributes = []
|
Topic.skip_time_zone_conversion_for_attributes = []
|
||||||
end
|
end
|
||||||
|
|
||||||
# Oracle, and Sybase do not have a TIME datatype.
|
# Oracle does not have a TIME datatype.
|
||||||
unless current_adapter?(:OracleAdapter, :SybaseAdapter)
|
unless current_adapter?(:OracleAdapter)
|
||||||
def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion
|
def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attributes_does_not_do_time_zone_conversion
|
||||||
with_timezone_config default: :utc, aware_attributes: true, zone: -28800 do
|
with_timezone_config default: :utc, aware_attributes: true, zone: -28800 do
|
||||||
attributes = {
|
attributes = {
|
||||||
|
@ -48,4 +48,4 @@ def test_pooled_connection_checkin_one
|
|||||||
def add_record(name)
|
def add_record(name)
|
||||||
ActiveRecord::Base.connection_pool.with_connection { Project.create! :name => name }
|
ActiveRecord::Base.connection_pool.with_connection { Project.create! :name => name }
|
||||||
end
|
end
|
||||||
end unless current_adapter?(:FrontBase) || in_memory_db?
|
end unless in_memory_db?
|
||||||
|
@ -10,13 +10,7 @@ def teardown
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_date_from_db(expected, actual, message = nil)
|
def assert_date_from_db(expected, actual, message = nil)
|
||||||
# SybaseAdapter doesn't have a separate column type just for dates,
|
assert_equal expected.to_s, actual.to_s, message
|
||||||
# so the time is in the string and incorrectly formatted
|
|
||||||
if current_adapter?(:SybaseAdapter)
|
|
||||||
assert_equal expected.to_s, actual.to_date.to_s, message
|
|
||||||
else
|
|
||||||
assert_equal expected.to_s, actual.to_s, message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def capture_sql
|
def capture_sql
|
||||||
|
@ -226,7 +226,6 @@ def test_to_xml
|
|||||||
xml = REXML::Document.new(topics(:first).to_xml(:indent => 0))
|
xml = REXML::Document.new(topics(:first).to_xml(:indent => 0))
|
||||||
bonus_time_in_current_timezone = topics(:first).bonus_time.xmlschema
|
bonus_time_in_current_timezone = topics(:first).bonus_time.xmlschema
|
||||||
written_on_in_current_timezone = topics(:first).written_on.xmlschema
|
written_on_in_current_timezone = topics(:first).written_on.xmlschema
|
||||||
last_read_in_current_timezone = topics(:first).last_read.xmlschema
|
|
||||||
|
|
||||||
assert_equal "topic", xml.root.name
|
assert_equal "topic", xml.root.name
|
||||||
assert_equal "The First Topic" , xml.elements["//title"].text
|
assert_equal "The First Topic" , xml.elements["//title"].text
|
||||||
@ -248,14 +247,9 @@ def test_to_xml
|
|||||||
assert_equal "integer", xml.elements["//parent-id"].attributes['type']
|
assert_equal "integer", xml.elements["//parent-id"].attributes['type']
|
||||||
assert_equal "true", xml.elements["//parent-id"].attributes['nil']
|
assert_equal "true", xml.elements["//parent-id"].attributes['nil']
|
||||||
|
|
||||||
if current_adapter?(:SybaseAdapter)
|
# Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
|
||||||
assert_equal last_read_in_current_timezone, xml.elements["//last-read"].text
|
assert_equal "2004-04-15", xml.elements["//last-read"].text
|
||||||
assert_equal "dateTime" , xml.elements["//last-read"].attributes['type']
|
assert_equal "date" , xml.elements["//last-read"].attributes['type']
|
||||||
else
|
|
||||||
# Oracle enhanced adapter allows to define Date attributes in model class (see topic.rb)
|
|
||||||
assert_equal "2004-04-15", xml.elements["//last-read"].text
|
|
||||||
assert_equal "date" , xml.elements["//last-read"].attributes['type']
|
|
||||||
end
|
|
||||||
|
|
||||||
# Oracle and DB2 don't have true boolean or time-only fields
|
# Oracle and DB2 don't have true boolean or time-only fields
|
||||||
unless current_adapter?(:OracleAdapter, :DB2Adapter)
|
unless current_adapter?(:OracleAdapter, :DB2Adapter)
|
||||||
|
@ -9,14 +9,6 @@ def except(adapter_names_to_exclude)
|
|||||||
|
|
||||||
#put adapter specific setup here
|
#put adapter specific setup here
|
||||||
case adapter_name
|
case adapter_name
|
||||||
# For Firebird, set the sequence values 10000 when create_table is called;
|
|
||||||
# this prevents primary key collisions between "normally" created records
|
|
||||||
# and fixture-based (YAML) records.
|
|
||||||
when "Firebird"
|
|
||||||
def create_table(*args, &block)
|
|
||||||
ActiveRecord::Base.connection.create_table(*args, &block)
|
|
||||||
ActiveRecord::Base.connection.execute "SET GENERATOR #{args.first}_seq TO 10000"
|
|
||||||
end
|
|
||||||
when "PostgreSQL"
|
when "PostgreSQL"
|
||||||
enable_uuid_ossp!(ActiveRecord::Base.connection)
|
enable_uuid_ossp!(ActiveRecord::Base.connection)
|
||||||
create_table :uuid_parents, id: :uuid, force: true do |t|
|
create_table :uuid_parents, id: :uuid, force: true do |t|
|
||||||
|
Loading…
Reference in New Issue
Block a user