Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
55400052
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,体验更适合开发者的 AI 搜索 >>
提交
55400052
编写于
5月 21, 2014
作者:
D
Dan Croak and Sean Griffin
提交者:
Dan Croak
5月 22, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move `extract_precision` onto type objects
上级
35c16006
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
15 addition
and
19 deletion
+15
-19
activerecord/lib/active_record/connection_adapters/column.rb
activerecord/lib/active_record/connection_adapters/column.rb
+1
-5
activerecord/lib/active_record/connection_adapters/postgresql/column.rb
...ib/active_record/connection_adapters/postgresql/column.rb
+0
-13
activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb
...active_record/connection_adapters/postgresql/oid/money.rb
+2
-0
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+1
-1
activerecord/lib/active_record/connection_adapters/type/date_time.rb
...d/lib/active_record/connection_adapters/type/date_time.rb
+4
-0
activerecord/lib/active_record/connection_adapters/type/numeric.rb
...ord/lib/active_record/connection_adapters/type/numeric.rb
+4
-0
activerecord/lib/active_record/connection_adapters/type/value.rb
...ecord/lib/active_record/connection_adapters/type/value.rb
+3
-0
未找到文件。
activerecord/lib/active_record/connection_adapters/column.rb
浏览文件 @
55400052
...
...
@@ -69,15 +69,11 @@ def extract_default(default)
end
private
delegate
:extract_scale
,
to: :cast_type
delegate
:extract_scale
,
:extract_precision
,
to: :cast_type
def
extract_limit
(
sql_type
)
$1
.
to_i
if
sql_type
=~
/\((.*)\)/
end
def
extract_precision
(
sql_type
)
$2
.
to_i
if
sql_type
=~
/^(numeric|decimal|number)\((\d+)(,\d+)?\)/i
end
end
end
# :startdoc:
...
...
activerecord/lib/active_record/connection_adapters/postgresql/column.rb
浏览文件 @
55400052
...
...
@@ -35,8 +35,6 @@ class << self
require
'active_record/connection_adapters/postgresql/array_parser'
include
PostgreSQL
::
ArrayParser
end
attr_accessor
:money_precision
end
# :startdoc:
...
...
@@ -121,17 +119,6 @@ def extract_limit(sql_type)
else
super
end
end
# Extracts the precision from PostgreSQL-specific data types.
def
extract_precision
(
sql_type
)
if
sql_type
==
'money'
self
.
class
.
money_precision
elsif
sql_type
=~
/timestamp/i
$1
.
to_i
if
sql_type
=~
/\((\d+)\)/
else
super
end
end
end
end
end
activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb
浏览文件 @
55400052
...
...
@@ -5,6 +5,8 @@ module OID # :nodoc:
class
Money
<
Type
::
Decimal
include
Infinity
class_attribute
:precision
def
extract_scale
(
sql_type
)
2
end
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
55400052
...
...
@@ -713,7 +713,7 @@ def connect
# Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of
# PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision
# should know about this but can't detect it there, so deal with it here.
PostgreSQLColumn
.
money_
precision
=
(
postgresql_version
>=
80300
)
?
19
:
10
OID
::
Money
.
precision
=
(
postgresql_version
>=
80300
)
?
19
:
10
configure_connection
rescue
::
PG
::
Error
=>
error
...
...
activerecord/lib/active_record/connection_adapters/type/date_time.rb
浏览文件 @
55400052
...
...
@@ -8,6 +8,10 @@ def type
:datetime
end
def
extract_precision
(
sql_type
)
$1
.
to_i
if
sql_type
=~
/\((\d+)\)/
end
private
def
cast_value
(
string
)
...
...
activerecord/lib/active_record/connection_adapters/type/numeric.rb
浏览文件 @
55400052
...
...
@@ -14,6 +14,10 @@ def type_cast_for_write(value)
else
super
end
end
def
extract_precision
(
sql_type
)
$1
.
to_i
if
sql_type
=~
/\((\d+)(,\d+)?\)/
end
end
end
end
...
...
activerecord/lib/active_record/connection_adapters/type/value.rb
浏览文件 @
55400052
...
...
@@ -3,8 +3,11 @@ module ConnectionAdapters
module
Type
class
Value
# :nodoc:
def
type
;
end
def
extract_scale
(
sql_type
);
end
def
extract_precision
(
sql_type
);
end
def
type_cast
(
value
)
cast_value
(
value
)
unless
value
.
nil?
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录