Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0bee4100
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,发现更多精彩内容 >>
提交
0bee4100
编写于
6月 25, 2015
作者:
S
Sean Griffin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #20677 from jmondo/decimal-default-string
Display decimal defaults as strings to keep precision
上级
17439e3a
4f58c501
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
9 addition
and
4 deletion
+9
-4
activerecord/lib/active_record/type/decimal.rb
activerecord/lib/active_record/type/decimal.rb
+1
-1
activerecord/test/cases/adapters/postgresql/money_test.rb
activerecord/test/cases/adapters/postgresql/money_test.rb
+1
-1
activerecord/test/cases/adapters/postgresql/schema_test.rb
activerecord/test/cases/adapters/postgresql/schema_test.rb
+5
-0
activerecord/test/cases/schema_dumper_test.rb
activerecord/test/cases/schema_dumper_test.rb
+2
-2
未找到文件。
activerecord/lib/active_record/type/decimal.rb
浏览文件 @
0bee4100
...
...
@@ -8,7 +8,7 @@ def type
end
def
type_cast_for_schema
(
value
)
value
.
to_s
value
.
to_s
.
inspect
end
private
...
...
activerecord/test/cases/adapters/postgresql/money_test.rb
浏览文件 @
0bee4100
...
...
@@ -56,7 +56,7 @@ def test_money_type_cast
def
test_schema_dumping
output
=
dump_table_schema
(
"postgresql_moneys"
)
assert_match
%r{t
\.
money
\s
+"wealth",
\s
+scale: 2$}
,
output
assert_match
%r{t
\.
money
\s
+"depth",
\s
+scale: 2,
\s
+default:
150
\.
55
$}
,
output
assert_match
%r{t
\.
money
\s
+"depth",
\s
+scale: 2,
\s
+default:
"150
\.
55"
$}
,
output
end
def
test_create_and_update_money
...
...
activerecord/test/cases/adapters/postgresql/schema_test.rb
浏览文件 @
0bee4100
...
...
@@ -480,6 +480,7 @@ class DefaultsUsingMultipleSchemasAndDomainTest < ActiveRecord::PostgreSQLTestCa
@connection
.
create_table
"defaults"
do
|
t
|
t
.
text
"text_col"
,
default:
"some value"
t
.
string
"string_col"
,
default:
"some value"
t
.
decimal
"decimal_col"
,
default:
"3.14159265358979323846"
end
Default
.
reset_column_information
end
...
...
@@ -498,6 +499,10 @@ def test_string_defaults_in_new_schema_when_overriding_domain
assert_equal
"some value"
,
Default
.
new
.
string_col
,
"Default of string column was not correctly parsed"
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"
end
def
test_bpchar_defaults_in_new_schema_when_overriding_domain
@connection
.
execute
"ALTER TABLE defaults ADD bpchar_col bpchar DEFAULT 'some value'"
Default
.
reset_column_information
...
...
activerecord/test/cases/schema_dumper_test.rb
浏览文件 @
0bee4100
...
...
@@ -239,7 +239,7 @@ def test_schema_dumps_index_type
def
test_schema_dump_includes_decimal_options
output
=
dump_all_table_schema
([
/^[^n]/
])
assert_match
%r{precision: 3,[[:space:]]+scale: 2,[[:space:]]+default:
2
\.
78
}
,
output
assert_match
%r{precision: 3,[[:space:]]+scale: 2,[[:space:]]+default:
"2
\.
78"
}
,
output
end
if
current_adapter?
(
:PostgreSQLAdapter
)
...
...
@@ -255,7 +255,7 @@ def test_schema_dump_includes_limit_on_array_type
def
test_schema_dump_allows_array_of_decimal_defaults
output
=
standard_dump
assert_match
%r{t
\.
decimal
\s
+"decimal_array_default",
\s
+default:
\[
1.23, 3.45
\]
,
\s
+array: true}
,
output
assert_match
%r{t
\.
decimal
\s
+"decimal_array_default",
\s
+default:
\[
"1.23", "3.45"
\]
,
\s
+array: true}
,
output
end
if
ActiveRecord
::
Base
.
connection
.
supports_extensions?
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录