diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2018-11-26 19:45:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-26 19:45:05 +0100 |
| commit | f091ea35150d95fc6732bbf0c27b971dd445509a (patch) | |
| tree | 254bdd5fee37cacef75eec92614f0e89fa4233ec /django | |
| parent | 26c2a6ff883a213b4dcadf4411740aff866153ac (diff) | |
Refs #29722 -- Added introspection of materialized views for Oracle.
Thanks Tim Graham for the review.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/backends/base/features.py | 3 | ||||
| -rw-r--r-- | django/db/backends/oracle/creation.py | 13 | ||||
| -rw-r--r-- | django/db/backends/oracle/features.py | 1 | ||||
| -rw-r--r-- | django/db/backends/oracle/introspection.py | 16 | ||||
| -rw-r--r-- | django/db/backends/postgresql/features.py | 1 |
5 files changed, 27 insertions, 7 deletions
diff --git a/django/db/backends/base/features.py b/django/db/backends/base/features.py index e07adb970d..56f7d4fb6a 100644 --- a/django/db/backends/base/features.py +++ b/django/db/backends/base/features.py @@ -151,6 +151,9 @@ class BaseDatabaseFeatures: # Can the backend introspect the column order (ASC/DESC) for indexes? supports_index_column_ordering = True + # Does the backend support introspection of materialized views? + can_introspect_materialized_views = False + # Support for the DISTINCT ON clause can_distinct_on_fields = False diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py index 98ea186dcb..741a03ae0e 100644 --- a/django/db/backends/oracle/creation.py +++ b/django/db/backends/oracle/creation.py @@ -241,11 +241,14 @@ class DatabaseCreation(BaseDatabaseCreation): if not success and self._test_settings_get('PASSWORD') is None: set_password = 'ALTER USER %(user)s IDENTIFIED BY "%(password)s"' self._execute_statements(cursor, [set_password], parameters, verbosity) - # Most test-suites can be run without the create-view privilege. But some need it. - extra = "GRANT CREATE VIEW TO %(user)s" - success = self._execute_allow_fail_statements(cursor, [extra], parameters, verbosity, 'ORA-01031') - if not success and verbosity >= 2: - self.log('Failed to grant CREATE VIEW permission to test user. This may be ok.') + # Most test suites can be run without "create view" and + # "create materialized view" privileges. But some need it. + for object_type in ('VIEW', 'MATERIALIZED VIEW'): + extra = 'GRANT CREATE %(object_type)s TO %(user)s' + parameters['object_type'] = object_type + success = self._execute_allow_fail_statements(cursor, [extra], parameters, verbosity, 'ORA-01031') + if not success and verbosity >= 2: + self.log('Failed to grant CREATE %s permission to test user. This may be ok.' % object_type) def _execute_test_db_destruction(self, cursor, parameters, verbosity): if verbosity >= 2: diff --git a/django/db/backends/oracle/features.py b/django/db/backends/oracle/features.py index 7e288e9840..7c72831c25 100644 --- a/django/db/backends/oracle/features.py +++ b/django/db/backends/oracle/features.py @@ -21,6 +21,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): truncates_names = True supports_tablespaces = True supports_sequence_reset = False + can_introspect_materialized_views = True can_introspect_time_field = False atomic_transactions = False supports_combined_alters = False diff --git a/django/db/backends/oracle/introspection.py b/django/db/backends/oracle/introspection.py index 51566365bc..29193f0507 100644 --- a/django/db/backends/oracle/introspection.py +++ b/django/db/backends/oracle/introspection.py @@ -48,8 +48,20 @@ class DatabaseIntrospection(BaseDatabaseIntrospection): def get_table_list(self, cursor): """Return a list of table and view names in the current database.""" - cursor.execute("SELECT TABLE_NAME, 't' FROM USER_TABLES UNION ALL " - "SELECT VIEW_NAME, 'v' FROM USER_VIEWS") + cursor.execute(""" + SELECT table_name, 't' + FROM user_tables + WHERE + NOT EXISTS ( + SELECT 1 + FROM user_mviews + WHERE user_mviews.mview_name = user_tables.table_name + ) + UNION ALL + SELECT view_name, 'v' FROM user_views + UNION ALL + SELECT mview_name, 'v' FROM user_mviews + """) return [TableInfo(self.identifier_converter(row[0]), row[1]) for row in cursor.fetchall()] def get_table_description(self, cursor, table_name): diff --git a/django/db/backends/postgresql/features.py b/django/db/backends/postgresql/features.py index 89ff06fdf5..5c8701c396 100644 --- a/django/db/backends/postgresql/features.py +++ b/django/db/backends/postgresql/features.py @@ -21,6 +21,7 @@ class DatabaseFeatures(BaseDatabaseFeatures): supports_transactions = True can_introspect_autofield = True can_introspect_ip_address_field = True + can_introspect_materialized_views = True can_introspect_small_integer_field = True can_distinct_on_fields = True can_rollback_ddl = True |
