]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Reflect comments from any table accessible by the current user
authorGord Thompson <gord@gordthompson.com>
Mon, 9 Mar 2020 21:50:53 +0000 (17:50 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 10 Mar 2020 14:40:41 +0000 (10:40 -0400)
Fixed a reflection bug where table comments could only be retrieved for
tables actually owned by the user but not for tables visible to the user
but owned by someone else.  Pull request courtesy Dave Hirschfeld.

Fixes: #5146
Closes: #5147
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5147
Pull-request-sha: 0651e3bed05923765203b37986a2506dac3e634e

Change-Id: If970fda10d6adf04d926d38df1a567df1de9f7b9

doc/build/changelog/unreleased_13/5146.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/oracle/base.py
test/dialect/oracle/test_reflection.py

diff --git a/doc/build/changelog/unreleased_13/5146.rst b/doc/build/changelog/unreleased_13/5146.rst
new file mode 100644 (file)
index 0000000..d216c75
--- /dev/null
@@ -0,0 +1,7 @@
+.. change::
+    :tags: bug, oracle
+    :tickets: 5146
+
+    Fixed a reflection bug where table comments could only be retrieved for
+    tables actually owned by the user but not for tables visible to the user
+    but owned by someone else.  Pull request courtesy Dave Hirschfeld.
index f6de4de68f4571fdb7d61b8587f16d83c808257f..c89e441b9efa23b0fe8463877fdcd92e183a5470 100644 (file)
@@ -1760,7 +1760,7 @@ class OracleDialect(default.DefaultDialect):
 
         COMMENT_SQL = """
             SELECT comments
-            FROM user_tab_comments
+            FROM all_tab_comments
             WHERE table_name = :table_name
         """
 
index 6c36c0a6bb7f57c41d93c37936ac4f908fdb5ac9..411ba335c687348de28f88b0189a7b4982359a79 100644 (file)
@@ -49,6 +49,8 @@ create table %(test_schema)s.parent(
     data varchar2(50)
 );
 
+COMMENT ON TABLE %(test_schema)s.parent IS 'my table comment';
+
 create table %(test_schema)s.child(
     id integer primary key,
     data varchar2(50),
@@ -189,6 +191,9 @@ drop synonym %(test_schema)s.local_table;
             parent.join(child)
         ).execute().fetchall()
 
+        # check table comment (#5146)
+        eq_(parent.comment, "my table comment")
+
     def test_reflect_local_to_remote(self):
         testing.db.execute(
             "CREATE TABLE localtable (id INTEGER "