diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/oracle.py | 10 | ||||
-rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 7 |
3 files changed, 9 insertions, 18 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index f8be94e2d..c820474c4 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -1542,13 +1542,9 @@ class MySQLDialect(default.DefaultDialect): return False def get_default_schema_name(self, connection): - try: - return self._default_schema_name - except AttributeError: - name = self._default_schema_name = \ - connection.execute('SELECT DATABASE()').scalar() - return name - + return connection.execute('SELECT DATABASE()').scalar() + get_default_schema_name = util.cache_decorator(get_default_schema_name) + def table_names(self, connection, schema): """Return a Unicode SHOW TABLES from a given schema.""" diff --git a/lib/sqlalchemy/databases/oracle.py b/lib/sqlalchemy/databases/oracle.py index 0c6e65f72..8a2df7f3b 100644 --- a/lib/sqlalchemy/databases/oracle.py +++ b/lib/sqlalchemy/databases/oracle.py @@ -379,13 +379,9 @@ class OracleDialect(default.DefaultDialect): return name.encode(self.encoding) def get_default_schema_name(self,connection): - try: - return self._default_schema_name - except AttributeError: - name = self._default_schema_name = \ - connection.execute('SELECT USER FROM DUAL').scalar() - return name - + return connection.execute('SELECT USER FROM DUAL').scalar() + get_default_schema_name = util.cache_decorator(get_default_schema_name) + def table_names(self, connection, schema): # note that table_names() isnt loading DBLINKed or synonym'ed tables if schema is None: diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index a34388a89..9dbf359b6 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -367,10 +367,9 @@ class PGDialect(default.DefaultDialect): return [row[0] for row in resultset] def get_default_schema_name(self, connection): - if not hasattr(self, '_default_schema_name'): - self._default_schema_name = connection.scalar("select current_schema()", None) - return self._default_schema_name - + return connection.scalar("select current_schema()", None) + get_default_schema_name = util.cache_decorator(get_default_schema_name) + def last_inserted_ids(self): if self.context.last_inserted_ids is None: raise exceptions.InvalidRequestError("no INSERT executed, or can't use cursor.lastrowid without Postgres OIDs enabled") |