mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
PostgreSQL: correctly parse negative integer column defaults. References #3776.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3554 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* PostgreSQL: correctly parse negative integer column defaults. #3776 [bellis@deepthought.org]
|
||||
|
||||
* Fix problems with count when used with :include [Jeremy Hopple and Kevin Clark]
|
||||
|
||||
* ActiveRecord::RecordInvalid now states which validations failed in its default error message [Tobias Luetke]
|
||||
|
||||
@@ -468,7 +468,7 @@ module ActiveRecord
|
||||
return $1 if value =~ /^'(.*)'::(bpchar|text|character varying)$/
|
||||
|
||||
# Numeric values
|
||||
return value if value =~ /^[0-9]+(\.[0-9]*)?/
|
||||
return value if value =~ /^-?[0-9]+(\.[0-9]*)?/
|
||||
|
||||
# Date / Time magic values
|
||||
return Time.now.to_s if value =~ /^now\(\)|^\('now'::text\)::(date|timestamp)/i
|
||||
|
||||
14
activerecord/test/defaults_test.rb
Normal file
14
activerecord/test/defaults_test.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
require 'abstract_unit'
|
||||
require 'fixtures/default'
|
||||
|
||||
class DefaultsTest < Test::Unit::TestCase
|
||||
if %w(PostgreSQL).include? ActiveRecord::Base.connection.adapter_name
|
||||
def test_default_integers
|
||||
default = Default.new
|
||||
assert_instance_of(Fixnum, default.positive_integer)
|
||||
assert_equal(default.positive_integer, 1)
|
||||
assert_instance_of(Fixnum, default.negative_integer)
|
||||
assert_equal(default.negative_integer, -1)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -111,7 +111,9 @@ CREATE TABLE defaults (
|
||||
fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
|
||||
char1 char(1) default 'Y',
|
||||
char2 character varying(50) default 'a varchar field',
|
||||
char3 text default 'a text field'
|
||||
char3 text default 'a text field',
|
||||
positive_integer integer default 1,
|
||||
negative_integer integer default -1
|
||||
);
|
||||
|
||||
CREATE TABLE auto_id_tests (
|
||||
|
||||
Reference in New Issue
Block a user