unticketed "database.dbo" SQL server feature incorrect?
regarding c94756cce81a940a6a6f09e1fdf8ccfe8d1c45c1 (no ticket ?! wtf?!)
This won't work as it stands. Schemas are themselves allowed to contain a ".", thus running any reflection on a schema "firstname.lastname" crashes (it will try to switch to a database called "firstname" and inspect the schema "lastname")
it needs to be determined how this feature came to be - it is not consistent vs. any other dialect.
Comments (9)
-
Account Deleted -
reporter I'm told, because I don't have time to test, that this is SQL Server's logic:
A.B.C means database A, schema B, table C
"A.B".C means schema "A.B", table C
which means, so far, we are doing the right thing, because "schema" in Table is already widely considered to be more of a "qualifier prefix" rather than a "schema". It's not named well, but at the moment that seems like the only "bug" here.
Supporting a schema name with a dot in it seems like we might use the quote_schema=True flag, or look for quoting within the schema name itself. It kind of depends on how a schema name with a dot in it can work at all, such as in 0.7.
-
reporter The plan is to work like SQL Server does, regexping for [as "quotes" and interpreting that way:
schema="A.B" schema="[A.B](])" schema="[A.B](A.B).[C.D](C.D)"
will need documentation examples too.
-
reporter - changed milestone to 0.8.xx
-
reporter - changed milestone to 0.x.xx
why
[]
? why not just use quotes"
? SQL server allows real quotes too. -
reporter - changed milestone to 1.x.xx
-
reporter this is unnecessary. the quoted_name() construct should be used:
class A(Base): __tablename__ = 'a' id = Column(Integer, primary_key=True) __table_args__ = { "schema": quoted_name("a.b", True) }
we need to modify the above change to make this work - for the moment we'll make quoted_name() override split().
-
reporter ... except then you can't reflect on owner.schema with case sensitivity, because we still need to split.
I think, just make the split use the regexp.
-
reporter - changed status to resolved
Recognize brackets, quoted_name in SQL Server schema
The SQL Server dialect now allows for a database and/or owner name with a dot inside of it, using brackets explicitly in the string around the owner and optionally the database name as well. In addition, sending the :class:
.quoted_name
construct for the schema name will not split on the dot and will deliver the full string as the "owner". :class:.quoted_name
is also now available from thesqlalchemy.sql
import space.Change-Id: I77491d63ce47638bd23787d903ccde2f35a9d43d Fixes:
#2626→ <<cset 9f82afea2595>>
- Log in to comment
(original author: diana) Here's some context from the mailing list (https://groups.google.com/forum/?fromgroups=#!topic/sqlalchemy/ZgCplxbI1Bg)
=== email 1
=== email 2
=== email 3