activerecord 1.14.3 → 1.14.4

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 CHANGED
@@ -1,5 +1,18 @@
1
+ *1.14.4* (August 8th, 2006)
2
+
3
+ * Add warning about the proper way to validate the presence of a foreign key. #4147 [Francois Beausoleil <francois.beausoleil@gmail.com>]
4
+
5
+ * Fix syntax error in documentation. #4679 [mislav@nippur.irb.hr]
6
+
7
+ * Update inconsistent migrations documentation. #4683 [machomagna@gmail.com]
8
+
9
+
1
10
  *1.14.3* (June 27th, 2006)
2
11
 
12
+ * Fix announcement of very long migration names. #5722 [blake@near-time.com]
13
+
14
+ * Update callbacks documentation. #3970 [Robby Russell <robby@planetargon.com>]
15
+
3
16
  * Properly quote index names in migrations (closes #4764) [John Long]
4
17
 
5
18
  * Ensure that Associations#include_eager_conditions? checks both scoped and explicit conditions [Rick]
@@ -175,7 +175,7 @@ module ActiveRecord #:nodoc:
175
175
  # serialize :preferences
176
176
  # end
177
177
  #
178
- # user = User.create(:preferences) => { "background" => "black", "display" => large })
178
+ # user = User.create(:preferences => { "background" => "black", "display" => large })
179
179
  # User.find(user.id).preferences # => { "background" => "black", "display" => large }
180
180
  #
181
181
  # You can also specify a class option as the second parameter that'll raise an exception if a serialized object is retrieved as a
@@ -243,6 +243,10 @@ module ActiveRecord
243
243
  def before_save() end
244
244
 
245
245
  # Is called _after_ Base.save (regardless of whether it's a create or update save).
246
+ #
247
+ # class Contact < ActiveRecord::Base
248
+ # after_save { logger.info( 'New contact saved!' ) }
249
+ # end
246
250
  def after_save() end
247
251
  def create_or_update_with_callbacks #:nodoc:
248
252
  return false if callback(:before_save) == false
@@ -312,9 +316,16 @@ module ActiveRecord
312
316
  end
313
317
 
314
318
  # Is called _before_ Base.destroy.
319
+ #
320
+ # Note: If you need to _destroy_ or _nullify_ associated records first,
321
+ # use the _:dependent_ option on your associations.
315
322
  def before_destroy() end
316
323
 
317
324
  # Is called _after_ Base.destroy (and all the attributes have been frozen).
325
+ #
326
+ # class Contact < ActiveRecord::Base
327
+ # after_destroy { |record| logger.info( "Contact #{record.id} was destroyed." ) }
328
+ # end
318
329
  def after_destroy() end
319
330
  def destroy_with_callbacks #:nodoc:
320
331
  return false if callback(:before_destroy) == false
@@ -70,8 +70,8 @@ module ActiveRecord
70
70
  # * <tt>change_column(table_name, column_name, type, options)</tt>: Changes the column to a different type using the same
71
71
  # parameters as add_column.
72
72
  # * <tt>remove_column(table_name, column_name)</tt>: Removes the column named +column_name+ from the table called +table_name+.
73
- # * <tt>add_index(table_name, column_name, index_type)</tt>: Add a new index with the name of the column on the column. Specify an optional index_type (e.g. UNIQUE).
74
- # * <tt>remove_index(table_name, column_name)</tt>: Remove the index called the same as the column.
73
+ # * <tt>add_index(table_name, column_names, index_type, index_name)</tt>: Add a new index with the name of the column, or +index_name+ (if specified) on the column(s). Specify an optional +index_type+ (e.g. UNIQUE).
74
+ # * <tt>remove_index(table_name, index_name)</tt>: Remove the index specified by +index_name+.
75
75
  #
76
76
  # == Irreversible transformations
77
77
  #
@@ -243,7 +243,8 @@ module ActiveRecord
243
243
 
244
244
  def announce(message)
245
245
  text = "#{name}: #{message}"
246
- write "== %s %s" % [ text, "=" * (75 - text.length) ]
246
+ length = [0, 75 - text.length].max
247
+ write "== %s %s" % [text, "=" * length]
247
248
  end
248
249
 
249
250
  def say(message, subitem=false)
@@ -381,6 +381,18 @@ module ActiveRecord
381
381
  # * <tt>if</tt> - Specifies a method, proc or string to call to determine if the validation should
382
382
  # occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }). The
383
383
  # method, proc or string should return or evaluate to a true or false value.
384
+ #
385
+ # === Warning
386
+ # Validate the presence of the foreign key, not the instance variable itself.
387
+ # Do this:
388
+ # validate_presence_of :invoice_id
389
+ #
390
+ # Not this:
391
+ # validate_presence_of :invoice
392
+ #
393
+ # If you validate the presence of the associated object, you will get
394
+ # failures on saves when both the parent object and the child object are
395
+ # new.
384
396
  def validates_presence_of(*attr_names)
385
397
  configuration = { :message => ActiveRecord::Errors.default_error_messages[:blank], :on => :save }
386
398
  configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
@@ -2,7 +2,7 @@ module ActiveRecord
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 14
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -922,6 +922,16 @@ class BasicsTest < Test::Unit::TestCase
922
922
  assert_equal("<baz>", inverted["quux"])
923
923
  end
924
924
 
925
+ def test_sql_injection_via_find
926
+ assert_raises(ActiveRecord::RecordNotFound) do
927
+ Topic.find("123456 OR id > 0")
928
+ end
929
+
930
+ assert_raises(ActiveRecord::RecordNotFound) do
931
+ Topic.find(";;; this should raise an RecordNotFound error")
932
+ end
933
+ end
934
+
925
935
  def test_column_name_properly_quoted
926
936
  col_record = ColumnName.new
927
937
  col_record.references = 40
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: activerecord
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.14.3
7
- date: 2006-06-27 00:00:00 -05:00
6
+ version: 1.14.4
7
+ date: 2006-08-09 00:00:00 -05:00
8
8
  summary: Implements the ActiveRecord pattern for ORM.
9
9
  require_paths:
10
10
  - lib