Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
42a1bf18
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,体验更适合开发者的 AI 搜索 >>
提交
42a1bf18
编写于
4月 09, 2014
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
working against arel/collector branch
上级
70bd5eb4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
19 deletion
+12
-19
activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
...ecord/connection_adapters/abstract/database_statements.rb
+2
-1
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
...tive_record/connection_adapters/abstract_mysql_adapter.rb
+4
-12
activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
...d/lib/active_record/connection_adapters/mysql2_adapter.rb
+2
-2
activerecord/lib/active_record/statement_cache.rb
activerecord/lib/active_record/statement_cache.rb
+4
-4
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
浏览文件 @
42a1bf18
...
...
@@ -9,7 +9,8 @@ def initialize
# Converts an arel AST to SQL
def
to_sql
(
arel
,
binds
=
[])
if
arel
.
respond_to?
(
:ast
)
visitor
.
accept
(
arel
.
ast
,
collector
).
compile
binds
.
dup
collected
=
visitor
.
accept
(
arel
.
ast
,
collector
)
collected
.
compile
(
binds
.
dup
,
self
)
else
arel
end
...
...
activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb
浏览文件 @
42a1bf18
...
...
@@ -183,10 +183,6 @@ def missing_default_forged_as_empty_string?(default)
INDEX_TYPES
=
[
:fulltext
,
:spatial
]
INDEX_USINGS
=
[
:btree
,
:hash
]
class
BindSubstitution
<
Arel
::
Visitors
::
MySQL
# :nodoc:
include
Arel
::
Visitors
::
BindVisitor
end
# FIXME: Make the first parameter more similar for the two adapters
def
initialize
(
connection
,
logger
,
connection_options
,
config
)
super
(
connection
,
logger
)
...
...
@@ -203,21 +199,17 @@ def initialize(connection, logger, connection_options, config)
end
class
BindCollector
<
Arel
::
Collectors
::
Bind
def
initialize
(
conn
)
@conn
=
conn
super
()
end
def
compile
(
bvs
)
super
(
bvs
.
map
{
|
bv
|
@conn
.
quote
(
*
bv
.
reverse
)
})
def
compile
(
bvs
,
conn
)
super
(
bvs
.
map
{
|
bv
|
conn
.
quote
(
*
bv
.
reverse
)
})
end
end
def
collector
if
@prepared_statements
raise
Arel
::
Collectors
::
SQLString
.
new
else
BindCollector
.
new
self
BindCollector
.
new
end
end
...
...
activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
浏览文件 @
42a1bf18
...
...
@@ -40,12 +40,12 @@ def adapter
def
initialize
(
connection
,
logger
,
connection_options
,
config
)
super
@
visitor
=
BindSubstitution
.
new
self
@
prepared_statements
=
false
configure_connection
end
def
cacheable_query
(
arel
)
ActiveRecord
::
StatementCache
.
partial_query
visitor
,
arel
.
ast
ActiveRecord
::
StatementCache
.
partial_query
visitor
,
arel
.
ast
,
collector
end
MAX_INDEX_LENGTH_FOR_UTF8MB4
=
191
...
...
activerecord/lib/active_record/statement_cache.rb
浏览文件 @
42a1bf18
...
...
@@ -28,7 +28,7 @@ def sql_for(binds, connection)
class
PartialQuery
<
Query
def
sql_for
(
binds
,
connection
)
@sql
.
gsub
(
/\?/
)
{
connection
.
quote
(
*
binds
.
shift
.
reverse
)
}
@sql
.
compile
binds
,
connection
end
end
...
...
@@ -36,9 +36,9 @@ def self.query(visitor, ast)
Query
.
new
visitor
.
accept
(
ast
,
Arel
::
Collectors
::
SQLString
.
new
).
value
end
def
self
.
partial_query
(
visitor
,
ast
)
sql
=
visitor
.
accept
(
ast
)
{
"?"
}
PartialQuery
.
new
sql
def
self
.
partial_query
(
visitor
,
ast
,
collector
)
collected
=
visitor
.
accept
(
ast
,
collector
)
PartialQuery
.
new
collected
end
class
Params
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录