Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
52434e9a
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,发现更多精彩内容 >>
提交
52434e9a
编写于
5月 27, 2014
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15295 from sgrif/sg-deprecate-decimals
Deprecate decimal columns being automatically treated as integers
上级
3067aee9
6b46106d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
29 addition
and
2 deletion
+29
-2
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
...lib/active_record/connection_adapters/abstract_adapter.rb
+1
-0
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+2
-0
activerecord/lib/active_record/properties.rb
activerecord/lib/active_record/properties.rb
+13
-1
activerecord/test/cases/base_test.rb
activerecord/test/cases/base_test.rb
+4
-0
activerecord/test/cases/calculations_test.rb
activerecord/test/cases/calculations_test.rb
+4
-0
activerecord/test/cases/helper.rb
activerecord/test/cases/helper.rb
+1
-0
activerecord/test/cases/migration_test.rb
activerecord/test/cases/migration_test.rb
+4
-1
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
浏览文件 @
52434e9a
...
...
@@ -396,6 +396,7 @@ def initialize_type_map(m) # :nodoc:
precision
=
extract_precision
(
sql_type
)
if
scale
==
0
# FIXME: Remove this class as well
Type
::
DecimalWithoutScale
.
new
(
precision:
precision
)
else
Type
::
Decimal
.
new
(
precision:
precision
,
scale:
scale
)
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
52434e9a
...
...
@@ -478,6 +478,8 @@ def initialize_type_map(m) # :nodoc:
# places after decimal = fmod - 4 & 0xffff
# places before decimal = (fmod - 4) >> 16 & 0xffff
if
fmod
&&
(
fmod
-
4
&
0xffff
).
zero?
# FIXME: Remove this class, and the second argument to
# lookups on PG
Type
::
DecimalWithoutScale
.
new
(
precision:
precision
)
else
OID
::
Decimal
.
new
(
precision:
precision
,
scale:
scale
)
...
...
activerecord/lib/active_record/properties.rb
浏览文件 @
52434e9a
...
...
@@ -64,7 +64,19 @@ def property(name, cast_type)
# Returns an array of column objects for the table associated with this class.
def
columns
@columns
||=
add_user_provided_columns
(
connection
.
schema_cache
.
columns
(
table_name
))
@columns
||=
add_user_provided_columns
(
connection
.
schema_cache
.
columns
(
table_name
)).
each
do
|
column
|
if
Type
::
DecimalWithoutScale
===
column
.
cast_type
ActiveSupport
::
Deprecation
.
warn
<<-
MESSAGE
.
strip_heredoc
Decimal columns with 0 scale being automatically treated as integers
is deprecated, and will be removed in a future version of Rails. If
you'd like to keep this behavior, add
property :
#{
column
.
name
}
, Type::Integer.new
to your
#{
name
}
model.
MESSAGE
end
end
end
# Returns a hash of column objects for the table associated with this class.
...
...
activerecord/test/cases/base_test.rb
浏览文件 @
52434e9a
...
...
@@ -984,6 +984,10 @@ def test_geometric_content
class
NumericData
<
ActiveRecord
::
Base
self
.
table_name
=
'numeric_data'
property
:world_population
,
Type
::
Integer
.
new
property
:my_house_population
,
Type
::
Integer
.
new
property
:atoms_in_universe
,
Type
::
Integer
.
new
end
def
test_big_decimal_conditions
...
...
activerecord/test/cases/calculations_test.rb
浏览文件 @
52434e9a
...
...
@@ -15,6 +15,10 @@
class
NumericData
<
ActiveRecord
::
Base
self
.
table_name
=
'numeric_data'
property
:world_population
,
Type
::
Integer
.
new
property
:my_house_population
,
Type
::
Integer
.
new
property
:atoms_in_universe
,
Type
::
Integer
.
new
end
class
CalculationsTest
<
ActiveRecord
::
TestCase
...
...
activerecord/test/cases/helper.rb
浏览文件 @
52434e9a
...
...
@@ -9,6 +9,7 @@
require
'cases/test_case'
require
'active_support/dependencies'
require
'active_support/logger'
require
'active_support/core_ext/string/strip'
require
'support/config'
require
'support/connection'
...
...
activerecord/test/cases/migration_test.rb
浏览文件 @
52434e9a
...
...
@@ -11,7 +11,10 @@
require
MIGRATIONS_ROOT
+
"/rename/2_rename_things"
require
MIGRATIONS_ROOT
+
"/decimal/1_give_me_big_numbers"
class
BigNumber
<
ActiveRecord
::
Base
;
end
class
BigNumber
<
ActiveRecord
::
Base
property
:world_population
,
Type
::
Integer
.
new
property
:my_house_population
,
Type
::
Integer
.
new
end
class
Reminder
<
ActiveRecord
::
Base
;
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录