Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
911f44f7
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,发现更多精彩内容 >>
提交
911f44f7
编写于
3月 23, 2017
作者:
M
Matthew Draper
提交者:
GitHub
3月 23, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #28522 from larskanis/replace-deprecated-pg-constants
[PostgreSQL] Replace deprecated PG constants.
上级
22deb922
f28a3310
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
21 addition
and
21 deletion
+21
-21
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
...lib/active_record/connection_adapters/abstract_adapter.rb
+1
-1
activerecord/lib/active_record/connection_adapters/postgresql/oid/bytea.rb
...active_record/connection_adapters/postgresql/oid/bytea.rb
+1
-1
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
...b/active_record/connection_adapters/postgresql/quoting.rb
+3
-3
activerecord/lib/active_record/connection_adapters/postgresql/utils.rb
...lib/active_record/connection_adapters/postgresql/utils.rb
+2
-2
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
...b/active_record/connection_adapters/postgresql_adapter.rb
+9
-9
activerecord/lib/active_record/transactions.rb
activerecord/lib/active_record/transactions.rb
+1
-1
activerecord/test/cases/adapters/postgresql/statement_pool_test.rb
...ord/test/cases/adapters/postgresql/statement_pool_test.rb
+4
-4
未找到文件。
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
浏览文件 @
911f44f7
...
...
@@ -439,7 +439,7 @@ def verify!(*ignored)
# Provides access to the underlying database driver for this adapter. For
# example, this method returns a Mysql2::Client object in case of Mysql2Adapter,
# and a PG
con
n object in case of PostgreSQLAdapter.
# and a PG
::Connectio
n object in case of PostgreSQLAdapter.
#
# This is useful for when you need to call a proprietary method such as
# PostgreSQL's lo_* methods.
...
...
activerecord/lib/active_record/connection_adapters/postgresql/oid/bytea.rb
浏览文件 @
911f44f7
...
...
@@ -6,7 +6,7 @@ class Bytea < Type::Binary # :nodoc:
def
deserialize
(
value
)
return
if
value
.
nil?
return
value
.
to_s
if
value
.
is_a?
(
Type
::
Binary
::
Data
)
PG
con
n
.
unescape_bytea
(
super
)
PG
::
Connectio
n
.
unescape_bytea
(
super
)
end
end
end
...
...
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
浏览文件 @
911f44f7
...
...
@@ -33,7 +33,7 @@ def quote_table_name(name) # :nodoc:
# Quotes schema names for use in SQL queries.
def
quote_schema_name
(
name
)
PG
con
n
.
quote_ident
(
name
)
PG
::
Connectio
n
.
quote_ident
(
name
)
end
def
quote_table_name_for_assignment
(
table
,
attr
)
...
...
@@ -42,7 +42,7 @@ def quote_table_name_for_assignment(table, attr)
# Quotes column names for use in SQL queries.
def
quote_column_name
(
name
)
# :nodoc:
@quoted_column_names
[
name
]
||=
PG
con
n
.
quote_ident
(
super
).
freeze
@quoted_column_names
[
name
]
||=
PG
::
Connectio
n
.
quote_ident
(
super
).
freeze
end
# Quote date/time values for use in SQL input.
...
...
@@ -105,7 +105,7 @@ def _type_cast(value)
case
value
when
Type
::
Binary
::
Data
# Return a bind param hash with format as binary.
# See http
://deveiate.org/code/pg/PGcon
n.html#method-i-exec_prepared-doc
# See http
s://deveiate.org/code/pg/PG/Connectio
n.html#method-i-exec_prepared-doc
# for more information
{
value:
value
.
to_s
,
format:
1
}
when
OID
::
Xml
::
Data
,
OID
::
Bit
::
Data
...
...
activerecord/lib/active_record/connection_adapters/postgresql/utils.rb
浏览文件 @
911f44f7
...
...
@@ -19,9 +19,9 @@ def to_s
def
quoted
if
schema
PG
conn
.
quote_ident
(
schema
)
<<
SEPARATOR
<<
PGcon
n
.
quote_ident
(
identifier
)
PG
::
Connection
.
quote_ident
(
schema
)
<<
SEPARATOR
<<
PG
::
Connectio
n
.
quote_ident
(
identifier
)
else
PG
con
n
.
quote_ident
(
identifier
)
PG
::
Connectio
n
.
quote_ident
(
identifier
)
end
end
...
...
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
浏览文件 @
911f44f7
...
...
@@ -29,11 +29,11 @@ def postgresql_connection(config)
conn_params
[
:user
]
=
conn_params
.
delete
(
:username
)
if
conn_params
[
:username
]
conn_params
[
:dbname
]
=
conn_params
.
delete
(
:database
)
if
conn_params
[
:database
]
# Forward only valid config params to PG
con
n.connect.
valid_conn_param_keys
=
PG
con
n
.
conndefaults_hash
.
keys
+
[
:requiressl
]
# Forward only valid config params to PG
::Connectio
n.connect.
valid_conn_param_keys
=
PG
::
Connectio
n
.
conndefaults_hash
.
keys
+
[
:requiressl
]
conn_params
.
slice!
(
*
valid_conn_param_keys
)
# The postgres drivers don't allow the creation of an unconnected PG
con
n object,
# The postgres drivers don't allow the creation of an unconnected PG
::Connectio
n object,
# so just pass a nil connection object for the time being.
ConnectionAdapters
::
PostgreSQLAdapter
.
new
(
nil
,
logger
,
conn_params
,
config
)
end
...
...
@@ -201,8 +201,8 @@ def dealloc(key)
end
def
connection_active?
@connection
.
status
==
PG
conn
::
CONNECTION_OK
rescue
PGError
@connection
.
status
==
PG
::
CONNECTION_OK
rescue
PG
::
Error
false
end
end
...
...
@@ -249,7 +249,7 @@ def truncate(table_name, name = nil)
def
active?
@connection
.
query
"SELECT 1"
true
rescue
PGError
rescue
PG
::
Error
false
end
...
...
@@ -414,7 +414,7 @@ def default_index_type?(index) # :nodoc:
def
translate_exception
(
exception
,
message
)
return
exception
unless
exception
.
respond_to?
(
:result
)
case
exception
.
result
.
try
(
:error_field
,
PG
result
::
PG_DIAG_SQLSTATE
)
case
exception
.
result
.
try
(
:error_field
,
PG
::
PG_DIAG_SQLSTATE
)
when
UNIQUE_VIOLATION
RecordNotUnique
.
new
(
message
)
when
FOREIGN_KEY_VIOLATION
...
...
@@ -651,7 +651,7 @@ def exec_cache(sql, name, binds)
CACHED_PLAN_HEURISTIC
=
"cached plan must not change result type"
.
freeze
def
is_cached_plan_failure?
(
e
)
pgerror
=
e
.
cause
code
=
pgerror
.
result
.
result_error_field
(
PG
result
::
PG_DIAG_SQLSTATE
)
code
=
pgerror
.
result
.
result_error_field
(
PG
::
PG_DIAG_SQLSTATE
)
code
==
FEATURE_NOT_SUPPORTED
&&
pgerror
.
message
.
include?
(
CACHED_PLAN_HEURISTIC
)
rescue
false
...
...
@@ -690,7 +690,7 @@ def prepare_statement(sql)
# Connects to a PostgreSQL server and sets up the adapter depending on the
# connected server's characteristics.
def
connect
@connection
=
PG
conn
.
connect
(
@connection_parameters
)
@connection
=
PG
.
connect
(
@connection_parameters
)
configure_connection
rescue
::
PG
::
Error
=>
error
if
error
.
message
.
include?
(
"does not exist"
)
...
...
activerecord/lib/active_record/transactions.rb
浏览文件 @
911f44f7
...
...
@@ -123,7 +123,7 @@ module Transactions
# # statement will cause a PostgreSQL error, even though the unique
# # constraint is no longer violated:
# Number.create(i: 1)
# # => "PGError: ERROR: current transaction is aborted, commands
# # => "PG
::
Error: ERROR: current transaction is aborted, commands
# # ignored until end of transaction block"
# end
#
...
...
activerecord/test/cases/adapters/postgresql/statement_pool_test.rb
浏览文件 @
911f44f7
...
...
@@ -3,13 +3,13 @@
module
ActiveRecord
module
ConnectionAdapters
class
PostgreSQLAdapter
<
AbstractAdapter
class
InactiveP
Gcon
n
class
InactiveP
gConnectio
n
def
query
(
*
args
)
raise
PGError
raise
PG
::
Error
end
def
status
PG
conn
::
CONNECTION_BAD
PG
::
CONNECTION_BAD
end
end
...
...
@@ -31,7 +31,7 @@ def test_cache_is_per_pid
end
def
test_dealloc_does_not_raise_on_inactive_connection
cache
=
StatementPool
.
new
InactiveP
Gcon
n
.
new
,
10
cache
=
StatementPool
.
new
InactiveP
gConnectio
n
.
new
,
10
cache
[
"foo"
]
=
"bar"
assert_nothing_raised
{
cache
.
clear
}
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录