Table("some_table", metadata, ..., postgresql_inherits=("t1", "t2", ...))
+For schema-qualified parent table names, use :class:`.quoted_name` with
+``quote=False`` to prevent the dotted name from being quoted as a single
+identifier::
+
+ from sqlalchemy.sql import quoted_name
+
+ Table(
+ "some_table",
+ metadata,
+ ...,
+ postgresql_inherits=quoted_name(
+ "my_schema.some_supertable", quote=False
+ ),
+ )
+
``ON COMMIT``
^^^^^^^^^^^^^
:class:`_schema.Table`, :class:`_schema.Column`, and others.
The class can also be
passed explicitly as the name to any function that receives a name which
- can be quoted. Such as to use the :meth:`_engine.Engine.has_table`
- method with
- an unconditionally quoted name::
+ can be quoted, such as :meth:`.Inspector.has_table` with an
+ unconditionally quoted name::
from sqlalchemy import create_engine
from sqlalchemy import inspect
backend, passing the name exactly as ``"some_table"`` without converting to
upper case.
+ A :class:`.quoted_name` object with ``quote=False`` may be passed to APIs
+ that apply automatic quoting in order to keep the given name unquoted,
+ such as when a PostgreSQL ``INHERITS`` option refers to a schema-qualified
+ table name like ``my_schema.some_table``.
+
"""
__slots__ = "quote", "lower", "upper"
from sqlalchemy.sql import column
from sqlalchemy.sql import literal_column
from sqlalchemy.sql import operators
+from sqlalchemy.sql import quoted_name
from sqlalchemy.sql import table
from sqlalchemy.sql import util as sql_util
from sqlalchemy.sql.functions import GenericFunction
'( "Quote Me", "quote Me Too" )',
)
+ def test_create_table_inherits_schema_qualified_quoted_name(self):
+ m = MetaData()
+ tbl = Table(
+ "atable",
+ m,
+ Column("id", Integer),
+ postgresql_inherits=quoted_name(
+ "my_schema.parent_table", quote=False
+ ),
+ )
+ self.assert_compile(
+ schema.CreateTable(tbl),
+ "CREATE TABLE atable (id INTEGER) "
+ "INHERITS ( my_schema.parent_table )",
+ )
+
def test_create_table_partition_by_list(self):
m = MetaData()
tbl = Table(