Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
bd3ecd76
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,发现更多精彩内容 >>
提交
bd3ecd76
编写于
8月 16, 2010
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
quoting strings from equality statements, adding to_dot
上级
e1155aa9
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
21 addition
and
2 deletion
+21
-2
lib/arel/tree_manager.rb
lib/arel/tree_manager.rb
+4
-0
lib/arel/visitors/dot.rb
lib/arel/visitors/dot.rb
+7
-1
lib/arel/visitors/to_sql.rb
lib/arel/visitors/to_sql.rb
+1
-1
spec/arel/visitors/to_sql_spec.rb
spec/arel/visitors/to_sql_spec.rb
+9
-0
未找到文件。
lib/arel/tree_manager.rb
浏览文件 @
bd3ecd76
...
@@ -7,6 +7,10 @@ def initialize engine
...
@@ -7,6 +7,10 @@ def initialize engine
@engine
=
engine
@engine
=
engine
end
end
def
to_dot
Visitors
::
Dot
.
new
.
accept
@head
end
def
to_sql
def
to_sql
viz
=
Visitors
::
ToSql
.
new
@engine
viz
=
Visitors
::
ToSql
.
new
@engine
viz
.
accept
@head
viz
.
accept
@head
...
...
lib/arel/visitors/dot.rb
浏览文件 @
bd3ecd76
...
@@ -56,6 +56,8 @@ def visit_String o
...
@@ -56,6 +56,8 @@ def visit_String o
end
end
alias
:visit_Time
:visit_String
alias
:visit_Time
:visit_String
alias
:visit_NilClass
:visit_String
alias
:visit_NilClass
:visit_String
alias
:visit_Arel_SqlLiteral
:visit_String
alias
:visit_Fixnum
:visit_String
def
visit_Hash
o
def
visit_Hash
o
o
.
each_with_index
do
|
pair
,
i
|
o
.
each_with_index
do
|
pair
,
i
|
...
@@ -105,13 +107,17 @@ def with_node node
...
@@ -105,13 +107,17 @@ def with_node node
@node_stack
.
pop
@node_stack
.
pop
end
end
def
quote
string
string
.
to_s
.
gsub
(
'"'
,
'\"'
)
end
def
to_dot
def
to_dot
"digraph
\"
ARel
\"
{
\n
node [width=0.375,height=0.25,shape=record];
\n
"
+
"digraph
\"
ARel
\"
{
\n
node [width=0.375,height=0.25,shape=record];
\n
"
+
@nodes
.
map
{
|
node
|
@nodes
.
map
{
|
node
|
label
=
"<f0>
#{
node
.
name
}
"
label
=
"<f0>
#{
node
.
name
}
"
node
.
fields
.
each_with_index
do
|
field
,
i
|
node
.
fields
.
each_with_index
do
|
field
,
i
|
label
<<
"|<f
#{
i
+
1
}
>
#{
field
}
"
label
<<
"|<f
#{
i
+
1
}
>
#{
quote
field
}
"
end
end
"
#{
node
.
id
}
[label=
\"
#{
label
}
\"
];"
"
#{
node
.
id
}
[label=
\"
#{
label
}
\"
];"
...
...
lib/arel/visitors/to_sql.rb
浏览文件 @
bd3ecd76
...
@@ -57,7 +57,7 @@ def visit_Arel_Table o
...
@@ -57,7 +57,7 @@ def visit_Arel_Table o
end
end
def
visit_Arel_Nodes_Equality
o
def
visit_Arel_Nodes_Equality
o
"
#{
visit
o
.
left
}
=
#{
visit
o
.
right
}
"
"
#{
visit
o
.
left
}
=
#{
quote
visit
o
.
right
}
"
end
end
def
visit_Arel_Attributes_Attribute
o
def
visit_Arel_Attributes_Attribute
o
...
...
spec/arel/visitors/to_sql_spec.rb
浏览文件 @
bd3ecd76
...
@@ -12,6 +12,15 @@ module Visitors
...
@@ -12,6 +12,15 @@ module Visitors
attr
=
Attributes
::
Time
.
new
(
@attr
.
relation
,
@attr
.
name
,
@attr
.
column
)
attr
=
Attributes
::
Time
.
new
(
@attr
.
relation
,
@attr
.
name
,
@attr
.
column
)
@visitor
.
accept
attr
@visitor
.
accept
attr
end
end
describe
'Equality'
do
it
"should escape strings"
do
test
=
@attr
.
eq
'Aaron Patterson'
@visitor
.
accept
(
test
).
should
be_like
%{
"users"."id" = 'Aaron Patterson'
}
end
end
end
end
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录