Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
77fa5fa5
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,发现更多精彩内容 >>
提交
77fa5fa5
编写于
9月 27, 2010
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
to_sql on nodes may be passed an engine
上级
ec998ae9
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
37 addition
and
35 deletion
+37
-35
lib/arel/nodes/binary.rb
lib/arel/nodes/binary.rb
+0
-10
lib/arel/nodes/function.rb
lib/arel/nodes/function.rb
+1
-6
lib/arel/nodes/grouping.rb
lib/arel/nodes/grouping.rb
+0
-10
lib/arel/nodes/node.rb
lib/arel/nodes/node.rb
+10
-0
spec/nodes/equality_spec.rb
spec/nodes/equality_spec.rb
+18
-0
spec/spec_helper.rb
spec/spec_helper.rb
+1
-1
spec/support/fake_record.rb
spec/support/fake_record.rb
+7
-8
未找到文件。
lib/arel/nodes/binary.rb
浏览文件 @
77fa5fa5
...
...
@@ -7,16 +7,6 @@ def initialize left, right
@left
=
left
@right
=
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.
#
# 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/function.rb
浏览文件 @
77fa5fa5
module
Arel
module
Nodes
class
Function
class
Function
<
Arel
::
Nodes
::
Node
include
Arel
::
Expression
attr_accessor
:expressions
,
:alias
...
...
@@ -13,11 +13,6 @@ def as aliaz
self
.
alias
=
SqlLiteral
.
new
(
aliaz
)
self
end
def
to_sql
viz
=
Visitors
::
ToSql
.
new
Table
.
engine
viz
.
accept
self
end
end
end
end
lib/arel/nodes/grouping.rb
浏览文件 @
77fa5fa5
...
...
@@ -6,16 +6,6 @@ class Grouping < Arel::Nodes::Node
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
浏览文件 @
77fa5fa5
...
...
@@ -15,6 +15,16 @@ def or right
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.
#
# Maybe we should just use `Table.engine`? :'(
def
to_sql
engine
=
Table
.
engine
viz
=
Visitors
::
ToSql
.
new
engine
viz
.
accept
self
end
end
end
end
spec/nodes/equality_spec.rb
浏览文件 @
77fa5fa5
...
...
@@ -26,6 +26,24 @@ module Nodes
check
left
.
right
.
should
==
left
.
operand2
end
end
describe
'to_sql'
do
it
'takes an engine'
do
engine
=
FakeRecord
::
Base
.
new
engine
.
connection
.
extend
Module
.
new
{
attr_accessor
:quote_count
def
quote
(
*
args
)
@quote_count
+=
1
;
super
;
end
def
quote_column_name
(
*
args
)
@quote_count
+=
1
;
super
;
end
def
quote_table_name
(
*
args
)
@quote_count
+=
1
;
super
;
end
}
engine
.
connection
.
quote_count
=
0
attr
=
Table
.
new
(
:users
)[
:id
]
test
=
attr
.
eq
(
10
)
test
.
to_sql
engine
check
engine
.
connection
.
quote_count
.
should
==
2
end
end
end
describe
'or'
do
...
...
spec/spec_helper.rb
浏览文件 @
77fa5fa5
...
...
@@ -13,6 +13,6 @@
config
.
include
Check
config
.
before
do
Arel
::
Table
.
engine
=
Arel
::
Sql
::
Engine
.
new
(
FakeRecord
::
Base
)
Arel
::
Table
.
engine
=
Arel
::
Sql
::
Engine
.
new
(
FakeRecord
::
Base
.
new
)
end
end
spec/support/fake_record.rb
浏览文件 @
77fa5fa5
...
...
@@ -63,14 +63,11 @@ class ConnectionPool
class
Spec
<
Struct
.
new
(
:config
)
end
attr_reader
:spec
attr_reader
:spec
,
:connection
def
initialize
@spec
=
Spec
.
new
(
'sqlite3'
)
end
def
connection
Connection
.
new
@connection
=
Connection
.
new
end
def
with_connection
...
...
@@ -79,11 +76,13 @@ def with_connection
end
class
Base
def
self
.
connection_pool
ConnectionPool
.
new
attr_accessor
:connection_pool
def
initialize
@connection_pool
=
ConnectionPool
.
new
end
def
self
.
connection
def
connection
connection_pool
.
connection
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录