From 3e5a8809873526c5761c1a0d7df6535602fd3f61 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 20 Dec 2004 13:32:09 +0000 Subject: [PATCH] Switched strategy on the id_before_type_cast problem and just did an explicit method so postgresql wouldnt choke on id is null git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@234 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/base.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 8f011947b357a..a7347c4af524a 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -734,6 +734,10 @@ def id read_attribute(self.class.primary_key) end + def id_before_type_cast + read_attribute_before_type_cast(self.class.primary_key) + end + def quoted_id quote(id, self.class.columns_hash[self.class.primary_key]) end @@ -1047,7 +1051,7 @@ def interpolate_sql(sql, record = nil) # that instances loaded from the database would. def attributes_from_column_definition connection.columns(self.class.table_name, "#{self.class.name} Columns").inject({}) do |attributes, column| - attributes[column.name] = (column.default unless column.name == self.class.primary_key) + attributes[column.name] = column.default unless column.name == self.class.primary_key attributes end end