diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-11-03 17:35:13 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-11-03 17:35:13 +0000 |
| commit | 4b532e208419caa1a7183a602ddf6363c2a26c2d (patch) | |
| tree | bd03453cbe09065b6c8bb12cd9ed12c8fdc84c87 /lib/sqlalchemy/engine | |
| parent | b5af1759dfc02c16440e603737f3ac04f347ac65 (diff) | |
| download | sqlalchemy-4b532e208419caa1a7183a602ddf6363c2a26c2d.tar.gz | |
- dialect.get_default_schema_name(connection) is now
public via dialect.default_schema_name.
[ticket:1571]
Diffstat (limited to 'lib/sqlalchemy/engine')
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 34 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/default.py | 9 |
2 files changed, 32 insertions, 11 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index e541399e8..fac25b699 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -65,11 +65,14 @@ class Dialect(object): server_version_info a tuple containing a version number for the DB backend in use. - This value is only available for supporting dialects, and only for - a dialect that's been associated with a connection pool via - create_engine() or otherwise had its ``initialize()`` method called - with a conneciton. - + This value is only available for supporting dialects, and is + typically populated during the initial connection to the database. + + default_schema_name + the name of the default schema. This value is only available for + supporting dialects, and is typically populated during the + initial connection to the database. + execution_ctx_cls a :class:`ExecutionContext` class used to handle statement execution @@ -327,10 +330,23 @@ class Dialect(object): raise NotImplementedError() - def get_default_schema_name(self, connection): - """Return the string name of the currently selected schema given a :class:`~sqlalchemy.engine.Connection`. + def _get_server_version_info(self, connection): + """Retrieve the server version info from the given connection. + + This is used by the default implementation to populate the + "server_version_info" attribute and is called exactly + once upon first connect. + + """ + + raise NotImplementedError() - DEPRECATED. moving this towards dialect.default_schema_name (not complete). + def _get_default_schema_name(self, connection): + """Return the string name of the currently selected schema from the given connection. + + This is used by the default implementation to populate the + "default_schema_name" attribute and is called exactly + once upon first connect. """ @@ -1427,7 +1443,7 @@ class Engine(Connectable): conn = connection if not schema: try: - schema = self.dialect.get_default_schema_name(conn) + schema = self.dialect.default_schema_name except NotImplementedError: pass try: diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 37afa84ec..a7f6dc4fa 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -101,10 +101,15 @@ class DefaultDialect(base.Dialect): #self.returns_unicode_strings = True def initialize(self, connection): - if hasattr(self, '_get_server_version_info'): + try: self.server_version_info = self._get_server_version_info(connection) - if hasattr(self, '_get_default_schema_name'): + except NotImplementedError: + self.server_version_info = None + try: self.default_schema_name = self._get_default_schema_name(connection) + except NotImplementedError: + self.default_schema_name = None + # Py2K self.returns_unicode_strings = self._check_unicode_returns(connection) # end Py2K |
