Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
5c9d75db
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,发现更多精彩内容 >>
提交
5c9d75db
编写于
9月 08, 2010
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adding locking node to the AST
上级
539572f0
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
36 addition
and
2 deletion
+36
-2
lib/arel/nodes.rb
lib/arel/nodes.rb
+1
-0
lib/arel/nodes/lock.rb
lib/arel/nodes/lock.rb
+6
-0
lib/arel/nodes/select_statement.rb
lib/arel/nodes/select_statement.rb
+2
-1
lib/arel/select_manager.rb
lib/arel/select_manager.rb
+7
-0
lib/arel/table.rb
lib/arel/table.rb
+4
-0
lib/arel/visitors/to_sql.rb
lib/arel/visitors/to_sql.rb
+7
-1
spec/arel/select_manager_spec.rb
spec/arel/select_manager_spec.rb
+9
-0
未找到文件。
lib/arel/nodes.rb
浏览文件 @
5c9d75db
...
...
@@ -4,6 +4,7 @@
require
'arel/nodes/and'
require
'arel/nodes/in'
require
'arel/nodes/lock'
require
'arel/nodes/function'
require
'arel/nodes/count'
require
'arel/nodes/sum'
...
...
lib/arel/nodes/lock.rb
0 → 100644
浏览文件 @
5c9d75db
module
Arel
module
Nodes
class
Lock
end
end
end
lib/arel/nodes/select_statement.rb
浏览文件 @
5c9d75db
...
...
@@ -2,12 +2,13 @@ module Arel
module
Nodes
class
SelectStatement
attr_reader
:cores
attr_accessor
:limit
,
:orders
attr_accessor
:limit
,
:orders
,
:lock
def
initialize
cores
=
[
SelectCore
.
new
]
@cores
=
cores
@orders
=
[]
@limit
=
nil
@lock
=
nil
end
def
initialize_copy
other
...
...
lib/arel/select_manager.rb
浏览文件 @
5c9d75db
...
...
@@ -8,6 +8,13 @@ def initialize engine
@ctx
=
@head
.
cores
.
last
end
def
lock
locking
=
true
# FIXME: do we even need to store this? If locking is +false+ shouldn't
# we just remove the node from the AST?
@head
.
lock
=
Nodes
::
Lock
.
new
self
end
def
on
*
exprs
@ctx
.
froms
.
last
.
constraint
=
Nodes
::
On
.
new
(
collapse
(
exprs
))
self
...
...
lib/arel/table.rb
浏览文件 @
5c9d75db
...
...
@@ -26,6 +26,10 @@ def tm
SelectManager
.
new
(
@engine
).
from
(
self
)
end
def
from
table
SelectManager
.
new
(
@engine
).
from
table
end
def
joins
manager
nil
end
...
...
lib/arel/visitors/to_sql.rb
浏览文件 @
5c9d75db
...
...
@@ -48,7 +48,8 @@ def visit_Arel_Nodes_SelectStatement o
[
o
.
cores
.
map
{
|
x
|
visit
x
}.
join
,
(
"ORDER BY
#{
o
.
orders
.
map
{
|
x
|
visit
x
}
.join(', ')}"
unless
o
.
orders
.
empty?
),
(
"LIMIT
#{
o
.
limit
}
"
if
o
.
limit
)
(
"LIMIT
#{
o
.
limit
}
"
if
o
.
limit
),
(
visit
(
o
.
lock
)
if
o
.
lock
),
].
compact
.
join
' '
end
...
...
@@ -66,6 +67,11 @@ def visit_Arel_Nodes_Having o
"HAVING
#{
visit
o
.
expr
}
"
end
# FIXME: this does nothing on SQLLite3, but should do things on other
# databases.
def
visit_Arel_Nodes_Lock
o
end
def
visit_Arel_Nodes_Group
o
visit
o
.
expr
end
...
...
spec/arel/select_manager_spec.rb
浏览文件 @
5c9d75db
...
...
@@ -25,6 +25,15 @@ def execute sql, name = nil
end
describe
'select manager'
do
describe
'lock'
do
# This should fail on other databases
it
'adds a lock node'
do
table
=
Table
.
new
:users
mgr
=
table
.
from
table
mgr
.
lock
.
to_sql
.
should
be_like
%{ SELECT FROM "users" }
end
end
describe
'order'
do
it
'generates order clauses'
do
table
=
Table
.
new
:users
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录