--- /dev/null
+.. change::
+ :tags: bug, oracle, reflection
+ :tickets: 5146
+
+ Fixed regression / incorrect fix caused by fix for :ticket:`5146` where the
+ Oracle dialect reads from the "all_tab_comments" view to get table comments
+ but fails to accommodate for the current owner of the table being
+ requested, causing it to read the wrong comment if multiple tables of the
+ same name exist in multiple schemas.
+
info_cache=info_cache,
)
+ if not schema:
+ schema = self.default_schema_name
+
COMMENT_SQL = """
SELECT comments
FROM all_tab_comments
- WHERE table_name = :table_name
+ WHERE table_name = :table_name AND owner = :schema_name
"""
- c = connection.execute(sql.text(COMMENT_SQL), table_name=table_name)
+ c = connection.execute(
+ sql.text(COMMENT_SQL), table_name=table_name, schema_name=schema
+ )
return {"text": c.scalar()}
@reflection.cache
# check table comment (#5146)
eq_(parent.comment, "my table comment")
+ @testing.provide_metadata
+ def test_reflect_table_comment(self):
+ local_parent = Table(
+ "parent",
+ self.metadata,
+ Column("q", Integer),
+ comment="my local comment",
+ )
+
+ local_parent.create(testing.db)
+
+ insp = inspect(testing.db)
+ eq_(
+ insp.get_table_comment(
+ "parent", schema=testing.config.test_schema
+ ),
+ {"text": "my table comment"},
+ )
+ eq_(insp.get_table_comment("parent",), {"text": "my local comment"})
+ eq_(
+ insp.get_table_comment(
+ "parent", schema=testing.db.dialect.default_schema_name
+ ),
+ {"text": "my local comment"},
+ )
+
def test_reflect_local_to_remote(self):
testing.db.execute(
"CREATE TABLE localtable (id INTEGER "