-----------------------
The MSSQL dialect supports clustered indexes (and primary keys) via the
-``mssql_clustered`` option. This option is available to :class:`.Index`,
-:class:`.Table` and :class:`.PrimaryKeyConstraint`.
+``mssql_clustered`` option. This option is available to :class:`.Index`
+and :class:`.PrimaryKeyConstraint`.
To generate a clustered index::
.. versionadded:: 0.8
-To generate a clustered primary key use either::
-
- Table('my_table', metadata,
- Column('x', ..., primary_key=True),
- Column('y', ..., primary_key=True),
- mssql_clustered=True)
-
-or::
+To generate a clustered primary key use::
Table('my_table', metadata,
Column('x', ...),
self.preparer.format_constraint(constraint)
text += "PRIMARY KEY "
- # we allow for mssql_clustered to have been specified directly on a
- # PrimaryKeyConstraint, or specified upon the table object. The latter allows
- # users to tag columns with primary_key=True and still achieve clustering.
- if (constraint.kwargs.get("mssql_clustered") or
- constraint.table.kwargs.get("mssql_clustered")):
+ # support clustered option
+ if constraint.kwargs.get("mssql_clustered"):
text += "CLUSTERED "
text += "(%s)" % ', '.join(self.preparer.quote(c.name)
"CREATE TABLE test (id INTEGER NOT NULL IDENTITY(1,1))"
)
- def test_table_pkc_clustering_1(self):
- metadata = MetaData()
- tbl = Table('test', metadata,
- Column('x', Integer, primary_key=True, autoincrement=False),
- Column('y', Integer, primary_key=True, autoincrement=False),
- mssql_clustered=True)
- self.assert_compile(schema.CreateTable(tbl),
- "CREATE TABLE test (x INTEGER NOT NULL, y INTEGER NOT NULL, "
- "PRIMARY KEY CLUSTERED (x, y))"
- )
-
- def test_table_pkc_clustering_2(self):
+ def test_table_pkc_clustering(self):
metadata = MetaData()
tbl = Table('test', metadata,
Column('x', Integer, autoincrement=False),