diff options
Diffstat (limited to 'activerecord/test')
5 files changed, 46 insertions, 56 deletions
diff --git a/activerecord/test/column_alias_test.rb b/activerecord/test/column_alias_test.rb index 1c84e119f3..f84d584eee 100644 --- a/activerecord/test/column_alias_test.rb +++ b/activerecord/test/column_alias_test.rb @@ -11,7 +11,7 @@ class TestColumnAlias < Test::Unit::TestCase assert_equal(records[0].keys[0], "pk") end else - records = topic.connection.select_all("SELECT id AS pk FROM topics LIMIT 1") + records = topic.connection.select_all("SELECT id AS pk FROM topics") assert_equal(records[0].keys[0], "pk") end end diff --git a/activerecord/test/connections/native_sqlserver/connection.rb b/activerecord/test/connections/native_sqlserver/connection.rb index 8d758a02ab..aa19fc7700 100644 --- a/activerecord/test/connections/native_sqlserver/connection.rb +++ b/activerecord/test/connections/native_sqlserver/connection.rb @@ -4,6 +4,9 @@ require 'logger' ActiveRecord::Base.logger = Logger.new("debug.log") +db1 = 'activerecord_unittest' +db2 = 'activerecord_unittest2' + ActiveRecord::Base.establish_connection( :adapter => "sqlserver", :host => "localhost", diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index de6d240faa..6b6b58a9c8 100755 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -2,10 +2,11 @@ require 'abstract_unit' require 'fixtures/company' require 'fixtures/topic' require 'fixtures/entrant' +require 'fixtures/developer' class FinderTest < Test::Unit::TestCase fixtures :companies, :topics, :entrants, :developers - + def test_find assert_equal(@topics["first"]["title"], Topic.find(1).title) end @@ -43,10 +44,10 @@ class FinderTest < Test::Unit::TestCase def test_find_all_with_prepared_limit_and_offset if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter) - assert_raises(ArgumentError) { Entrant.find_all nil, "id ASC", ["? OFFSET ?", 2, 1] } + assert_raises(ArgumentError) { Entrant.find_all nil, "id ASC", [2, 1] } end else - entrants = Entrant.find_all nil, "id ASC", ["? OFFSET ?", 2, 1] + entrants = Entrant.find_all nil, "id ASC", [2, 1] assert_equal(2, entrants.size) assert_equal(@entrants["second"]["name"], entrants.first.name) @@ -256,11 +257,11 @@ class FinderTest < Test::Unit::TestCase assert_equal first_five_developers, Developer.find_all(nil, 'id ASC', [5]) assert_equal no_developers, Developer.find_all(nil, 'id ASC', [0]) end - + def test_find_all_with_limit_and_offset first_three_developers = Developer.find_all nil, 'id ASC', [3, 0] second_three_developers = Developer.find_all nil, 'id ASC', [3, 3] - last_two_developers = Developer.find_all nil, 'id ASC', [3, 8] + last_two_developers = Developer.find_all nil, 'id ASC', [2, 8] assert_equal 3, first_three_developers.length assert_equal 3, second_three_developers.length diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql index 1f611c8d5a..19da3f8e61 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.drop.sql @@ -14,5 +14,4 @@ DROP TABLE colnametests; DROP TABLE mixins; DROP TABLE people; DROP TABLE binaries; -DROP TABLE computers; - +DROP TABLE computers;
\ No newline at end of file diff --git a/activerecord/test/fixtures/db_definitions/sqlserver.sql b/activerecord/test/fixtures/db_definitions/sqlserver.sql index 4ed5b8ef79..11d5b30255 100644 --- a/activerecord/test/fixtures/db_definitions/sqlserver.sql +++ b/activerecord/test/fixtures/db_definitions/sqlserver.sql @@ -1,88 +1,79 @@ CREATE TABLE accounts ( - id int NOT NULL IDENTITY(1, 1), + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, firm_id int default NULL, - credit_limit int default NULL, - PRIMARY KEY (id) + credit_limit int default NULL ) CREATE TABLE companies ( - id int NOT NULL IDENTITY(1, 1), + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, type varchar(50) default NULL, ruby_type varchar(50) default NULL, firm_id int default NULL, name varchar(50) default NULL, client_of int default NULL, - companies_count int default 0, - rating int default 1, - PRIMARY KEY (id) + rating int default 1 ) CREATE TABLE topics ( - id int NOT NULL IDENTITY(1, 1), + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, title varchar(255) default NULL, author_name varchar(255) default NULL, author_email_address varchar(255) default NULL, written_on datetime default NULL, + bonus_time datetime default NULL, last_read datetime default NULL, content text, approved tinyint default 1, replies_count int default 0, parent_id int default NULL, - type varchar(50) default NULL, - PRIMARY KEY (id) + type varchar(50) default NULL ) CREATE TABLE developers ( - id int NOT NULL IDENTITY(1, 1), + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, name varchar(100) default NULL, - PRIMARY KEY (id) + salary int default 70000 ); CREATE TABLE projects ( - id int NOT NULL IDENTITY(1, 1), - name varchar(100) default NULL, - salary int default 70000, - PRIMARY KEY (id) + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + name varchar(100) default NULL ); CREATE TABLE developers_projects ( developer_id int NOT NULL, - project_id int NOT NULL + project_id int NOT NULL, + joined_on datetime default NULL ); CREATE TABLE customers ( - id int NOT NULL IDENTITY(1, 1), + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, name varchar(100) default NULL, balance int default 0, address_street varchar(100) default NULL, address_city varchar(100) default NULL, address_country varchar(100) default NULL, - gps_location varchar(100) default NULL, - PRIMARY KEY (id) + gps_location varchar(100) default NULL ); CREATE TABLE movies ( - movieid int NOT NULL IDENTITY(1, 1), - name varchar(100) default NULL, - PRIMARY KEY (movieid) + movieid int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + name varchar(100) default NULL ); CREATE TABLE subscribers ( - nick varchar(100) NOT NULL, - name varchar(100) default NULL, - PRIMARY KEY (nick) + nick varchar(100) NOT NULL PRIMARY KEY, + name varchar(100) default NULL ); CREATE TABLE booleantests ( - id int NOT NULL IDENTITY(1, 1), - value integer default NULL, - PRIMARY KEY (id) + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + value bit default NULL ); CREATE TABLE auto_id_tests ( - auto_id int NOT NULL IDENTITY(1, 1), - value int default NULL, - PRIMARY KEY (auto_id) + auto_id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + value int default NULL ); CREATE TABLE entrants ( @@ -92,22 +83,20 @@ CREATE TABLE entrants ( ); CREATE TABLE colnametests ( - id int NOT NULL IDENTITY(1, 1), - [references] int NOT NULL, - PRIMARY KEY (id) + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + [references] int NOT NULL ); CREATE TABLE mixins ( - id int NOT NULL IDENTITY(1, 1), - parent_id int default NULL, - type varchar(40) default NULL, + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + parent_id int default NULL, pos int default NULL, - lft int default NULL, - rgt int default NULL, - root_id int default NULL, created_at datetime default NULL, updated_at datetime default NULL, - PRIMARY KEY (id) + lft int default NULL, + rgt int default NULL, + root_id int default NULL, + type varchar(40) default NULL ); CREATE TABLE people ( @@ -118,14 +107,12 @@ CREATE TABLE people ( ); CREATE TABLE binaries ( - id int NOT NULL IDENTITY(1, 1), - data image NULL, - PRIMARY KEY (id) + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + data image NULL ); CREATE TABLE computers ( - id int NOT NULL IDENTITY(1, 1), - developer int NOT NULL, - PRIMARY KEY (id) + id int NOT NULL IDENTITY(1, 1) PRIMARY KEY, + developer int NOT NULL ); |