From: Gord Thompson Date: Mon, 9 Mar 2020 21:50:53 +0000 (-0400) Subject: Reflect comments from any table accessible by the current user X-Git-Tag: rel_1_4_0b1~481 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c294d356f7cbb22a8da3fc4552a9c4232c3f69a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Reflect comments from any table accessible by the current user 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 --- diff --git a/doc/build/changelog/unreleased_13/5146.rst b/doc/build/changelog/unreleased_13/5146.rst new file mode 100644 index 0000000000..d216c752a8 --- /dev/null +++ b/doc/build/changelog/unreleased_13/5146.rst @@ -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. diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py index f6de4de68f..c89e441b9e 100644 --- a/lib/sqlalchemy/dialects/oracle/base.py +++ b/lib/sqlalchemy/dialects/oracle/base.py @@ -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 """ diff --git a/test/dialect/oracle/test_reflection.py b/test/dialect/oracle/test_reflection.py index 6c36c0a6bb..411ba335c6 100644 --- a/test/dialect/oracle/test_reflection.py +++ b/test/dialect/oracle/test_reflection.py @@ -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 "