activerecord 1.14.4 → 1.15.0

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.

Files changed (159) hide show
  1. data/CHANGELOG +400 -1
  2. data/README +2 -2
  3. data/RUNNING_UNIT_TESTS +21 -3
  4. data/Rakefile +55 -10
  5. data/lib/active_record.rb +10 -4
  6. data/lib/active_record/acts/list.rb +15 -4
  7. data/lib/active_record/acts/nested_set.rb +11 -12
  8. data/lib/active_record/acts/tree.rb +13 -14
  9. data/lib/active_record/aggregations.rb +46 -22
  10. data/lib/active_record/associations.rb +213 -162
  11. data/lib/active_record/associations/association_collection.rb +45 -15
  12. data/lib/active_record/associations/association_proxy.rb +32 -13
  13. data/lib/active_record/associations/has_and_belongs_to_many_association.rb +18 -18
  14. data/lib/active_record/associations/has_many_association.rb +37 -17
  15. data/lib/active_record/associations/has_many_through_association.rb +120 -30
  16. data/lib/active_record/associations/has_one_association.rb +1 -1
  17. data/lib/active_record/attribute_methods.rb +75 -0
  18. data/lib/active_record/base.rb +282 -203
  19. data/lib/active_record/calculations.rb +95 -54
  20. data/lib/active_record/callbacks.rb +13 -24
  21. data/lib/active_record/connection_adapters/abstract/connection_specification.rb +12 -1
  22. data/lib/active_record/connection_adapters/abstract/connection_specification.rb.rej +21 -0
  23. data/lib/active_record/connection_adapters/abstract/database_statements.rb +30 -4
  24. data/lib/active_record/connection_adapters/abstract/quoting.rb +16 -9
  25. data/lib/active_record/connection_adapters/abstract/schema_definitions.rb +121 -37
  26. data/lib/active_record/connection_adapters/abstract/schema_statements.rb +55 -23
  27. data/lib/active_record/connection_adapters/abstract_adapter.rb +8 -0
  28. data/lib/active_record/connection_adapters/db2_adapter.rb +1 -11
  29. data/lib/active_record/connection_adapters/firebird_adapter.rb +364 -50
  30. data/lib/active_record/connection_adapters/frontbase_adapter.rb +861 -0
  31. data/lib/active_record/connection_adapters/mysql_adapter.rb +86 -33
  32. data/lib/active_record/connection_adapters/openbase_adapter.rb +4 -3
  33. data/lib/active_record/connection_adapters/oracle_adapter.rb +151 -127
  34. data/lib/active_record/connection_adapters/postgresql_adapter.rb +125 -48
  35. data/lib/active_record/connection_adapters/sqlite_adapter.rb +38 -10
  36. data/lib/active_record/connection_adapters/sqlserver_adapter.rb +183 -155
  37. data/lib/active_record/connection_adapters/sybase_adapter.rb +190 -212
  38. data/lib/active_record/deprecated_associations.rb +24 -10
  39. data/lib/active_record/deprecated_finders.rb +4 -1
  40. data/lib/active_record/fixtures.rb +37 -23
  41. data/lib/active_record/locking/optimistic.rb +106 -0
  42. data/lib/active_record/locking/pessimistic.rb +77 -0
  43. data/lib/active_record/migration.rb +8 -5
  44. data/lib/active_record/observer.rb +73 -34
  45. data/lib/active_record/reflection.rb +21 -7
  46. data/lib/active_record/schema_dumper.rb +33 -5
  47. data/lib/active_record/timestamp.rb +23 -34
  48. data/lib/active_record/transactions.rb +37 -30
  49. data/lib/active_record/validations.rb +46 -30
  50. data/lib/active_record/vendor/mysql.rb +20 -5
  51. data/lib/active_record/version.rb +2 -2
  52. data/lib/active_record/wrappings.rb +1 -2
  53. data/lib/active_record/xml_serialization.rb +308 -0
  54. data/test/aaa_create_tables_test.rb +5 -1
  55. data/test/abstract_unit.rb +18 -8
  56. data/test/{active_schema_mysql.rb → active_schema_test_mysql.rb} +2 -2
  57. data/test/adapter_test.rb +9 -7
  58. data/test/adapter_test_sqlserver.rb +81 -0
  59. data/test/aggregations_test.rb +29 -0
  60. data/test/{association_callbacks_test.rb → associations/callbacks_test.rb} +10 -8
  61. data/test/{associations_cascaded_eager_loading_test.rb → associations/cascaded_eager_loading_test.rb} +35 -3
  62. data/test/{associations_go_eager_test.rb → associations/eager_test.rb} +36 -2
  63. data/test/{associations_extensions_test.rb → associations/extension_test.rb} +5 -0
  64. data/test/{associations_join_model_test.rb → associations/join_model_test.rb} +118 -8
  65. data/test/associations_test.rb +339 -45
  66. data/test/attribute_methods_test.rb +49 -0
  67. data/test/base_test.rb +321 -67
  68. data/test/calculations_test.rb +48 -10
  69. data/test/callbacks_test.rb +13 -0
  70. data/test/connection_test_firebird.rb +8 -0
  71. data/test/connections/native_db2/connection.rb +18 -17
  72. data/test/connections/native_firebird/connection.rb +19 -17
  73. data/test/connections/native_frontbase/connection.rb +27 -0
  74. data/test/connections/native_mysql/connection.rb +18 -15
  75. data/test/connections/native_openbase/connection.rb +14 -15
  76. data/test/connections/native_oracle/connection.rb +16 -12
  77. data/test/connections/native_postgresql/connection.rb +16 -17
  78. data/test/connections/native_sqlite/connection.rb +3 -6
  79. data/test/connections/native_sqlite3/connection.rb +3 -6
  80. data/test/connections/native_sqlserver/connection.rb +16 -17
  81. data/test/connections/native_sqlserver_odbc/connection.rb +18 -19
  82. data/test/connections/native_sybase/connection.rb +16 -17
  83. data/test/datatype_test_postgresql.rb +52 -0
  84. data/test/defaults_test.rb +52 -10
  85. data/test/deprecated_associations_test.rb +151 -107
  86. data/test/deprecated_finder_test.rb +83 -66
  87. data/test/empty_date_time_test.rb +25 -0
  88. data/test/finder_test.rb +118 -11
  89. data/test/fixtures/accounts.yml +6 -1
  90. data/test/fixtures/author.rb +27 -4
  91. data/test/fixtures/categorizations.yml +8 -2
  92. data/test/fixtures/category.rb +1 -2
  93. data/test/fixtures/comments.yml +0 -6
  94. data/test/fixtures/companies.yml +6 -1
  95. data/test/fixtures/company.rb +23 -1
  96. data/test/fixtures/company_in_module.rb +8 -10
  97. data/test/fixtures/customer.rb +2 -2
  98. data/test/fixtures/customers.yml +9 -0
  99. data/test/fixtures/db_definitions/db2.drop.sql +1 -0
  100. data/test/fixtures/db_definitions/db2.sql +9 -0
  101. data/test/fixtures/db_definitions/firebird.drop.sql +3 -0
  102. data/test/fixtures/db_definitions/firebird.sql +13 -1
  103. data/test/fixtures/db_definitions/frontbase.drop.sql +31 -0
  104. data/test/fixtures/db_definitions/frontbase.sql +262 -0
  105. data/test/fixtures/db_definitions/frontbase2.drop.sql +1 -0
  106. data/test/fixtures/db_definitions/frontbase2.sql +4 -0
  107. data/test/fixtures/db_definitions/mysql.drop.sql +1 -0
  108. data/test/fixtures/db_definitions/mysql.sql +23 -14
  109. data/test/fixtures/db_definitions/openbase.sql +13 -1
  110. data/test/fixtures/db_definitions/oracle.drop.sql +2 -0
  111. data/test/fixtures/db_definitions/oracle.sql +29 -2
  112. data/test/fixtures/db_definitions/postgresql.drop.sql +3 -1
  113. data/test/fixtures/db_definitions/postgresql.sql +13 -3
  114. data/test/fixtures/db_definitions/schema.rb +29 -1
  115. data/test/fixtures/db_definitions/sqlite.drop.sql +1 -0
  116. data/test/fixtures/db_definitions/sqlite.sql +12 -3
  117. data/test/fixtures/db_definitions/sqlserver.drop.sql +3 -0
  118. data/test/fixtures/db_definitions/sqlserver.sql +35 -0
  119. data/test/fixtures/db_definitions/sybase.drop.sql +2 -0
  120. data/test/fixtures/db_definitions/sybase.sql +13 -4
  121. data/test/fixtures/developer.rb +12 -0
  122. data/test/fixtures/edge.rb +5 -0
  123. data/test/fixtures/edges.yml +6 -0
  124. data/test/fixtures/funny_jokes.yml +3 -7
  125. data/test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb +15 -0
  126. data/test/fixtures/migrations_with_missing_versions/1000_people_have_middle_names.rb +9 -0
  127. data/test/fixtures/migrations_with_missing_versions/1_people_have_last_names.rb +9 -0
  128. data/test/fixtures/migrations_with_missing_versions/3_we_need_reminders.rb +12 -0
  129. data/test/fixtures/migrations_with_missing_versions/4_innocent_jointable.rb +12 -0
  130. data/test/fixtures/mixin.rb +15 -0
  131. data/test/fixtures/mixins.yml +38 -0
  132. data/test/fixtures/post.rb +3 -2
  133. data/test/fixtures/project.rb +3 -1
  134. data/test/fixtures/topic.rb +6 -1
  135. data/test/fixtures/topics.yml +4 -4
  136. data/test/fixtures/vertex.rb +9 -0
  137. data/test/fixtures/vertices.yml +4 -0
  138. data/test/fixtures_test.rb +45 -0
  139. data/test/inheritance_test.rb +67 -6
  140. data/test/lifecycle_test.rb +40 -19
  141. data/test/locking_test.rb +170 -26
  142. data/test/method_scoping_test.rb +2 -2
  143. data/test/migration_test.rb +387 -110
  144. data/test/migration_test_firebird.rb +124 -0
  145. data/test/mixin_nested_set_test.rb +14 -2
  146. data/test/mixin_test.rb +56 -18
  147. data/test/modules_test.rb +8 -2
  148. data/test/multiple_db_test.rb +2 -2
  149. data/test/pk_test.rb +1 -0
  150. data/test/reflection_test.rb +8 -2
  151. data/test/schema_authorization_test_postgresql.rb +75 -0
  152. data/test/schema_dumper_test.rb +40 -4
  153. data/test/table_name_test_sqlserver.rb +23 -0
  154. data/test/threaded_connections_test.rb +19 -16
  155. data/test/transactions_test.rb +86 -72
  156. data/test/validations_test.rb +126 -56
  157. data/test/xml_serialization_test.rb +125 -0
  158. metadata +45 -11
  159. data/lib/active_record/locking.rb +0 -79
@@ -0,0 +1,125 @@
1
+ require 'abstract_unit'
2
+ require 'fixtures/post'
3
+ require 'fixtures/author'
4
+
5
+ class Contact < ActiveRecord::Base
6
+ # mock out self.columns so no pesky db is needed for these tests
7
+ def self.columns() @columns ||= []; end
8
+ def self.column(name, sql_type = nil, default = nil, null = true)
9
+ columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
10
+ end
11
+
12
+ column :name, :string
13
+ column :age, :integer
14
+ column :avatar, :binary
15
+ column :created_at, :datetime
16
+ column :awesome, :boolean
17
+ end
18
+
19
+ class XmlSerializationTest < Test::Unit::TestCase
20
+ def test_should_serialize_default_root
21
+ @xml = Contact.new.to_xml
22
+ assert_match %r{^<contact>}, @xml
23
+ assert_match %r{</contact>$}, @xml
24
+ end
25
+
26
+ def test_should_serialize_default_root_with_namespace
27
+ @xml = Contact.new.to_xml :namespace=>"http://xml.rubyonrails.org/contact"
28
+ assert_match %r{^<contact xmlns="http://xml.rubyonrails.org/contact">}, @xml
29
+ assert_match %r{</contact>$}, @xml
30
+ end
31
+
32
+ def test_should_serialize_custom_root
33
+ @xml = Contact.new.to_xml :root => 'xml_contact'
34
+ assert_match %r{^<xml-contact>}, @xml
35
+ assert_match %r{</xml-contact>$}, @xml
36
+ end
37
+
38
+ def test_should_allow_undasherized_tags
39
+ @xml = Contact.new.to_xml :root => 'xml_contact', :dasherize => false
40
+ assert_match %r{^<xml_contact>}, @xml
41
+ assert_match %r{</xml_contact>$}, @xml
42
+ assert_match %r{<created_at}, @xml
43
+ end
44
+
45
+ def test_should_allow_attribute_filtering
46
+ @xml = Contact.new.to_xml :only => [:age, :name]
47
+ assert_match %r{<name}, @xml
48
+ assert_match %r{<age}, @xml
49
+ assert_no_match %r{<created-at}, @xml
50
+
51
+ @xml = Contact.new.to_xml :except => [:age, :name]
52
+ assert_no_match %r{<name}, @xml
53
+ assert_no_match %r{<age}, @xml
54
+ assert_match %r{<created-at}, @xml
55
+ end
56
+ end
57
+
58
+ class DefaultXmlSerializationTest < Test::Unit::TestCase
59
+ def setup
60
+ @xml = Contact.new(:name => 'aaron stack', :age => 25, :avatar => 'binarydata', :created_at => Time.utc(2006, 8, 1), :awesome => false).to_xml
61
+ end
62
+
63
+ def test_should_serialize_string
64
+ assert_match %r{<name>aaron stack</name>}, @xml
65
+ end
66
+
67
+ def test_should_serialize_integer
68
+ assert_match %r{<age type="integer">25</age>}, @xml
69
+ end
70
+
71
+ def test_should_serialize_binary
72
+ assert_match %r{YmluYXJ5ZGF0YQ==\n</avatar>}, @xml
73
+ assert_match %r{<avatar(.*)(type="binary")}, @xml
74
+ assert_match %r{<avatar(.*)(encoding="base64")}, @xml
75
+ end
76
+
77
+ def test_should_serialize_datetime
78
+ assert_match %r{<created-at type=\"datetime\">2006-08-01T00:00:00Z</created-at>}, @xml
79
+ end
80
+
81
+ def test_should_serialize_boolean
82
+ assert_match %r{<awesome type=\"boolean\">false</awesome>}, @xml
83
+ end
84
+ end
85
+
86
+ class NilXmlSerializationTest < Test::Unit::TestCase
87
+ def setup
88
+ @xml = Contact.new.to_xml(:root => 'xml_contact')
89
+ end
90
+
91
+ def test_should_serialize_string
92
+ assert_match %r{<name></name>}, @xml
93
+ end
94
+
95
+ def test_should_serialize_integer
96
+ assert_match %r{<age type="integer"></age>}, @xml
97
+ end
98
+
99
+ def test_should_serialize_binary
100
+ assert_match %r{></avatar>}, @xml
101
+ assert_match %r{<avatar(.*)(type="binary")}, @xml
102
+ assert_match %r{<avatar(.*)(encoding="base64")}, @xml
103
+ end
104
+
105
+ def test_should_serialize_datetime
106
+ assert_match %r{<created-at type=\"datetime\"></created-at>}, @xml
107
+ end
108
+
109
+ def test_should_serialize_boolean
110
+ assert_match %r{<awesome type=\"boolean\"></awesome>}, @xml
111
+ end
112
+ end
113
+
114
+ class DatabaseConnectedXmlSerializationTest < Test::Unit::TestCase
115
+ fixtures :authors, :posts
116
+ # to_xml used to mess with the hash the user provided which
117
+ # caused the builder to be reused
118
+ def test_passing_hash_shouldnt_reuse_builder
119
+ options = {:include=>:posts}
120
+ david = authors(:david)
121
+ first_xml_size = david.to_xml(options).size
122
+ second_xml_size = david.to_xml(options).size
123
+ assert_equal first_xml_size, second_xml_size
124
+ end
125
+ end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: activerecord
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.14.4
7
- date: 2006-08-09 00:00:00 -05:00
6
+ version: 1.15.0
7
+ date: 2007-01-18 00:00:00 -06:00
8
8
  summary: Implements the ActiveRecord pattern for ORM.
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - David Heinemeier Hansson
30
31
  files:
@@ -39,6 +40,7 @@ files:
39
40
  - lib/active_record/aggregations.rb
40
41
  - lib/active_record/associations
41
42
  - lib/active_record/associations.rb
43
+ - lib/active_record/attribute_methods.rb
42
44
  - lib/active_record/base.rb
43
45
  - lib/active_record/calculations.rb
44
46
  - lib/active_record/callbacks.rb
@@ -46,7 +48,7 @@ files:
46
48
  - lib/active_record/deprecated_associations.rb
47
49
  - lib/active_record/deprecated_finders.rb
48
50
  - lib/active_record/fixtures.rb
49
- - lib/active_record/locking.rb
51
+ - lib/active_record/locking
50
52
  - lib/active_record/migration.rb
51
53
  - lib/active_record/observer.rb
52
54
  - lib/active_record/query_cache.rb
@@ -60,6 +62,7 @@ files:
60
62
  - lib/active_record/version.rb
61
63
  - lib/active_record/wrappers
62
64
  - lib/active_record/wrappings.rb
65
+ - lib/active_record/xml_serialization.rb
63
66
  - lib/active_record/acts/list.rb
64
67
  - lib/active_record/acts/nested_set.rb
65
68
  - lib/active_record/acts/tree.rb
@@ -75,6 +78,7 @@ files:
75
78
  - lib/active_record/connection_adapters/abstract_adapter.rb
76
79
  - lib/active_record/connection_adapters/db2_adapter.rb
77
80
  - lib/active_record/connection_adapters/firebird_adapter.rb
81
+ - lib/active_record/connection_adapters/frontbase_adapter.rb
78
82
  - lib/active_record/connection_adapters/mysql_adapter.rb
79
83
  - lib/active_record/connection_adapters/openbase_adapter.rb
80
84
  - lib/active_record/connection_adapters/oracle_adapter.rb
@@ -83,40 +87,44 @@ files:
83
87
  - lib/active_record/connection_adapters/sqlserver_adapter.rb
84
88
  - lib/active_record/connection_adapters/sybase_adapter.rb
85
89
  - lib/active_record/connection_adapters/abstract/connection_specification.rb
90
+ - lib/active_record/connection_adapters/abstract/connection_specification.rb.rej
86
91
  - lib/active_record/connection_adapters/abstract/database_statements.rb
87
92
  - lib/active_record/connection_adapters/abstract/quoting.rb
88
93
  - lib/active_record/connection_adapters/abstract/schema_definitions.rb
89
94
  - lib/active_record/connection_adapters/abstract/schema_statements.rb
95
+ - lib/active_record/locking/optimistic.rb
96
+ - lib/active_record/locking/pessimistic.rb
90
97
  - lib/active_record/vendor/db2.rb
91
98
  - lib/active_record/vendor/mysql.rb
92
99
  - lib/active_record/vendor/simple.rb
93
100
  - lib/active_record/wrappers/yaml_wrapper.rb
94
101
  - test/aaa_create_tables_test.rb
95
102
  - test/abstract_unit.rb
96
- - test/active_schema_mysql.rb
103
+ - test/active_schema_test_mysql.rb
97
104
  - test/adapter_test.rb
105
+ - test/adapter_test_sqlserver.rb
98
106
  - test/aggregations_test.rb
99
107
  - test/all.sh
100
108
  - test/ar_schema_test.rb
101
- - test/association_callbacks_test.rb
102
109
  - test/association_inheritance_reload.rb
103
- - test/associations_cascaded_eager_loading_test.rb
104
- - test/associations_extensions_test.rb
105
- - test/associations_go_eager_test.rb
106
- - test/associations_join_model_test.rb
110
+ - test/associations
107
111
  - test/associations_test.rb
112
+ - test/attribute_methods_test.rb
108
113
  - test/base_test.rb
109
114
  - test/binary_test.rb
110
115
  - test/calculations_test.rb
111
116
  - test/callbacks_test.rb
112
117
  - test/class_inheritable_attributes_test.rb
113
118
  - test/column_alias_test.rb
119
+ - test/connection_test_firebird.rb
114
120
  - test/connections
115
121
  - test/copy_table_sqlite.rb
122
+ - test/datatype_test_postgresql.rb
116
123
  - test/default_test_firebird.rb
117
124
  - test/defaults_test.rb
118
125
  - test/deprecated_associations_test.rb
119
126
  - test/deprecated_finder_test.rb
127
+ - test/empty_date_time_test.rb
120
128
  - test/finder_test.rb
121
129
  - test/fixtures
122
130
  - test/fixtures_test.rb
@@ -125,6 +133,7 @@ files:
125
133
  - test/locking_test.rb
126
134
  - test/method_scoping_test.rb
127
135
  - test/migration_test.rb
136
+ - test/migration_test_firebird.rb
128
137
  - test/mixin_nested_set_test.rb
129
138
  - test/mixin_test.rb
130
139
  - test/modules_test.rb
@@ -132,15 +141,24 @@ files:
132
141
  - test/pk_test.rb
133
142
  - test/readonly_test.rb
134
143
  - test/reflection_test.rb
144
+ - test/schema_authorization_test_postgresql.rb
135
145
  - test/schema_dumper_test.rb
136
146
  - test/schema_test_postgresql.rb
137
147
  - test/synonym_test_oracle.rb
148
+ - test/table_name_test_sqlserver.rb
138
149
  - test/threaded_connections_test.rb
139
150
  - test/transactions_test.rb
140
151
  - test/unconnected_test.rb
141
152
  - test/validations_test.rb
153
+ - test/xml_serialization_test.rb
154
+ - test/associations/callbacks_test.rb
155
+ - test/associations/cascaded_eager_loading_test.rb
156
+ - test/associations/eager_test.rb
157
+ - test/associations/extension_test.rb
158
+ - test/associations/join_model_test.rb
142
159
  - test/connections/native_db2
143
160
  - test/connections/native_firebird
161
+ - test/connections/native_frontbase
144
162
  - test/connections/native_mysql
145
163
  - test/connections/native_openbase
146
164
  - test/connections/native_oracle
@@ -152,6 +170,7 @@ files:
152
170
  - test/connections/native_sybase
153
171
  - test/connections/native_db2/connection.rb
154
172
  - test/connections/native_firebird/connection.rb
173
+ - test/connections/native_frontbase/connection.rb
155
174
  - test/connections/native_mysql/connection.rb
156
175
  - test/connections/native_openbase/connection.rb
157
176
  - test/connections/native_oracle/connection.rb
@@ -194,6 +213,8 @@ files:
194
213
  - test/fixtures/developers.yml
195
214
  - test/fixtures/developers_projects
196
215
  - test/fixtures/developers_projects.yml
216
+ - test/fixtures/edge.rb
217
+ - test/fixtures/edges.yml
197
218
  - test/fixtures/entrant.rb
198
219
  - test/fixtures/entrants.yml
199
220
  - test/fixtures/fk_test_has_fk.yml
@@ -205,7 +226,9 @@ files:
205
226
  - test/fixtures/legacy_thing.rb
206
227
  - test/fixtures/legacy_things.yml
207
228
  - test/fixtures/migrations
229
+ - test/fixtures/migrations_with_decimal
208
230
  - test/fixtures/migrations_with_duplicate
231
+ - test/fixtures/migrations_with_missing_versions
209
232
  - test/fixtures/mixin.rb
210
233
  - test/fixtures/mixins.yml
211
234
  - test/fixtures/movie.rb
@@ -232,6 +255,8 @@ files:
232
255
  - test/fixtures/tasks.yml
233
256
  - test/fixtures/topic.rb
234
257
  - test/fixtures/topics.yml
258
+ - test/fixtures/vertex.rb
259
+ - test/fixtures/vertices.yml
235
260
  - test/fixtures/bad_fixtures/attr_with_numeric_first_char
236
261
  - test/fixtures/bad_fixtures/attr_with_spaces
237
262
  - test/fixtures/bad_fixtures/blank_line
@@ -248,6 +273,10 @@ files:
248
273
  - test/fixtures/db_definitions/firebird.sql
249
274
  - test/fixtures/db_definitions/firebird2.drop.sql
250
275
  - test/fixtures/db_definitions/firebird2.sql
276
+ - test/fixtures/db_definitions/frontbase.drop.sql
277
+ - test/fixtures/db_definitions/frontbase.sql
278
+ - test/fixtures/db_definitions/frontbase2.drop.sql
279
+ - test/fixtures/db_definitions/frontbase2.sql
251
280
  - test/fixtures/db_definitions/mysql.drop.sql
252
281
  - test/fixtures/db_definitions/mysql.sql
253
282
  - test/fixtures/db_definitions/mysql2.drop.sql
@@ -283,10 +312,15 @@ files:
283
312
  - test/fixtures/migrations/1_people_have_last_names.rb
284
313
  - test/fixtures/migrations/2_we_need_reminders.rb
285
314
  - test/fixtures/migrations/3_innocent_jointable.rb
315
+ - test/fixtures/migrations_with_decimal/1_give_me_big_numbers.rb
286
316
  - test/fixtures/migrations_with_duplicate/1_people_have_last_names.rb
287
317
  - test/fixtures/migrations_with_duplicate/2_we_need_reminders.rb
288
318
  - test/fixtures/migrations_with_duplicate/3_foo.rb
289
319
  - test/fixtures/migrations_with_duplicate/3_innocent_jointable.rb
320
+ - test/fixtures/migrations_with_missing_versions/1000_people_have_middle_names.rb
321
+ - test/fixtures/migrations_with_missing_versions/1_people_have_last_names.rb
322
+ - test/fixtures/migrations_with_missing_versions/3_we_need_reminders.rb
323
+ - test/fixtures/migrations_with_missing_versions/4_innocent_jointable.rb
290
324
  - test/fixtures/naked/csv
291
325
  - test/fixtures/naked/yml
292
326
  - test/fixtures/naked/csv/accounts.csv
@@ -320,5 +354,5 @@ dependencies:
320
354
  requirements:
321
355
  - - "="
322
356
  - !ruby/object:Gem::Version
323
- version: 1.3.1
357
+ version: 1.4.0
324
358
  version:
@@ -1,79 +0,0 @@
1
- module ActiveRecord
2
- # Active Records support optimistic locking if the field <tt>lock_version</tt> is present. Each update to the
3
- # record increments the lock_version column and the locking facilities ensure that records instantiated twice
4
- # will let the last one saved raise a StaleObjectError if the first was also updated. Example:
5
- #
6
- # p1 = Person.find(1)
7
- # p2 = Person.find(1)
8
- #
9
- # p1.first_name = "Michael"
10
- # p1.save
11
- #
12
- # p2.first_name = "should fail"
13
- # p2.save # Raises a ActiveRecord::StaleObjectError
14
- #
15
- # You're then responsible for dealing with the conflict by rescuing the exception and either rolling back, merging,
16
- # or otherwise apply the business logic needed to resolve the conflict.
17
- #
18
- # You must ensure that your database schema defaults the lock_version column to 0.
19
- #
20
- # This behavior can be turned off by setting <tt>ActiveRecord::Base.lock_optimistically = false</tt>.
21
- # To override the name of the lock_version column, invoke the <tt>set_locking_column</tt> method.
22
- # This method uses the same syntax as <tt>set_table_name</tt>
23
- module Locking
24
- def self.append_features(base) #:nodoc:
25
- super
26
- base.class_eval do
27
- alias_method :update_without_lock, :update
28
- alias_method :update, :update_with_lock
29
- end
30
- end
31
-
32
- def update_with_lock #:nodoc:
33
- return update_without_lock unless locking_enabled?
34
-
35
- lock_col = self.class.locking_column
36
- previous_value = send(lock_col)
37
- send(lock_col + '=', previous_value + 1)
38
-
39
- affected_rows = connection.update(<<-end_sql, "#{self.class.name} Update with optimistic locking")
40
- UPDATE #{self.class.table_name}
41
- SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))}
42
- WHERE #{self.class.primary_key} = #{quote(id)}
43
- AND #{lock_col} = #{quote(previous_value)}
44
- end_sql
45
-
46
- unless affected_rows == 1
47
- raise ActiveRecord::StaleObjectError, "Attempted to update a stale object"
48
- end
49
-
50
- return true
51
- end
52
- end
53
-
54
- class Base
55
- @@lock_optimistically = true
56
- cattr_accessor :lock_optimistically
57
-
58
- def locking_enabled? #:nodoc:
59
- lock_optimistically && respond_to?(self.class.locking_column)
60
- end
61
-
62
- class << self
63
- def set_locking_column(value = nil, &block)
64
- define_attr_method :locking_column, value, &block
65
- end
66
-
67
- def locking_column #:nodoc:
68
- reset_locking_column
69
- end
70
-
71
- def reset_locking_column #:nodoc:
72
- default = 'lock_version'
73
- set_locking_column(default)
74
- default
75
- end
76
- end
77
-
78
- end
79
- end