-
Notifications
You must be signed in to change notification settings - Fork 419
Add rudimentary server capability detection. #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
asyncpg/connection.py
Outdated
if self._server_version < (9, 2): | ||
self._intro_query = introspection.INTRO_LOOKUP_TYPES_91 | ||
else: | ||
self._intro_query = introspection.INTRO_LOOKUP_TYPES | ||
|
||
_reset_query = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you factor this code into a separate method _get_reset_query()
? I'd also only call it from Connection.reset()
(only pooled connections are likely to ever call reset()
).
asyncpg/capabilities.py
Outdated
@@ -0,0 +1,37 @@ | |||
|
|||
# Copyright (C) 2016-present the ayncpg authors and contributors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017?
asyncpg/capabilities.py
Outdated
ServerCapabilities.__doc__ = 'PostgreSQL server capabilities.' | ||
|
||
|
||
def detect_server_capabilities(server_version, connection_settings): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this method private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
a317d2e
to
b9ad3c3
Compare
asyncpg/connection.py
Outdated
def _detect_server_capabilities(server_version, connection_settings): | ||
if hasattr(connection_settings, 'crdb_version'): | ||
# CocroachDB detected. | ||
advisory_locks = cursors = notifications = plpgsql = sql_reset = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make it a multiline assignment. Will minimize the diff when we need to add a new one.
b9ad3c3
to
05375ed
Compare
Add basic server capability detection mechanism based on server version and parameters reported by the server through ParameterStatus messages. This allows altering certain asyncpg behaviour based on the connected server. Specifically, this allows asyncpg to connect to CochroachDB servers. Fixes #87.
05375ed
to
32d72c0
Compare
Add basic server capability detection mechanism based on server version
and parameters reported by the server through ParameterStatus messages.
This allows altering certain asyncpg behaviour based on the connected
server.
Specifically, this allows asyncpg to connect to CockroachDB servers.
Fixes #87.