Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f569955e
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 搜索 >>
提交
f569955e
编写于
10月 10, 2018
作者:
R
Ryuta Kamizono
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor Arel visitor to use `collect_nodes_for` as much as possible
上级
92ccb7c7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
33 deletion
+10
-33
activerecord/lib/arel/visitors/to_sql.rb
activerecord/lib/arel/visitors/to_sql.rb
+10
-33
未找到文件。
activerecord/lib/arel/visitors/to_sql.rb
浏览文件 @
f569955e
...
...
@@ -85,7 +85,9 @@ def visit_Arel_Nodes_DeleteStatement(o, collector)
end
collector
=
visit
o
.
relation
,
collector
collect_where_for
(
o
,
collector
)
collect_nodes_for
o
.
wheres
,
collector
,
" WHERE "
,
" AND "
collect_nodes_for
o
.
orders
,
collector
,
" ORDER BY "
maybe_visit
o
.
limit
,
collector
end
def
visit_Arel_Nodes_UpdateStatement
(
o
,
collector
)
...
...
@@ -93,12 +95,11 @@ def visit_Arel_Nodes_UpdateStatement(o, collector)
collector
<<
"UPDATE "
collector
=
visit
o
.
relation
,
collector
unless
o
.
values
.
empty?
collector
<<
" SET "
collector
=
inject_join
o
.
values
,
collector
,
", "
end
collect_nodes_for
o
.
values
,
collector
,
" SET "
collect_where_for
(
o
,
collector
)
collect_nodes_for
o
.
wheres
,
collector
,
" WHERE "
,
" AND "
collect_nodes_for
o
.
orders
,
collector
,
" ORDER BY "
maybe_visit
o
.
limit
,
collector
end
def
visit_Arel_Nodes_InsertStatement
(
o
,
collector
)
...
...
@@ -231,10 +232,7 @@ def visit_Arel_Nodes_SelectCore(o, collector)
collect_nodes_for
o
.
wheres
,
collector
,
WHERE
,
AND
collect_nodes_for
o
.
groups
,
collector
,
GROUP_BY
unless
o
.
havings
.
empty?
collector
<<
" HAVING "
inject_join
o
.
havings
,
collector
,
AND
end
collect_nodes_for
o
.
havings
,
collector
,
" HAVING "
,
AND
collect_nodes_for
o
.
windows
,
collector
,
WINDOW
collector
...
...
@@ -243,11 +241,7 @@ def visit_Arel_Nodes_SelectCore(o, collector)
def
collect_nodes_for
(
nodes
,
collector
,
spacer
,
connector
=
COMMA
)
unless
nodes
.
empty?
collector
<<
spacer
len
=
nodes
.
length
-
1
nodes
.
each_with_index
do
|
x
,
i
|
collector
=
visit
(
x
,
collector
)
collector
<<
connector
unless
len
==
i
end
inject_join
nodes
,
collector
,
connector
end
end
...
...
@@ -302,10 +296,7 @@ def visit_Arel_Nodes_NamedWindow(o, collector)
def
visit_Arel_Nodes_Window
(
o
,
collector
)
collector
<<
"("
if
o
.
partitions
.
any?
collector
<<
"PARTITION BY "
collector
=
inject_join
o
.
partitions
,
collector
,
", "
end
collect_nodes_for
o
.
partitions
,
collector
,
"PARTITION BY "
if
o
.
orders
.
any?
collector
<<
SPACE
if
o
.
partitions
.
any?
...
...
@@ -836,20 +827,6 @@ def build_subselect(key, o)
stmt
end
def
collect_where_for
(
o
,
collector
)
unless
o
.
wheres
.
empty?
collector
<<
" WHERE "
collector
=
inject_join
o
.
wheres
,
collector
,
" AND "
end
unless
o
.
orders
.
empty?
collector
<<
" ORDER BY "
collector
=
inject_join
o
.
orders
,
collector
,
", "
end
maybe_visit
o
.
limit
,
collector
end
def
infix_value
(
o
,
collector
,
value
)
collector
=
visit
o
.
left
,
collector
collector
<<
value
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录