activerecord 1.13.0 → 1.13.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activerecord might be problematic. Click here for more details.
- data/CHANGELOG +91 -0
- data/lib/active_record.rb +2 -2
- data/lib/active_record/acts/list.rb +16 -12
- data/lib/active_record/acts/tree.rb +2 -2
- data/lib/active_record/aggregations.rb +6 -0
- data/lib/active_record/associations.rb +38 -16
- data/lib/active_record/associations/has_many_association.rb +2 -1
- data/lib/active_record/associations/has_one_association.rb +1 -1
- data/lib/active_record/base.rb +46 -33
- data/lib/active_record/connection_adapters/abstract/connection_specification.rb +33 -9
- data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +11 -2
- data/lib/active_record/connection_adapters/abstract/schema_statements.rb +3 -0
- data/lib/active_record/connection_adapters/abstract_adapter.rb +41 -21
- data/lib/active_record/connection_adapters/firebird_adapter.rb +414 -0
- data/lib/active_record/connection_adapters/mysql_adapter.rb +68 -29
- data/lib/active_record/connection_adapters/oci_adapter.rb +141 -21
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +82 -21
- data/lib/active_record/connection_adapters/sqlite_adapter.rb +3 -3
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +39 -6
- data/lib/active_record/fixtures.rb +1 -0
- data/lib/active_record/migration.rb +30 -13
- data/lib/active_record/validations.rb +18 -7
- data/lib/active_record/vendor/mysql.rb +89 -12
- data/lib/active_record/version.rb +2 -2
- data/rakefile +38 -3
- data/test/abstract_unit.rb +5 -0
- data/test/aggregations_test.rb +19 -0
- data/test/associations_go_eager_test.rb +26 -2
- data/test/associations_test.rb +29 -10
- data/test/base_test.rb +57 -6
- data/test/binary_test.rb +3 -3
- data/test/connections/native_db2/connection.rb +1 -1
- data/test/connections/native_firebird/connection.rb +24 -0
- data/test/connections/native_mysql/connection.rb +1 -1
- data/test/connections/native_oci/connection.rb +1 -1
- data/test/connections/native_postgresql/connection.rb +6 -6
- data/test/connections/native_sqlite/connection.rb +1 -1
- data/test/connections/native_sqlite3/connection.rb +1 -1
- data/test/connections/native_sqlite3/in_memory_connection.rb +1 -1
- data/test/connections/native_sqlserver/connection.rb +1 -1
- data/test/connections/native_sqlserver_odbc/connection.rb +1 -1
- data/test/default_test_firebird.rb +16 -0
- data/test/deprecated_associations_test.rb +1 -1
- data/test/finder_test.rb +11 -1
- data/test/fixtures/author.rb +30 -30
- data/test/fixtures/comment.rb +1 -1
- data/test/fixtures/company.rb +3 -1
- data/test/fixtures/customer.rb +4 -0
- data/test/fixtures/db_definitions/firebird.drop.sql +54 -0
- data/test/fixtures/db_definitions/firebird.sql +259 -0
- data/test/fixtures/db_definitions/firebird2.drop.sql +2 -0
- data/test/fixtures/db_definitions/firebird2.sql +6 -0
- data/test/fixtures/db_definitions/oci.sql +8 -0
- data/test/fixtures/db_definitions/postgresql.sql +3 -2
- data/test/fixtures/developer.rb +10 -0
- data/test/fixtures/fixture_database.sqlite +0 -0
- data/test/fixtures/fixture_database_2.sqlite +0 -0
- data/test/fixtures/mixin.rb +11 -1
- data/test/fixtures/mixins.yml +20 -1
- data/test/fixtures_test.rb +65 -45
- data/test/inheritance_test.rb +1 -1
- data/test/migration_test.rb +7 -1
- data/test/mixin_test.rb +267 -98
- data/test/multiple_db_test.rb +13 -1
- data/test/pk_test.rb +1 -0
- metadata +11 -5
- data/lib/active_record/vendor/mysql411.rb +0 -311
- data/test/debug.log +0 -2857
data/rakefile
CHANGED
@@ -9,7 +9,7 @@ require File.join(File.dirname(__FILE__), 'lib', 'active_record', 'version')
|
|
9
9
|
|
10
10
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
11
11
|
PKG_NAME = 'activerecord'
|
12
|
-
PKG_VERSION = ActiveRecord::
|
12
|
+
PKG_VERSION = ActiveRecord::VERSION::STRING + PKG_BUILD
|
13
13
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
14
14
|
|
15
15
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
@@ -27,7 +27,7 @@ task :default => [ :test_mysql, :test_sqlite, :test_postgresql ]
|
|
27
27
|
|
28
28
|
# Run the unit tests
|
29
29
|
|
30
|
-
for adapter in %w( mysql postgresql sqlite sqlite3 sqlserver sqlserver_odbc db2 oci )
|
30
|
+
for adapter in %w( mysql postgresql sqlite sqlite3 firebird sqlserver sqlserver_odbc db2 oci )
|
31
31
|
Rake::TestTask.new("test_#{adapter}") { |t|
|
32
32
|
t.libs << "test" << "test/connections/native_#{adapter}"
|
33
33
|
t.pattern = "test/*_test{,_#{adapter}}.rb"
|
@@ -35,6 +35,41 @@ for adapter in %w( mysql postgresql sqlite sqlite3 sqlserver sqlserver_odbc db2
|
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
38
|
+
SCHEMA_PATH = File.join(File.dirname(__FILE__), *%w(test fixtures db_definitions))
|
39
|
+
|
40
|
+
desc 'Build the MySQL test databases'
|
41
|
+
task :build_mysql_databases do
|
42
|
+
%x( mysqladmin create activerecord_unittest )
|
43
|
+
%x( mysqladmin create activerecord_unittest2 )
|
44
|
+
%x( mysql activerecord_unittest < #{File.join(SCHEMA_PATH, 'mysql.sql')} )
|
45
|
+
%x( mysql activerecord_unittest < #{File.join(SCHEMA_PATH, 'mysql2.sql')} )
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'Drop the MySQL test databases'
|
49
|
+
task :drop_mysql_databases do
|
50
|
+
%x( mysqladmin -f drop activerecord_unittest )
|
51
|
+
%x( mysqladmin -f drop activerecord_unittest2 )
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'Rebuild the MySQL test databases'
|
55
|
+
task :rebuild_mysql_databases => [:drop_mysql_databases, :build_mysql_databases]
|
56
|
+
|
57
|
+
desc 'Build the PostgreSQL test databases'
|
58
|
+
task :build_postgresql_databases do
|
59
|
+
%x( createdb activerecord_unittest )
|
60
|
+
%x( createdb activerecord_unittest2 )
|
61
|
+
%x( psql activerecord_unittest -f #{File.join(SCHEMA_PATH, 'postgresql.sql')} )
|
62
|
+
%x( psql activerecord_unittest -f #{File.join(SCHEMA_PATH, 'postgresql2.sql')} )
|
63
|
+
end
|
64
|
+
|
65
|
+
desc 'Drop the PostgreSQL test databases'
|
66
|
+
task :drop_postgresql_databases do
|
67
|
+
%x( dropdb activerecord_unittest )
|
68
|
+
%x( dropdb activerecord_unittest2 )
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Rebuild the PostgreSQL test databases'
|
72
|
+
task :rebuild_postgresql_databases => [:drop_postgresql_databases, :build_postgresql_databases]
|
38
73
|
|
39
74
|
# Generate the RDoc documentation
|
40
75
|
|
@@ -71,7 +106,7 @@ spec = Gem::Specification.new do |s|
|
|
71
106
|
s.files = s.files + Dir.glob( "#{dir}/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
72
107
|
end
|
73
108
|
|
74
|
-
s.add_dependency('activesupport', '= 1.2.
|
109
|
+
s.add_dependency('activesupport', '= 1.2.4' + PKG_BUILD)
|
75
110
|
|
76
111
|
s.files.delete "test/fixtures/fixture_database.sqlite"
|
77
112
|
s.files.delete "test/fixtures/fixture_database_2.sqlite"
|
data/test/abstract_unit.rb
CHANGED
@@ -8,6 +8,8 @@ require 'active_support/binding_of_caller'
|
|
8
8
|
require 'active_support/breakpoint'
|
9
9
|
require 'connection'
|
10
10
|
|
11
|
+
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') unless Object.const_defined?(:QUOTED_TYPE)
|
12
|
+
|
11
13
|
class Test::Unit::TestCase #:nodoc:
|
12
14
|
self.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
13
15
|
self.use_instantiated_fixtures = false
|
@@ -22,3 +24,6 @@ def current_adapter?(type)
|
|
22
24
|
ActiveRecord::ConnectionAdapters.const_defined?(type) &&
|
23
25
|
ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters.const_get(type))
|
24
26
|
end
|
27
|
+
|
28
|
+
#ActiveRecord::Base.logger = Logger.new(STDOUT)
|
29
|
+
#ActiveRecord::Base.colorize_logging = false
|
data/test/aggregations_test.rb
CHANGED
@@ -44,4 +44,23 @@ class AggregationsTest < Test::Unit::TestCase
|
|
44
44
|
assert_equal "39", customers(:david).gps_location.latitude
|
45
45
|
assert_equal "-110", customers(:david).gps_location.longitude
|
46
46
|
end
|
47
|
+
|
48
|
+
def test_reloaded_instance_refreshes_aggregations
|
49
|
+
assert_equal "35.544623640962634", customers(:david).gps_location.latitude
|
50
|
+
assert_equal "-105.9309951055148", customers(:david).gps_location.longitude
|
51
|
+
|
52
|
+
Customer.update_all("gps_location = '24x113'")
|
53
|
+
customers(:david).reload
|
54
|
+
assert_equal '24x113', customers(:david)['gps_location']
|
55
|
+
|
56
|
+
assert_equal GpsLocation.new('24x113'), customers(:david).gps_location
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_gps_equality
|
60
|
+
assert GpsLocation.new('39x110') == GpsLocation.new('39x110')
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_gps_inequality
|
64
|
+
assert GpsLocation.new('39x110') != GpsLocation.new('39x111')
|
65
|
+
end
|
47
66
|
end
|
@@ -21,7 +21,7 @@ class EagerAssociationTest < Test::Unit::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_loading_conditions_with_or
|
24
|
-
posts = authors(:david).posts.find(:all, :include => :comments, :conditions => "comments.body like 'Normal%' OR comments
|
24
|
+
posts = authors(:david).posts.find(:all, :include => :comments, :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE} = 'SpecialComment'")
|
25
25
|
assert_nil posts.detect { |p| p.author_id != authors(:david).id },
|
26
26
|
"expected to find only david's posts"
|
27
27
|
end
|
@@ -83,6 +83,12 @@ class EagerAssociationTest < Test::Unit::TestCase
|
|
83
83
|
assert_equal [6,7,8], comments.collect { |c| c.id }
|
84
84
|
end
|
85
85
|
|
86
|
+
def test_eager_association_loading_with_belongs_to_and_limit_and_offset_and_conditions_array
|
87
|
+
comments = Comment.find(:all, :include => :post, :conditions => ['post_id = ?',4], :limit => 3, :offset => 1, :order => 'comments.id')
|
88
|
+
assert_equal 3, comments.length
|
89
|
+
assert_equal [6,7,8], comments.collect { |c| c.id }
|
90
|
+
end
|
91
|
+
|
86
92
|
def test_eager_association_loading_with_belongs_to_and_limit_and_multiple_associations
|
87
93
|
posts = Post.find(:all, :include => [:author, :very_special_comment], :limit => 1)
|
88
94
|
assert_equal 1, posts.length
|
@@ -101,6 +107,24 @@ class EagerAssociationTest < Test::Unit::TestCase
|
|
101
107
|
assert_equal 3, posts.inject(0) { |sum, post| sum += post.comments.size }
|
102
108
|
end
|
103
109
|
|
110
|
+
def test_eager_with_has_many_and_limit_and_conditions
|
111
|
+
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.body = 'hello'", :order => "posts.id")
|
112
|
+
assert_equal 2, posts.size
|
113
|
+
assert_equal [4,5], posts.collect { |p| p.id }
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_eager_with_has_many_and_limit_and_conditions_array
|
117
|
+
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "posts.body = ?", 'hello' ], :order => "posts.id")
|
118
|
+
assert_equal 2, posts.size
|
119
|
+
assert_equal [4,5], posts.collect { |p| p.id }
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_eager_with_has_many_and_limit_and_conditions_array_on_the_eagers
|
123
|
+
assert_raises(ArgumentError) do
|
124
|
+
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => [ "authors.name = ?", 'David' ])
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
104
128
|
def test_eager_with_has_many_and_limit_with_no_results
|
105
129
|
posts = Post.find(:all, :include => [ :author, :comments ], :limit => 2, :conditions => "posts.title = 'magic forest'")
|
106
130
|
assert_equal 0, posts.size
|
@@ -120,7 +144,7 @@ class EagerAssociationTest < Test::Unit::TestCase
|
|
120
144
|
assert_raises(ArgumentError) do
|
121
145
|
posts = authors(:david).posts.find(:all,
|
122
146
|
:include => :comments,
|
123
|
-
:conditions => "comments.body like 'Normal%' OR comments
|
147
|
+
:conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'",
|
124
148
|
:limit => 2
|
125
149
|
)
|
126
150
|
end
|
data/test/associations_test.rb
CHANGED
@@ -351,7 +351,7 @@ class HasManyAssociationsTest < Test::Unit::TestCase
|
|
351
351
|
def test_find_all
|
352
352
|
firm = Firm.find_first
|
353
353
|
assert_equal firm.clients, firm.clients.find_all
|
354
|
-
assert_equal 2, firm.clients.find(:all, :conditions => "
|
354
|
+
assert_equal 2, firm.clients.find(:all, :conditions => "#{QUOTED_TYPE} = 'Client'").length
|
355
355
|
assert_equal 1, firm.clients.find(:all, :conditions => "name = 'Summit'").length
|
356
356
|
end
|
357
357
|
|
@@ -367,16 +367,16 @@ class HasManyAssociationsTest < Test::Unit::TestCase
|
|
367
367
|
firm = Firm.find_first
|
368
368
|
client2 = Client.find(2)
|
369
369
|
assert_equal firm.clients.first, firm.clients.find_first
|
370
|
-
assert_equal client2, firm.clients.find_first("
|
371
|
-
assert_equal client2, firm.clients.find(:first, :conditions => "
|
370
|
+
assert_equal client2, firm.clients.find_first("#{QUOTED_TYPE} = 'Client'")
|
371
|
+
assert_equal client2, firm.clients.find(:first, :conditions => "#{QUOTED_TYPE} = 'Client'")
|
372
372
|
end
|
373
373
|
|
374
374
|
def test_find_first_sanitized
|
375
375
|
firm = Firm.find_first
|
376
376
|
client2 = Client.find(2)
|
377
|
-
assert_equal client2, firm.clients.find_first(["
|
378
|
-
assert_equal client2, firm.clients.find(:first, :conditions => [
|
379
|
-
assert_equal client2, firm.clients.find(:first, :conditions => [
|
377
|
+
assert_equal client2, firm.clients.find_first(["#{QUOTED_TYPE} = ?", "Client"])
|
378
|
+
assert_equal client2, firm.clients.find(:first, :conditions => ["#{QUOTED_TYPE} = ?", 'Client'])
|
379
|
+
assert_equal client2, firm.clients.find(:first, :conditions => ["#{QUOTED_TYPE} = :type", { :type => 'Client' }])
|
380
380
|
end
|
381
381
|
|
382
382
|
def test_find_in_collection
|
@@ -384,6 +384,13 @@ class HasManyAssociationsTest < Test::Unit::TestCase
|
|
384
384
|
assert_raises(ActiveRecord::RecordNotFound) { companies(:first_firm).clients.find(6) }
|
385
385
|
end
|
386
386
|
|
387
|
+
def test_find_grouped
|
388
|
+
all_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1")
|
389
|
+
grouped_clients_of_firm1 = Client.find(:all, :conditions => "firm_id = 1", :group => "firm_id", :select => 'firm_id, count(id) as clients_count')
|
390
|
+
assert_equal 2, all_clients_of_firm1.size
|
391
|
+
assert_equal 1, grouped_clients_of_firm1.size
|
392
|
+
end
|
393
|
+
|
387
394
|
def test_adding
|
388
395
|
force_signal37_to_load_all_clients_of_firm
|
389
396
|
natural = Client.new("name" => "Natural Company")
|
@@ -1246,10 +1253,13 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|
1246
1253
|
end
|
1247
1254
|
|
1248
1255
|
def test_removing_associations_on_destroy
|
1249
|
-
|
1250
|
-
assert
|
1256
|
+
david = DeveloperWithBeforeDestroyRaise.find(1)
|
1257
|
+
assert !david.projects.empty?
|
1258
|
+
assert_nothing_raised { david.destroy }
|
1259
|
+
assert david.projects.empty?
|
1260
|
+
assert DeveloperWithBeforeDestroyRaise.connection.select_all("SELECT * FROM developers_projects WHERE developer_id = 1").empty?
|
1251
1261
|
end
|
1252
|
-
|
1262
|
+
|
1253
1263
|
def test_additional_columns_from_join_table
|
1254
1264
|
# SQL Server doesn't have a separate column type just for dates,
|
1255
1265
|
# so the time is in the string and incorrectly formatted
|
@@ -1371,5 +1381,14 @@ class HasAndBelongsToManyAssociationsTest < Test::Unit::TestCase
|
|
1371
1381
|
assert developer.special_projects.include?(special_project)
|
1372
1382
|
assert !developer.special_projects.include?(other_project)
|
1373
1383
|
end
|
1374
|
-
|
1384
|
+
|
1385
|
+
def test_update_attributes_after_push_without_duplicate_join_table_rows
|
1386
|
+
developer = Developer.new("name" => "Kano")
|
1387
|
+
project = SpecialProject.create("name" => "Special Project")
|
1388
|
+
assert developer.save
|
1389
|
+
developer.projects << project
|
1390
|
+
developer.update_attribute("name", "Bruza")
|
1391
|
+
assert_equal 1, developer.connection.select_one("SELECT count(*) FROM developers_projects WHERE
|
1392
|
+
project_id = #{project.id} AND developer_id = #{developer.id}")["count(*)"].to_i
|
1393
|
+
end
|
1375
1394
|
end
|
data/test/base_test.rb
CHANGED
@@ -17,6 +17,7 @@ class MasterCreditCard < ActiveRecord::Base; end
|
|
17
17
|
class Post < ActiveRecord::Base; end
|
18
18
|
class Computer < ActiveRecord::Base; end
|
19
19
|
class NonExistentTable < ActiveRecord::Base; end
|
20
|
+
class TestOCIDefault < ActiveRecord::Base; end
|
20
21
|
|
21
22
|
class LoosePerson < ActiveRecord::Base
|
22
23
|
attr_protected :credit_rating, :administrator
|
@@ -205,6 +206,40 @@ class BasicsTest < Test::Unit::TestCase
|
|
205
206
|
topic = topics(:first)
|
206
207
|
topic.approved = false
|
207
208
|
assert !topic.approved?, "approved should be false"
|
209
|
+
topic.approved = "false"
|
210
|
+
assert !topic.approved?, "approved should be false"
|
211
|
+
end
|
212
|
+
|
213
|
+
def test_read_attribute_when_true
|
214
|
+
topic = topics(:first)
|
215
|
+
topic.approved = true
|
216
|
+
assert topic.approved?, "approved should be true"
|
217
|
+
topic.approved = "true"
|
218
|
+
assert topic.approved?, "approved should be true"
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_read_write_boolean_attribute
|
222
|
+
topic = Topic.new
|
223
|
+
# puts ""
|
224
|
+
# puts "New Topic"
|
225
|
+
# puts topic.inspect
|
226
|
+
topic.approved = "false"
|
227
|
+
# puts "Expecting false"
|
228
|
+
# puts topic.inspect
|
229
|
+
assert !topic.approved?, "approved should be false"
|
230
|
+
topic.approved = "false"
|
231
|
+
# puts "Expecting false"
|
232
|
+
# puts topic.inspect
|
233
|
+
assert !topic.approved?, "approved should be false"
|
234
|
+
topic.approved = "true"
|
235
|
+
# puts "Expecting true"
|
236
|
+
# puts topic.inspect
|
237
|
+
assert topic.approved?, "approved should be true"
|
238
|
+
topic.approved = "true"
|
239
|
+
# puts "Expecting true"
|
240
|
+
# puts topic.inspect
|
241
|
+
assert topic.approved?, "approved should be true"
|
242
|
+
# puts ""
|
208
243
|
end
|
209
244
|
|
210
245
|
def test_reader_generation
|
@@ -220,6 +255,13 @@ class BasicsTest < Test::Unit::TestCase
|
|
220
255
|
end
|
221
256
|
end
|
222
257
|
|
258
|
+
def test_reader_for_invalid_column_names
|
259
|
+
# column names which aren't legal ruby ids
|
260
|
+
topic = Topic.find(:first)
|
261
|
+
topic.send(:define_read_method, "mumub-jumbo".to_sym, "mumub-jumbo", nil)
|
262
|
+
assert !Topic.read_methods.include?("mumub-jumbo")
|
263
|
+
end
|
264
|
+
|
223
265
|
def test_non_attribute_access_and_assignment
|
224
266
|
topic = Topic.new
|
225
267
|
assert !topic.respond_to?("mumbo")
|
@@ -470,6 +512,15 @@ class BasicsTest < Test::Unit::TestCase
|
|
470
512
|
topic = Topic.find(topic.id)
|
471
513
|
assert topic.approved?
|
472
514
|
assert_nil topic.last_read
|
515
|
+
|
516
|
+
# Oracle has some funky default handling, so it requires a bit of
|
517
|
+
# extra testing. See ticket #2788.
|
518
|
+
if current_adapter?(:OCIAdapter)
|
519
|
+
test = TestOCIDefault.new
|
520
|
+
assert_equal "X", test.test_char
|
521
|
+
assert_equal "hello", test.test_string
|
522
|
+
assert_equal 3, test.test_int
|
523
|
+
end
|
473
524
|
end
|
474
525
|
|
475
526
|
def test_utc_as_time_zone
|
@@ -495,7 +546,7 @@ class BasicsTest < Test::Unit::TestCase
|
|
495
546
|
assert_nil topic.last_read
|
496
547
|
assert_nil topic.approved
|
497
548
|
end
|
498
|
-
|
549
|
+
|
499
550
|
def test_equality
|
500
551
|
assert_equal Topic.find(1), Topic.find(2).parent
|
501
552
|
end
|
@@ -839,10 +890,10 @@ class BasicsTest < Test::Unit::TestCase
|
|
839
890
|
def test_column_name_properly_quoted
|
840
891
|
col_record = ColumnName.new
|
841
892
|
col_record.references = 40
|
842
|
-
col_record.save
|
893
|
+
assert col_record.save
|
843
894
|
col_record.references = 41
|
844
|
-
col_record.save
|
845
|
-
c2 = ColumnName.find(col_record.id)
|
895
|
+
assert col_record.save
|
896
|
+
assert_not_nil c2 = ColumnName.find(col_record.id)
|
846
897
|
assert_equal(41, c2.references)
|
847
898
|
end
|
848
899
|
|
@@ -993,10 +1044,10 @@ class BasicsTest < Test::Unit::TestCase
|
|
993
1044
|
end
|
994
1045
|
|
995
1046
|
def test_count_with_join
|
996
|
-
res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts
|
1047
|
+
res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'"
|
997
1048
|
res2 = res + 1
|
998
1049
|
assert_nothing_raised do
|
999
|
-
res2 = Post.count("posts
|
1050
|
+
res2 = Post.count("posts.#{QUOTED_TYPE} = 'Post'",
|
1000
1051
|
"LEFT JOIN comments ON posts.id=comments.post_id")
|
1001
1052
|
end
|
1002
1053
|
assert_equal res, res2
|
data/test/binary_test.rb
CHANGED
@@ -18,9 +18,9 @@ class BinaryTest < Test::Unit::TestCase
|
|
18
18
|
# limited to 8KB.
|
19
19
|
#
|
20
20
|
# Without using prepared statements, it makes no sense to test
|
21
|
-
# BLOB data with DB2, because the length of a statement
|
22
|
-
# limited to 32KB.
|
23
|
-
unless %w(SQLServer DB2 OCI).include? ActiveRecord::Base.connection.adapter_name
|
21
|
+
# BLOB data with DB2 or Firebird, because the length of a statement
|
22
|
+
# is limited to 32KB.
|
23
|
+
unless %w(SQLServer DB2 OCI Firebird).include? ActiveRecord::Base.connection.adapter_name
|
24
24
|
def test_load_save
|
25
25
|
bin = Binary.new
|
26
26
|
bin.data = @data
|
@@ -0,0 +1,24 @@
|
|
1
|
+
print "Using native Firebird\n"
|
2
|
+
require_dependency 'fixtures/course'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
ActiveRecord::Base.logger = Logger.new("debug.log")
|
6
|
+
|
7
|
+
db1 = 'activerecord_unittest'
|
8
|
+
db2 = 'activerecord_unittest2'
|
9
|
+
|
10
|
+
ActiveRecord::Base.establish_connection(
|
11
|
+
:adapter => "firebird",
|
12
|
+
:host => "localhost",
|
13
|
+
:username => "rails",
|
14
|
+
:password => "rails",
|
15
|
+
:database => db1
|
16
|
+
)
|
17
|
+
|
18
|
+
Course.establish_connection(
|
19
|
+
:adapter => "firebird",
|
20
|
+
:host => "localhost",
|
21
|
+
:username => "rails",
|
22
|
+
:password => "rails",
|
23
|
+
:database => db2
|
24
|
+
)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
print "Using native PostgreSQL\n"
|
2
|
-
|
2
|
+
require_dependency 'fixtures/course'
|
3
3
|
require 'logger'
|
4
4
|
|
5
5
|
ActiveRecord::Base.logger = Logger.new("debug.log")
|
@@ -9,16 +9,16 @@ db2 = 'activerecord_unittest2'
|
|
9
9
|
|
10
10
|
ActiveRecord::Base.establish_connection(
|
11
11
|
:adapter => "postgresql",
|
12
|
-
:host => nil,
|
13
12
|
:username => "postgres",
|
14
13
|
:password => "postgres",
|
15
|
-
:database => db1
|
14
|
+
:database => db1,
|
15
|
+
:min_messages => "warning"
|
16
16
|
)
|
17
17
|
|
18
18
|
Course.establish_connection(
|
19
19
|
:adapter => "postgresql",
|
20
|
-
:host => nil,
|
21
20
|
:username => "postgres",
|
22
21
|
:password => "postgres",
|
23
|
-
:database => db2
|
24
|
-
|
22
|
+
:database => db2,
|
23
|
+
:min_messages => "warning"
|
24
|
+
)
|