From 84481dd3b42159428cd48ba67f811ed24deb6ed0 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Fri, 5 Jan 2007 00:12:06 +0000 Subject: Sybase adapter fixes. Closes #6926 [jsheets] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5839 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/associations/eager_test.rb | 2 +- activerecord/test/base_test.rb | 10 +++++----- activerecord/test/fixtures/db_definitions/sybase.drop.sql | 1 + activerecord/test/fixtures/db_definitions/sybase.sql | 4 ++-- activerecord/test/locking_test.rb | 4 ++-- activerecord/test/migration_test.rb | 10 ++++++++-- 6 files changed, 19 insertions(+), 12 deletions(-) (limited to 'activerecord/test') diff --git a/activerecord/test/associations/eager_test.rb b/activerecord/test/associations/eager_test.rb index e8e14c2c50..b303363f00 100644 --- a/activerecord/test/associations/eager_test.rb +++ b/activerecord/test/associations/eager_test.rb @@ -374,7 +374,7 @@ class EagerAssociationTest < Test::Unit::TestCase end def test_count_with_include - if current_adapter?(:SQLServerAdapter) + if current_adapter?(:SQLServerAdapter, :SybaseAdapter) assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "len(comments.body) > 15") else assert_equal 3, authors(:david).posts_with_comments.count(:conditions => "length(comments.body) > 15") diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index ab73ea77a7..672ad6f0bc 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -622,8 +622,8 @@ class BasicsTest < Test::Unit::TestCase end end - # Oracle and SQLServer do not have a TIME datatype. - unless current_adapter?(:SQLServerAdapter, :OracleAdapter) + # Oracle, SQLServer, and Sybase do not have a TIME datatype. + unless current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter) def test_utc_as_time_zone Topic.default_timezone = :utc attributes = { "bonus_time" => "5:42:00AM" } @@ -852,8 +852,8 @@ class BasicsTest < Test::Unit::TestCase end def test_attributes_on_dummy_time - # Oracle and SQL Server do not have a TIME datatype. - return true if current_adapter?(:SQLServerAdapter, :OracleAdapter) + # Oracle, SQL Server, and Sybase do not have a TIME datatype. + return true if current_adapter?(:SQLServerAdapter, :OracleAdapter, :SybaseAdapter) attributes = { "bonus_time" => "5:42:00AM" @@ -1075,7 +1075,7 @@ class BasicsTest < Test::Unit::TestCase end def test_sql_injection_via_find - assert_raises(ActiveRecord::RecordNotFound) do + assert_raises(ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid) do Topic.find("123456 OR id > 0") end end diff --git a/activerecord/test/fixtures/db_definitions/sybase.drop.sql b/activerecord/test/fixtures/db_definitions/sybase.drop.sql index fa51eefeeb..ebf2fc9736 100644 --- a/activerecord/test/fixtures/db_definitions/sybase.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sybase.drop.sql @@ -29,4 +29,5 @@ DROP TABLE fk_test_has_pk DROP TABLE keyboards DROP TABLE legacy_things DROP TABLE numeric_data +DROP TABLE schema_info go diff --git a/activerecord/test/fixtures/db_definitions/sybase.sql b/activerecord/test/fixtures/db_definitions/sybase.sql index 79c7b940b5..8544a4150e 100644 --- a/activerecord/test/fixtures/db_definitions/sybase.sql +++ b/activerecord/test/fixtures/db_definitions/sybase.sql @@ -197,12 +197,12 @@ CREATE TABLE keyboards ( CREATE TABLE legacy_things ( id numeric(9,0) IDENTITY PRIMARY KEY, tps_report_number int default NULL, - version int default 0, + version int default 0 ) CREATE TABLE numeric_data ( - id numeric((9,0) IDENTITY PRIMARY KEY, + id numeric(9,0) IDENTITY PRIMARY KEY, bank_balance numeric(10,2), big_bank_balance numeric(15,2), world_population numeric(10), diff --git a/activerecord/test/locking_test.rb b/activerecord/test/locking_test.rb index f786d77027..471771bfbb 100644 --- a/activerecord/test/locking_test.rb +++ b/activerecord/test/locking_test.rb @@ -81,9 +81,9 @@ end # blocks, so separate script called by Kernel#system is needed. # (See exec vs. async_exec in the PostgreSQL adapter.) -# TODO: The SQL Server adapter currently has no support for pessimistic locking +# TODO: The SQL Server and Sybase adapters currently have no support for pessimistic locking -unless current_adapter?(:SQLServerAdapter) +unless current_adapter?(:SQLServerAdapter, :SybaseAdapter) class PessimisticLockingTest < Test::Unit::TestCase self.use_transactional_fixtures = false fixtures :people, :readers diff --git a/activerecord/test/migration_test.rb b/activerecord/test/migration_test.rb index 3cfbcac82e..ce79ffc80e 100644 --- a/activerecord/test/migration_test.rb +++ b/activerecord/test/migration_test.rb @@ -58,8 +58,8 @@ if ActiveRecord::Base.connection.supports_migrations? assert_nothing_raised { Person.connection.add_index("people", "last_name") } assert_nothing_raised { Person.connection.remove_index("people", "last_name") } - # Orcl nds shrt indx nms. - unless current_adapter?(:OracleAdapter) + # Orcl nds shrt indx nms. Sybs 2. + unless current_adapter?(:OracleAdapter, :SybaseAdapter) assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } assert_nothing_raised { Person.connection.remove_index("people", :column => ["last_name", "first_name"]) } assert_nothing_raised { Person.connection.add_index("people", ["last_name", "first_name"]) } @@ -188,7 +188,9 @@ if ActiveRecord::Base.connection.supports_migrations? end con = Person.connection + Person.connection.enable_identity_insert("testings", true) if current_adapter?(:SybaseAdapter) Person.connection.execute "insert into testings (#{con.quote_column_name('id')}, #{con.quote_column_name('foo')}) values (1, 'hello')" + Person.connection.enable_identity_insert("testings", false) if current_adapter?(:SybaseAdapter) assert_nothing_raised {Person.connection.add_column :testings, :bar, :string, :null => false, :default => "default" } assert_raises(ActiveRecord::StatementInvalid) do @@ -367,7 +369,9 @@ if ActiveRecord::Base.connection.supports_migrations? # Using explicit id in insert for compatibility across all databases con = ActiveRecord::Base.connection + con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter) assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" } + con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter) assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', ActiveRecord::Base.connection.select_value("SELECT url FROM octopi WHERE id=1") @@ -388,7 +392,9 @@ if ActiveRecord::Base.connection.supports_migrations? # Using explicit id in insert for compatibility across all databases con = ActiveRecord::Base.connection + con.enable_identity_insert("octopi", true) if current_adapter?(:SybaseAdapter) assert_nothing_raised { con.execute "INSERT INTO octopi (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://www.foreverflying.com/octopus-black7.jpg')" } + con.enable_identity_insert("octopi", false) if current_adapter?(:SybaseAdapter) assert_equal 'http://www.foreverflying.com/octopus-black7.jpg', ActiveRecord::Base.connection.select_value("SELECT url FROM octopi WHERE id=1") assert ActiveRecord::Base.connection.indexes(:octopi).first.columns.include?("url") -- cgit v1.2.3