Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
43bbb25d
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 搜索 >>
提交
43bbb25d
编写于
10月 15, 2010
作者:
A
Aaron Patterson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bind substitution is working properly
上级
9d46e0d0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
7 deletion
+19
-7
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+11
-7
activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
...test/cases/adapters/postgresql/postgresql_adapter_test.rb
+8
-0
未找到文件。
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
43bbb25d
...
...
@@ -228,7 +228,7 @@ def initialize(connection, logger, connection_parameters, config)
def
clear_cache!
@statements
.
each_value
do
|
value
|
exec
"DEALLOCATE
#{
value
}
"
@connection
.
query
"DEALLOCATE
#{
value
}
"
end
@statements
.
clear
end
...
...
@@ -251,6 +251,7 @@ def active?
def
reconnect!
if
@connection
.
respond_to?
(
:reset
)
@connection
.
reset
clear_cache!
configure_connection
else
disconnect!
...
...
@@ -515,6 +516,10 @@ def execute(sql, name = nil)
end
end
def
substitute_for
(
column
,
current_values
)
Arel
.
sql
(
"$
#{
current_values
.
length
+
1
}
"
)
end
def
exec
(
sql
,
name
=
'SQL'
,
binds
=
[])
return
async_exec
(
sql
,
name
,
binds
)
if
@async
...
...
@@ -537,7 +542,9 @@ def async_exec(sql, name, binds)
})
@connection
.
block
result
=
@connection
.
get_last_result
ActiveRecord
::
Result
.
new
(
result
.
fields
,
result_as_array
(
result
))
ret
=
ActiveRecord
::
Result
.
new
(
result
.
fields
,
result_as_array
(
result
))
result
.
clear
return
ret
end
end
...
...
@@ -1014,11 +1021,8 @@ def last_insert_id(table, sequence_name) #:nodoc:
# Executes a SELECT query and returns the results, performing any data type
# conversions that are required to be performed here instead of in PostgreSQLColumn.
def
select
(
sql
,
name
=
nil
)
fields
,
rows
=
select_raw
(
sql
,
name
)
rows
.
map
do
|
row
|
Hash
[
fields
.
zip
(
row
)]
end
def
select
(
sql
,
name
=
nil
,
binds
=
[])
exec
(
sql
,
name
,
binds
).
to_a
end
def
select_raw
(
sql
,
name
=
nil
)
...
...
activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
浏览文件 @
43bbb25d
...
...
@@ -55,6 +55,14 @@ def test_exec_typecasts_bind_vals
assert_equal
[[
'1'
,
'foo'
]],
result
.
rows
end
def
test_substitute_for
bind
=
@connection
.
substitute_for
(
nil
,
[])
assert_equal
Arel
.
sql
(
'$1'
),
bind
bind
=
@connection
.
substitute_for
(
nil
,
[
nil
])
assert_equal
Arel
.
sql
(
'$2'
),
bind
end
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录