Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
a80f04c0
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,发现更多精彩内容 >>
提交
a80f04c0
编写于
4月 15, 2013
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #10225 from kennyj/fix_bit_string_problem
Fix bit string problem
上级
9f290e6e
9339005b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
5 deletion
+22
-5
activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
.../lib/active_record/connection_adapters/postgresql/cast.rb
+7
-0
activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
...d/lib/active_record/connection_adapters/postgresql/oid.rb
+12
-2
activerecord/test/cases/adapters/postgresql/datatype_test.rb
activerecord/test/cases/adapters/postgresql/datatype_test.rb
+3
-3
未找到文件。
activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
浏览文件 @
a80f04c0
...
...
@@ -26,6 +26,13 @@ def string_to_time(string)
end
end
def
string_to_bit
(
value
)
case
value
when
/^[01]*$/
then
value
# Bit-string notation
when
/^[0-9A-F]*$/i
then
value
.
hex
.
to_s
(
2
)
# Hexadecimal notation
end
end
def
hstore_to_string
(
object
)
if
Hash
===
object
object
.
map
{
|
k
,
v
|
...
...
activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
浏览文件 @
a80f04c0
...
...
@@ -18,6 +18,16 @@ def type_cast(value)
end
end
class
Bit
<
Type
def
type_cast
(
value
)
if
String
===
value
ConnectionAdapters
::
PostgreSQLColumn
.
string_to_bit
value
else
value
end
end
end
class
Bytea
<
Type
def
type_cast
(
value
)
return
if
value
.
nil?
...
...
@@ -323,14 +333,14 @@ def self.registered_type?(name)
# FIXME: why are we keeping these types as strings?
alias_type
'tsvector'
,
'text'
alias_type
'interval'
,
'text'
alias_type
'bit'
,
'text'
alias_type
'varbit'
,
'text'
alias_type
'macaddr'
,
'text'
alias_type
'uuid'
,
'text'
register_type
'money'
,
OID
::
Money
.
new
register_type
'bytea'
,
OID
::
Bytea
.
new
register_type
'bool'
,
OID
::
Boolean
.
new
register_type
'bit'
,
OID
::
Bit
.
new
register_type
'varbit'
,
OID
::
Bit
.
new
register_type
'float4'
,
OID
::
Float
.
new
alias_type
'float8'
,
'float4'
...
...
activerecord/test/cases/adapters/postgresql/datatype_test.rb
浏览文件 @
a80f04c0
...
...
@@ -545,13 +545,13 @@ def test_update_network_address
def
test_update_bit_string
new_bit_string
=
'11111111'
new_bit_string_varying
=
'
11111110
'
new_bit_string_varying
=
'
FF
'
assert
@first_bit_string
.
bit_string
=
new_bit_string
assert
@first_bit_string
.
bit_string_varying
=
new_bit_string_varying
assert
@first_bit_string
.
save
assert
@first_bit_string
.
reload
assert_equal
new_bit_string
,
@first_bit_string
.
bit_string
assert_equal
new_bit_string_vary
ing
,
@first_bit_string
.
bit_string_varying
assert_equal
@first_bit_string
.
bit_string
,
new_
bit_string
assert_equal
@first_bit_string
.
bit_str
ing
,
@first_bit_string
.
bit_string_varying
end
def
test_update_oid
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录