Skip to content

detect oracle pure-quoted lowercase names #3548

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

diff --git a/test/dialect/test_oracle.py b/test/dialect/test_oracle.py
index e080568..32dce9c 100644
--- a/test/dialect/test_oracle.py
+++ b/test/dialect/test_oracle.py
@@ -5,6 +5,7 @@ from sqlalchemy.testing import eq_
 from sqlalchemy import *
 from sqlalchemy import types as sqltypes, exc, schema
 from sqlalchemy.sql import table, column
+from sqlalchemy.sql.elements import quoted_name
 from sqlalchemy.testing import fixtures, AssertsExecutionResults, AssertsCompiledSQL
 from sqlalchemy import testing
 from sqlalchemy.util import u, b
@@ -1859,6 +1860,27 @@ class TableReflectionTest(fixtures.TestBase):
         tbl = Table('test_compress', m2, autoload=True)
         assert tbl.dialect_options['oracle']['compress'] == "OLTP"
 
+    @testing.provide_metadata
+    def test_reflect_lowercase_forced_tables(self):
+        metadata = self.metadata
+
+        t1 = Table(quoted_name('t1', quote=True), metadata, 
+             Column('id', Integer, primary_key=True),
+        )
+        t2 = Table(quoted_name('t2', quote=True), metadata, 
+             Column('id', Integer, primary_key=True),
+             Column('t1id', ForeignKey('t1.id'))
+        )
+        metadata.create_all()
+
+        m2 = MetaData(testing.db)
+        t2_ref = Table(quoted_name('t2', quote=True), m2, autoload=True)
+        t1_ref = m2.tables['t1']
+        assert t2_ref.c.t1id.references(t1_ref.c.id)
+
+        m3 = MetaData(testing.db)
+        m3.reflect(only=lambda name, m: name.lower() in ('t1', 't2'))
+        assert m3.tables['t2'].c.t1id.references(m3.tables['t1'].c.id)
 

at some point this would apply to firebird as well...

Activity

sqlalchemy-bot

sqlalchemy-bot commented on Oct 5, 2015

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

  • Fixed bug in Oracle dialect where reflection of tables and other
    symbols with names quoted to force all-lower-case would not be
    identified properly in reflection queries. The :class:.quoted_name
    construct is now applied to incoming symbol names that detect as
    forced into all-lower-case within the "name normalize" process.
    fixes detect oracle pure-quoted lowercase names #3548

4578ab5

sqlalchemy-bot

sqlalchemy-bot commented on Oct 5, 2015

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

  • Fixed bug in Oracle dialect where reflection of tables and other
    symbols with names quoted to force all-lower-case would not be
    identified properly in reflection queries. The :class:.quoted_name
    construct is now applied to incoming symbol names that detect as
    forced into all-lower-case within the "name normalize" process.
    fixes detect oracle pure-quoted lowercase names #3548

(cherry picked from commit 4578ab5)

0b8489f

sqlalchemy-bot

sqlalchemy-bot commented on Oct 5, 2015

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
sqlalchemy-bot

sqlalchemy-bot commented on Nov 16, 2016

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

we should do this for firebird also, same issue

sqlalchemy-bot

sqlalchemy-bot commented on Nov 16, 2016

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to reopened
sqlalchemy-bot

sqlalchemy-bot commented on Nov 16, 2016

@sqlalchemy-bot
CollaboratorAuthor
sqlalchemy-bot

sqlalchemy-bot commented on Nov 16, 2016

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

Port lower case quoted name fix to firebird

Ported the fix for Oracle quoted-lowercase names to Firebird, so that
a table name that is quoted as lower case can be reflected properly
including when the table name comes from the get_table_names()
inspection function.

Also genericize the test to the test suite for denormlized name
dialects.

Fixes: #3548

Change-Id: I8ca62e8d2b359e363ccb01cfe2daa0995354a3cb

68d3018

sqlalchemy-bot

sqlalchemy-bot commented on Nov 16, 2016

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added this to the 1.0.9 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingoracle

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          detect oracle pure-quoted lowercase names · Issue #3548 · sqlalchemy/sqlalchemy