Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
b1458218
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,发现更多精彩内容 >>
提交
b1458218
编写于
4月 24, 2019
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Lazy allocate `@_start_transaction_state`
上级
aa5e6b59
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
8 deletion
+10
-8
activerecord/lib/active_record/core.rb
activerecord/lib/active_record/core.rb
+2
-2
activerecord/lib/active_record/transactions.rb
activerecord/lib/active_record/transactions.rb
+8
-6
未找到文件。
activerecord/lib/active_record/core.rb
浏览文件 @
b1458218
...
...
@@ -403,7 +403,7 @@ def initialize_dup(other) # :nodoc:
@new_record
=
true
@destroyed
=
false
@_start_transaction_state
=
{}
@_start_transaction_state
=
nil
@transaction_state
=
nil
super
...
...
@@ -575,7 +575,7 @@ def init_internals
@marked_for_destruction
=
false
@destroyed_by_association
=
nil
@new_record
=
true
@_start_transaction_state
=
{}
@_start_transaction_state
=
nil
@transaction_state
=
nil
end
...
...
activerecord/lib/active_record/transactions.rb
浏览文件 @
b1458218
...
...
@@ -386,14 +386,15 @@ def with_transaction_returning_status
# Save the new record state and id of a record so it can be restored later if a transaction fails.
def
remember_transaction_record_state
@_start_transaction_state
.
reverse_merge!
(
@_start_transaction_state
||=
{
id:
id
,
new_record:
@new_record
,
destroyed:
@destroyed
,
attributes:
@attributes
,
frozen?:
frozen?
,
)
@_start_transaction_state
[
:level
]
=
(
@_start_transaction_state
[
:level
]
||
0
)
+
1
level:
0
}
@_start_transaction_state
[
:level
]
+=
1
remember_new_record_before_last_commit
end
...
...
@@ -407,19 +408,20 @@ def remember_new_record_before_last_commit
# Clear the new record state and id of a record.
def
clear_transaction_record_state
@_start_transaction_state
[
:level
]
=
(
@_start_transaction_state
[
:level
]
||
0
)
-
1
return
unless
@_start_transaction_state
@_start_transaction_state
[
:level
]
-=
1
force_clear_transaction_record_state
if
@_start_transaction_state
[
:level
]
<
1
end
# Force to clear the transaction record state.
def
force_clear_transaction_record_state
@_start_transaction_state
.
clear
@_start_transaction_state
=
nil
@transaction_state
=
nil
end
# Restore the new record state and id of a record that was previously saved by a call to save_record_state.
def
restore_transaction_record_state
(
force_restore_state
=
false
)
unless
@_start_transaction_state
.
empty?
if
@_start_transaction_state
transaction_level
=
(
@_start_transaction_state
[
:level
]
||
0
)
-
1
if
transaction_level
<
1
||
force_restore_state
restore_state
=
@_start_transaction_state
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录