Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
7361b6cb
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,发现更多精彩内容 >>
提交
7361b6cb
编写于
4月 29, 2011
作者:
E
Ernie Miller
提交者:
Aaron Patterson
4月 29, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move #as to AliasPredication, stop overriding Function's #as.
上级
d09a8823
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
33 addition
and
9 deletion
+33
-9
lib/arel.rb
lib/arel.rb
+1
-0
lib/arel/alias_predication.rb
lib/arel/alias_predication.rb
+7
-0
lib/arel/attributes/attribute.rb
lib/arel/attributes/attribute.rb
+1
-0
lib/arel/nodes/function.rb
lib/arel/nodes/function.rb
+2
-2
lib/arel/nodes/infix_operation.rb
lib/arel/nodes/infix_operation.rb
+1
-0
lib/arel/nodes/sql_literal.rb
lib/arel/nodes/sql_literal.rb
+1
-0
lib/arel/predications.rb
lib/arel/predications.rb
+0
-4
test/nodes/test_named_function.rb
test/nodes/test_named_function.rb
+17
-0
test/visitors/test_depth_first.rb
test/visitors/test_depth_first.rb
+3
-3
未找到文件。
lib/arel.rb
浏览文件 @
7361b6cb
...
...
@@ -4,6 +4,7 @@
require
'arel/expressions'
require
'arel/predications'
require
'arel/math'
require
'arel/alias_predication'
require
'arel/order_predications'
require
'arel/table'
require
'arel/attributes'
...
...
lib/arel/alias_predication.rb
0 → 100644
浏览文件 @
7361b6cb
module
Arel
module
AliasPredication
def
as
other
Nodes
::
As
.
new
self
,
Nodes
::
SqlLiteral
.
new
(
other
.
to_s
)
end
end
end
\ No newline at end of file
lib/arel/attributes/attribute.rb
浏览文件 @
7361b6cb
...
...
@@ -3,6 +3,7 @@ module Attributes
class
Attribute
<
Struct
.
new
:relation
,
:name
include
Arel
::
Expressions
include
Arel
::
Predications
include
Arel
::
AliasPredication
include
Arel
::
OrderPredications
include
Arel
::
Math
...
...
lib/arel/nodes/function.rb
浏览文件 @
7361b6cb
...
...
@@ -6,12 +6,12 @@ class Function < Arel::Nodes::Node
def
initialize
expr
,
aliaz
=
nil
@expressions
=
expr
@alias
=
aliaz
@alias
=
aliaz
&&
SqlLiteral
.
new
(
aliaz
.
to_s
)
@distinct
=
false
end
def
as
aliaz
self
.
alias
=
SqlLiteral
.
new
(
aliaz
)
self
.
alias
=
SqlLiteral
.
new
(
aliaz
.
to_s
)
self
end
end
...
...
lib/arel/nodes/infix_operation.rb
浏览文件 @
7361b6cb
...
...
@@ -4,6 +4,7 @@ module Nodes
class
InfixOperation
<
Binary
include
Arel
::
Expressions
include
Arel
::
Predications
include
Arel
::
AliasPredication
include
Arel
::
Math
attr_reader
:operator
...
...
lib/arel/nodes/sql_literal.rb
浏览文件 @
7361b6cb
...
...
@@ -3,6 +3,7 @@ module Nodes
class
SqlLiteral
<
String
include
Arel
::
Expressions
include
Arel
::
Predications
include
Arel
::
AliasPredication
include
Arel
::
OrderPredications
end
end
...
...
lib/arel/predications.rb
浏览文件 @
7361b6cb
module
Arel
module
Predications
def
as
other
Nodes
::
As
.
new
self
,
Nodes
::
SqlLiteral
.
new
(
other
)
end
def
not_eq
other
Nodes
::
NotEqual
.
new
self
,
other
end
...
...
test/nodes/test_named_function.rb
浏览文件 @
7361b6cb
...
...
@@ -8,6 +8,23 @@ def test_construct
assert_equal
'omg'
,
function
.
name
assert_equal
'zomg'
,
function
.
expressions
end
def
test_function_alias
function
=
NamedFunction
.
new
'omg'
,
'zomg'
function
=
function
.
as
(
'wth'
)
assert_equal
'omg'
,
function
.
name
assert_equal
'zomg'
,
function
.
expressions
assert_kind_of
SqlLiteral
,
function
.
alias
assert_equal
'wth'
,
function
.
alias
end
def
test_construct_with_alias
function
=
NamedFunction
.
new
'omg'
,
'zomg'
,
'wth'
assert_equal
'omg'
,
function
.
name
assert_equal
'zomg'
,
function
.
expressions
assert_kind_of
SqlLiteral
,
function
.
alias
assert_equal
'wth'
,
function
.
alias
end
end
end
end
test/visitors/test_depth_first.rb
浏览文件 @
7361b6cb
...
...
@@ -52,14 +52,14 @@ def test_raises_with_object
define_method
(
"test_
#{
klass
.
name
.
gsub
(
'::'
,
'_'
)
}
"
)
do
func
=
klass
.
new
(
:a
,
:b
)
@visitor
.
accept
func
assert_equal
[
:a
,
:b
,
false
,
func
],
@collector
.
calls
assert_equal
[
:a
,
"b"
,
false
,
func
],
@collector
.
calls
end
end
def
test_named_function
func
=
Arel
::
Nodes
::
NamedFunction
.
new
(
:a
,
:b
,
:c
)
@visitor
.
accept
func
assert_equal
[
:a
,
:b
,
false
,
:c
,
func
],
@collector
.
calls
assert_equal
[
:a
,
:b
,
false
,
"c"
,
func
],
@collector
.
calls
end
def
test_lock
...
...
@@ -71,7 +71,7 @@ def test_lock
def
test_count
count
=
Nodes
::
Count
.
new
:a
,
:b
,
:c
@visitor
.
accept
count
assert_equal
[
:a
,
:c
,
:b
,
count
],
@collector
.
calls
assert_equal
[
:a
,
"c"
,
:b
,
count
],
@collector
.
calls
end
def
test_inner_join
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录