Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
d980abdb
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,发现更多精彩内容 >>
提交
d980abdb
编写于
7月 26, 2016
作者:
S
Sean Griffin
提交者:
GitHub
7月 26, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #25523 from kamipo/extract_quoted_binds_type_casted_binds
Extract `type_casted_binds` method
上级
6594226c
d31c2e2c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
10 addition
and
6 deletion
+10
-6
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
...lib/active_record/connection_adapters/abstract/quoting.rb
+4
-0
activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
...e_record/connection_adapters/mysql/database_statements.rb
+1
-1
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+2
-2
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
.../lib/active_record/connection_adapters/sqlite3_adapter.rb
+3
-3
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
浏览文件 @
d980abdb
...
...
@@ -156,6 +156,10 @@ def prepare_binds_for_database(binds) # :nodoc:
private
def
type_casted_binds
(
binds
)
binds
.
map
{
|
attr
|
type_cast
(
attr
.
value_for_database
)
}
end
def
types_which_need_no_typecasting
[
nil
,
Numeric
,
String
]
end
...
...
activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb
浏览文件 @
d980abdb
...
...
@@ -77,7 +77,7 @@ def exec_stmt_and_free(sql, name, binds, cache_stmt: false)
@connection
.
query_options
[
:database_timezone
]
=
ActiveRecord
::
Base
.
default_timezone
end
type_casted_binds
=
binds
.
map
{
|
attr
|
type_cast
(
attr
.
value_for_database
)
}
type_casted_binds
=
type_casted_binds
(
binds
)
log
(
sql
,
name
,
binds
,
type_casted_binds
)
do
if
cache_stmt
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
d980abdb
...
...
@@ -597,13 +597,13 @@ def execute_and_clear(sql, name, binds, prepare: false)
end
def
exec_no_cache
(
sql
,
name
,
binds
)
type_casted_binds
=
binds
.
map
{
|
attr
|
type_cast
(
attr
.
value_for_database
)
}
type_casted_binds
=
type_casted_binds
(
binds
)
log
(
sql
,
name
,
binds
,
type_casted_binds
)
{
@connection
.
async_exec
(
sql
,
type_casted_binds
)
}
end
def
exec_cache
(
sql
,
name
,
binds
)
stmt_key
=
prepare_statement
(
sql
)
type_casted_binds
=
binds
.
map
{
|
attr
|
type_cast
(
attr
.
value_for_database
)
}
type_casted_binds
=
type_casted_binds
(
binds
)
log
(
sql
,
name
,
binds
,
type_casted_binds
,
stmt_key
)
do
@connection
.
exec_prepared
(
stmt_key
,
type_casted_binds
)
...
...
activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
浏览文件 @
d980abdb
...
...
@@ -188,7 +188,7 @@ def explain(arel, binds = [])
end
def
exec_query
(
sql
,
name
=
nil
,
binds
=
[],
prepare:
false
)
type_casted_binds
=
binds
.
map
{
|
attr
|
type_cast
(
attr
.
value_for_database
)
}
type_casted_binds
=
type_casted_binds
(
binds
)
log
(
sql
,
name
,
binds
,
type_casted_binds
)
do
# Don't cache statements if they are not prepared
...
...
@@ -203,7 +203,6 @@ def exec_query(sql, name = nil, binds = [], prepare: false)
ensure
stmt
.
close
end
stmt
=
records
else
cache
=
@statements
[
sql
]
||=
{
:stmt
=>
@connection
.
prepare
(
sql
)
...
...
@@ -212,9 +211,10 @@ def exec_query(sql, name = nil, binds = [], prepare: false)
cols
=
cache
[
:cols
]
||=
stmt
.
columns
stmt
.
reset!
stmt
.
bind_params
(
type_casted_binds
)
records
=
stmt
.
to_a
end
ActiveRecord
::
Result
.
new
(
cols
,
stmt
.
to_a
)
ActiveRecord
::
Result
.
new
(
cols
,
records
)
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录