Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
6464683c
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
6464683c
编写于
12月 13, 2017
作者:
R
Rafael França
提交者:
GitHub
12月 13, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #31435 from yahonda/deprecated_bigdecimal_new
Suppress `warning: BigDecimal.new is deprecated` in activerecord
上级
92426751
6c6c3fa1
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
24 addition
and
24 deletion
+24
-24
activerecord/lib/active_record/attributes.rb
activerecord/lib/active_record/attributes.rb
+1
-1
activerecord/lib/active_record/connection_adapters/postgresql/oid/decimal.rb
...tive_record/connection_adapters/postgresql/oid/decimal.rb
+1
-1
activerecord/test/cases/adapters/postgresql/domain_test.rb
activerecord/test/cases/adapters/postgresql/domain_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/money_test.rb
activerecord/test/cases/adapters/postgresql/money_test.rb
+3
-3
activerecord/test/cases/adapters/postgresql/range_test.rb
activerecord/test/cases/adapters/postgresql/range_test.rb
+7
-7
activerecord/test/cases/adapters/postgresql/schema_test.rb
activerecord/test/cases/adapters/postgresql/schema_test.rb
+1
-1
activerecord/test/cases/adapters/sqlite3/quoting_test.rb
activerecord/test/cases/adapters/sqlite3/quoting_test.rb
+1
-1
activerecord/test/cases/attributes_test.rb
activerecord/test/cases/attributes_test.rb
+1
-1
activerecord/test/cases/defaults_test.rb
activerecord/test/cases/defaults_test.rb
+1
-1
activerecord/test/cases/migration/column_attributes_test.rb
activerecord/test/cases/migration/column_attributes_test.rb
+3
-3
activerecord/test/cases/quoting_test.rb
activerecord/test/cases/quoting_test.rb
+1
-1
activerecord/test/cases/relation/where_test.rb
activerecord/test/cases/relation/where_test.rb
+1
-1
activerecord/test/cases/validations_test.rb
activerecord/test/cases/validations_test.rb
+2
-2
未找到文件。
activerecord/lib/active_record/attributes.rb
浏览文件 @
6464683c
...
...
@@ -57,7 +57,7 @@ module ClassMethods
# store_listing = StoreListing.new(price_in_cents: '10.1')
#
# # before
# store_listing.price_in_cents # => BigDecimal
.new
(10.1)
# store_listing.price_in_cents # => BigDecimal(10.1)
#
# class StoreListing < ActiveRecord::Base
# attribute :price_in_cents, :integer
...
...
activerecord/lib/active_record/connection_adapters/postgresql/oid/decimal.rb
浏览文件 @
6464683c
...
...
@@ -6,7 +6,7 @@ module PostgreSQL
module
OID
# :nodoc:
class
Decimal
<
Type
::
Decimal
# :nodoc:
def
infinity
(
options
=
{})
BigDecimal
.
new
(
"Infinity"
)
*
(
options
[
:negative
]
?
-
1
:
1
)
BigDecimal
(
"Infinity"
)
*
(
options
[
:negative
]
?
-
1
:
1
)
end
end
end
...
...
activerecord/test/cases/adapters/postgresql/domain_test.rb
浏览文件 @
6464683c
...
...
@@ -44,6 +44,6 @@ def test_domain_acts_like_basetype
record
.
price
=
"34.15"
record
.
save!
assert_equal
BigDecimal
.
new
(
"34.15"
),
record
.
reload
.
price
assert_equal
BigDecimal
(
"34.15"
),
record
.
reload
.
price
end
end
activerecord/test/cases/adapters/postgresql/money_test.rb
浏览文件 @
6464683c
...
...
@@ -33,8 +33,8 @@ def test_column
end
def
test_default
assert_equal
BigDecimal
.
new
(
"150.55"
),
PostgresqlMoney
.
column_defaults
[
"depth"
]
assert_equal
BigDecimal
.
new
(
"150.55"
),
PostgresqlMoney
.
new
.
depth
assert_equal
BigDecimal
(
"150.55"
),
PostgresqlMoney
.
column_defaults
[
"depth"
]
assert_equal
BigDecimal
(
"150.55"
),
PostgresqlMoney
.
new
.
depth
end
def
test_money_values
...
...
@@ -65,7 +65,7 @@ def test_create_and_update_money
money
=
PostgresqlMoney
.
create
(
wealth:
"987.65"
.
dup
)
assert_equal
987.65
,
money
.
wealth
new_value
=
BigDecimal
.
new
(
"123.45"
)
new_value
=
BigDecimal
(
"123.45"
)
money
.
wealth
=
new_value
money
.
save!
money
.
reload
...
...
activerecord/test/cases/adapters/postgresql/range_test.rb
浏览文件 @
6464683c
...
...
@@ -134,10 +134,10 @@ def test_daterange_values
end
def
test_numrange_values
assert_equal
BigDecimal
.
new
(
"0.1"
)
..
BigDecimal
.
new
(
"0.2"
),
@first_range
.
num_range
assert_equal
BigDecimal
.
new
(
"0.1"
)
...
BigDecimal
.
new
(
"0.2"
),
@second_range
.
num_range
assert_equal
BigDecimal
.
new
(
"0.1"
)
...
BigDecimal
.
new
(
"Infinity"
),
@third_range
.
num_range
assert_equal
BigDecimal
.
new
(
"-Infinity"
)
...
BigDecimal
.
new
(
"Infinity"
),
@fourth_range
.
num_range
assert_equal
BigDecimal
(
"0.1"
)
..
BigDecimal
(
"0.2"
),
@first_range
.
num_range
assert_equal
BigDecimal
(
"0.1"
)
...
BigDecimal
(
"0.2"
),
@second_range
.
num_range
assert_equal
BigDecimal
(
"0.1"
)
...
BigDecimal
(
"Infinity"
),
@third_range
.
num_range
assert_equal
BigDecimal
(
"-Infinity"
)
...
BigDecimal
(
"Infinity"
),
@fourth_range
.
num_range
assert_nil
@empty_range
.
num_range
end
...
...
@@ -285,14 +285,14 @@ def test_timezone_awareness_tsrange_preserve_usec
def
test_create_numrange
assert_equal_round_trip
(
@new_range
,
:num_range
,
BigDecimal
.
new
(
"0.5"
)
...
BigDecimal
.
new
(
"1"
))
BigDecimal
(
"0.5"
)
...
BigDecimal
(
"1"
))
end
def
test_update_numrange
assert_equal_round_trip
(
@first_range
,
:num_range
,
BigDecimal
.
new
(
"0.5"
)
...
BigDecimal
.
new
(
"1"
))
BigDecimal
(
"0.5"
)
...
BigDecimal
(
"1"
))
assert_nil_round_trip
(
@first_range
,
:num_range
,
BigDecimal
.
new
(
"0.5"
)
...
BigDecimal
.
new
(
"0.5"
))
BigDecimal
(
"0.5"
)
...
BigDecimal
(
"0.5"
))
end
def
test_create_daterange
...
...
activerecord/test/cases/adapters/postgresql/schema_test.rb
浏览文件 @
6464683c
...
...
@@ -566,7 +566,7 @@ def test_string_defaults_in_new_schema_when_overriding_domain
end
def
test_decimal_defaults_in_new_schema_when_overriding_domain
assert_equal
BigDecimal
.
new
(
"3.14159265358979323846"
),
Default
.
new
.
decimal_col
,
"Default of decimal column was not correctly parsed"
assert_equal
BigDecimal
(
"3.14159265358979323846"
),
Default
.
new
.
decimal_col
,
"Default of decimal column was not correctly parsed"
end
def
test_bpchar_defaults_in_new_schema_when_overriding_domain
...
...
activerecord/test/cases/adapters/sqlite3/quoting_test.rb
浏览文件 @
6464683c
...
...
@@ -38,7 +38,7 @@ def test_type_cast_false
end
def
test_type_cast_bigdecimal
bd
=
BigDecimal
.
new
"10.0"
bd
=
BigDecimal
"10.0"
assert_equal
bd
.
to_f
,
@conn
.
type_cast
(
bd
)
end
...
...
activerecord/test/cases/attributes_test.rb
浏览文件 @
6464683c
...
...
@@ -59,7 +59,7 @@ class CustomPropertiesTest < ActiveRecord::TestCase
test
"nonexistent attribute"
do
data
=
OverloadedType
.
new
(
non_existent_decimal:
1
)
assert_equal
BigDecimal
.
new
(
1
),
data
.
non_existent_decimal
assert_equal
BigDecimal
(
1
),
data
.
non_existent_decimal
assert_raise
ActiveRecord
::
UnknownAttributeError
do
UnoverloadedType
.
new
(
non_existent_decimal:
1
)
end
...
...
activerecord/test/cases/defaults_test.rb
浏览文件 @
6464683c
...
...
@@ -53,7 +53,7 @@ def test_default_negative_integer
def
test_default_decimal_number
record
=
DefaultNumber
.
new
assert_equal
BigDecimal
.
new
(
"2.78"
),
record
.
decimal_number
assert_equal
BigDecimal
(
"2.78"
),
record
.
decimal_number
assert_equal
"2.78"
,
record
.
decimal_number_before_type_cast
end
end
...
...
activerecord/test/cases/migration/column_attributes_test.rb
浏览文件 @
6464683c
...
...
@@ -80,7 +80,7 @@ def test_native_decimal_insert_manual_vs_automatic
TestModel
.
delete_all
# Now use the Rails insertion
TestModel
.
create
wealth:
BigDecimal
.
new
(
"12345678901234567890.0123456789"
)
TestModel
.
create
wealth:
BigDecimal
(
"12345678901234567890.0123456789"
)
# SELECT
row
=
TestModel
.
first
...
...
@@ -146,7 +146,7 @@ def test_native_types
TestModel
.
create
first_name:
"bob"
,
last_name:
"bobsen"
,
bio:
"I was born ...."
,
age:
18
,
height:
1.78
,
wealth:
BigDecimal
.
new
(
"12345678901234567890.0123456789"
),
wealth:
BigDecimal
(
"12345678901234567890.0123456789"
),
birthday:
18
.
years
.
ago
,
favorite_day:
10
.
days
.
ago
,
moment_of_truth:
"1782-10-10 21:40:18"
,
male:
true
...
...
@@ -159,7 +159,7 @@ def test_native_types
# Test for 30 significant digits (beyond the 16 of float), 10 of them
# after the decimal place.
assert_equal
BigDecimal
.
new
(
"0012345678901234567890.0123456789"
),
bob
.
wealth
assert_equal
BigDecimal
(
"0012345678901234567890.0123456789"
),
bob
.
wealth
assert_equal
true
,
bob
.
male?
...
...
activerecord/test/cases/quoting_test.rb
浏览文件 @
6464683c
...
...
@@ -111,7 +111,7 @@ def test_quote_bignum
end
def
test_quote_bigdecimal
bigdec
=
BigDecimal
.
new
((
1
<<
100
).
to_s
)
bigdec
=
BigDecimal
((
1
<<
100
).
to_s
)
assert_equal
bigdec
.
to_s
(
"F"
),
@quoter
.
quote
(
bigdec
)
end
...
...
activerecord/test/cases/relation/where_test.rb
浏览文件 @
6464683c
...
...
@@ -265,7 +265,7 @@ def test_where_with_boolean_for_string_column
end
def
test_where_with_decimal_for_string_column
count
=
Post
.
where
(
title:
BigDecimal
.
new
(
0
)).
count
count
=
Post
.
where
(
title:
BigDecimal
(
0
)).
count
assert_equal
0
,
count
end
...
...
activerecord/test/cases/validations_test.rb
浏览文件 @
6464683c
...
...
@@ -175,12 +175,12 @@ def self.model_name
ActiveModel
::
Name
.
new
(
self
,
nil
,
"Topic"
)
end
attribute
:wibble
,
:decimal
,
scale:
2
,
precision:
9
validates_numericality_of
:wibble
,
greater_than_or_equal_to:
BigDecimal
.
new
(
"97.18"
)
validates_numericality_of
:wibble
,
greater_than_or_equal_to:
BigDecimal
(
"97.18"
)
end
assert_not
klass
.
new
(
wibble:
"97.179"
).
valid?
assert_not
klass
.
new
(
wibble:
97.179
).
valid?
assert_not
klass
.
new
(
wibble:
BigDecimal
.
new
(
"97.179"
)).
valid?
assert_not
klass
.
new
(
wibble:
BigDecimal
(
"97.179"
)).
valid?
end
def
test_acceptance_validator_doesnt_require_db_connection
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录