Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
ed6192c5
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,发现更多精彩内容 >>
提交
ed6192c5
编写于
9月 15, 2010
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adding a grouping node
上级
188fc7a4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
54 addition
and
15 deletion
+54
-15
lib/arel/nodes.rb
lib/arel/nodes.rb
+2
-0
lib/arel/nodes/binary.rb
lib/arel/nodes/binary.rb
+1
-9
lib/arel/nodes/grouping.rb
lib/arel/nodes/grouping.rb
+21
-0
lib/arel/nodes/node.rb
lib/arel/nodes/node.rb
+20
-0
lib/arel/visitors/to_sql.rb
lib/arel/visitors/to_sql.rb
+4
-0
spec/arel/nodes/equality_spec.rb
spec/arel/nodes/equality_spec.rb
+2
-2
spec/arel/nodes/or_spec.rb
spec/arel/nodes/or_spec.rb
+4
-4
未找到文件。
lib/arel/nodes.rb
浏览文件 @
ed6192c5
require
'arel/nodes/node'
require
'arel/nodes/binary'
require
'arel/nodes/equality'
require
'arel/nodes/not_equal'
...
...
@@ -29,6 +30,7 @@
require
'arel/nodes/table_alias'
require
'arel/nodes/join'
require
'arel/nodes/group'
require
'arel/nodes/grouping'
require
'arel/nodes/inner_join'
require
'arel/nodes/outer_join'
require
'arel/nodes/string_join'
...
...
lib/arel/nodes/binary.rb
浏览文件 @
ed6192c5
module
Arel
module
Nodes
class
Binary
class
Binary
<
Arel
::
Nodes
::
Node
attr_accessor
:left
,
:right
def
initialize
left
,
right
...
...
@@ -8,14 +8,6 @@ def initialize left, right
@right
=
right
end
def
or
right
Nodes
::
Or
.
new
self
,
right
end
def
and
right
Nodes
::
And
.
new
self
,
right
end
# FIXME: this method should go away. I don't like people calling
# to_sql on non-head nodes. This forces us to walk the AST until we
# can find a node that has a "relation" member.
...
...
lib/arel/nodes/grouping.rb
0 → 100644
浏览文件 @
ed6192c5
module
Arel
module
Nodes
class
Grouping
<
Arel
::
Nodes
::
Node
attr_accessor
:expr
def
initialize
expression
@expr
=
expression
end
# FIXME: this method should go away. I don't like people calling
# to_sql on non-head nodes. This forces us to walk the AST until we
# can find a node that has a "relation" member.
#
# Maybe we should just use `Table.engine`? :'(
def
to_sql
viz
=
Visitors
::
ToSql
.
new
Table
.
engine
viz
.
accept
self
end
end
end
end
lib/arel/nodes/node.rb
0 → 100644
浏览文件 @
ed6192c5
module
Arel
module
Nodes
###
# Abstract base class for all AST nodes
class
Node
###
# Factory method to create a Nodes::Grouping node that has an Nodes::Or
# node as a child.
def
or
right
Nodes
::
Grouping
.
new
Nodes
::
Or
.
new
(
self
,
right
)
end
###
# Factory method to create an Nodes::And node.
def
and
right
Nodes
::
And
.
new
self
,
right
end
end
end
end
lib/arel/visitors/to_sql.rb
浏览文件 @
ed6192c5
...
...
@@ -84,6 +84,10 @@ def visit_Arel_Nodes_Offset o
def
visit_Arel_Nodes_Lock
o
end
def
visit_Arel_Nodes_Grouping
o
"(
#{
visit
o
.
expr
}
)"
end
def
visit_Arel_Nodes_Group
o
visit
o
.
expr
end
...
...
spec/arel/nodes/equality_spec.rb
浏览文件 @
ed6192c5
...
...
@@ -34,8 +34,8 @@ module Nodes
left
=
attr
.
eq
(
10
)
right
=
attr
.
eq
(
11
)
node
=
left
.
or
right
check
node
.
left
.
should
==
left
check
node
.
right
.
should
==
right
check
node
.
expr
.
left
.
should
==
left
check
node
.
expr
.
right
.
should
==
right
end
end
...
...
spec/arel/nodes/or_spec.rb
浏览文件 @
ed6192c5
...
...
@@ -7,12 +7,12 @@ module Nodes
left
=
attr
.
eq
(
10
)
right
=
attr
.
eq
(
11
)
node
=
left
.
or
right
check
node
.
left
.
should
==
left
check
node
.
right
.
should
==
right
check
node
.
expr
.
left
.
should
==
left
check
node
.
expr
.
right
.
should
==
right
oror
=
node
.
or
(
right
)
check
oror
.
left
==
node
check
oror
.
right
==
right
check
oror
.
expr
.
left
==
node
check
oror
.
expr
.
right
==
right
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录