Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
96e504ec
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 搜索 >>
提交
96e504ec
编写于
1月 23, 2015
作者:
S
Sean Griffin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Errors raised in `type_cast_for_database` no longer raise on assignment
Fixes #18580.
上级
b9d668f8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
3 deletion
+29
-3
activerecord/CHANGELOG.md
activerecord/CHANGELOG.md
+10
-1
activerecord/lib/active_record/attribute_methods/dirty.rb
activerecord/lib/active_record/attribute_methods/dirty.rb
+1
-1
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
.../lib/active_record/connection_adapters/sqlite3_adapter.rb
+1
-1
activerecord/test/cases/types_test.rb
activerecord/test/cases/types_test.rb
+17
-0
未找到文件。
activerecord/CHANGELOG.md
浏览文件 @
96e504ec
*
Values which would error while being sent to the database (such as an
ASCII-8BIT string with invalid UTF-8 bytes on Sqlite3), no longer error on
assignment. They will still error when sent to the database, but you are
given the ability to re-assign it to a valid value.
Fixes #18580.
*Sean Griffin*
*
Don't remove join dependencies in
`Relation#exists?`
Fixes #18632
Fixes #18632
.
*Sean Griffin*
...
...
activerecord/lib/active_record/attribute_methods/dirty.rb
浏览文件 @
96e504ec
...
...
@@ -165,7 +165,7 @@ def original_raw_attributes
end
def
store_original_raw_attribute
(
attr_name
)
original_raw_attributes
[
attr_name
]
=
@attributes
[
attr_name
].
value_for_database
original_raw_attributes
[
attr_name
]
=
@attributes
[
attr_name
].
value_for_database
rescue
nil
end
def
store_original_raw_attributes
...
...
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
浏览文件 @
96e504ec
...
...
@@ -53,7 +53,7 @@ def cast_value(value)
class
SQLite3String
<
Type
::
String
# :nodoc:
def
type_cast_for_database
(
value
)
if
value
.
is_a?
(
::
String
)
&&
value
.
encoding
==
Encoding
::
ASCII_8BIT
value
.
encode
(
Encoding
::
UTF_8
)
value
.
encode
(
Encoding
::
UTF_8
,
undef: :replace
)
else
super
end
...
...
activerecord/test/cases/types_test.rb
浏览文件 @
96e504ec
...
...
@@ -117,6 +117,23 @@ def test_binary_encoding
assert_equal
Encoding
::
ASCII_8BIT
,
type_cast
.
encoding
end
end
def
test_attributes_which_are_invalid_for_database_can_still_be_reassigned
type_which_cannot_go_to_the_database
=
Type
::
Value
.
new
def
type_which_cannot_go_to_the_database
.
type_cast_for_database
(
*
)
raise
end
klass
=
Class
.
new
(
ActiveRecord
::
Base
)
do
self
.
table_name
=
'posts'
attribute
:foo
,
type_which_cannot_go_to_the_database
end
model
=
klass
.
new
model
.
foo
=
"foo"
model
.
foo
=
"bar"
assert_equal
"bar"
,
model
.
foo
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录