--- /dev/null
+.. change::
+ :tags: schema, bug
+ :tickets: 10207
+ :versions: 2.0.21
+
+ Modified the rendering of the Oracle only :paramref:`.Identity.order`
+ parameter that's part of both :class:`.Sequence` and :class:`.Identity` to
+ only take place for the Oracle backend, and not other backends such as that
+ of PostgreSQL. A future release will rename the
+ :paramref:`.Identity.order`, :paramref:`.Sequence.order` and
+ :paramref:`.Identity.on_null` parameters to Oracle-specific names,
+ deprecating the old names, these parameters only apply to Oracle.
text = text.replace("NO MINVALUE", "NOMINVALUE")
text = text.replace("NO MAXVALUE", "NOMAXVALUE")
text = text.replace("NO CYCLE", "NOCYCLE")
- text = text.replace("NO ORDER", "NOORDER")
- return text
+ if identity_options.order is not None:
+ text += " ORDER" if identity_options.order else " NOORDER"
+ return text.strip()
def visit_computed_column(self, generated, **kw):
text = "GENERATED ALWAYS AS (%s)" % self.sql_compiler.process(
text.append("NO MAXVALUE")
if identity_options.cache is not None:
text.append("CACHE %d" % identity_options.cache)
- if identity_options.order is not None:
- text.append("ORDER" if identity_options.order else "NO ORDER")
if identity_options.cycle is not None:
text.append("CYCLE" if identity_options.cycle else "NO CYCLE")
return " ".join(text)
schema.CreateTable(t),
"CREATE TABLE t (y INTEGER GENERATED ALWAYS AS IDENTITY "
"(INCREMENT BY 7 START WITH 4 NOMINVALUE NOMAXVALUE "
- "NOORDER NOCYCLE))",
+ "NOCYCLE NOORDER))",
)
def test_column_identity_no_generated(self):
"ALWAYS AS IDENTITY (START WITH 1 MAXVALUE 10 CYCLE)",
),
(
- dict(always=False, cache=1000, order=True),
- "BY DEFAULT AS IDENTITY (CACHE 1000 ORDER)",
- ),
- (dict(order=True, cycle=True), "BY DEFAULT AS IDENTITY (ORDER CYCLE)"),
- (
- dict(order=False, cycle=False),
- "BY DEFAULT AS IDENTITY (NO ORDER NO CYCLE)",
+ dict(always=False, cache=1000, cycle=False),
+ "BY DEFAULT AS IDENTITY (CACHE 1000 NO CYCLE)",
),
+ (dict(cycle=True), "BY DEFAULT AS IDENTITY (CYCLE)"),
)
def test_create_ddl(self, identity_args, text):
if getattr(
text = text.replace("NO MINVALUE", "NOMINVALUE")
text = text.replace("NO MAXVALUE", "NOMAXVALUE")
text = text.replace("NO CYCLE", "NOCYCLE")
- text = text.replace("NO ORDER", "NOORDER")
t = Table(
"foo_table",
Column(
"foo",
Integer(),
- Identity(always=False, on_null=True, start=42, order=True),
+ Identity(always=False, on_null=True, start=42, cycle=True),
),
)
text = " ON NULL" if testing.against("oracle") else ""
(
"CREATE TABLE foo_table (foo INTEGER GENERATED BY DEFAULT"
+ text
- + " AS IDENTITY (START WITH 42 ORDER))"
+ + " AS IDENTITY (START WITH 42 CYCLE))"
),
)
assert_raises_message(ArgumentError, text, fn, server_onupdate="42")
def test_to_metadata(self):
- identity1 = Identity("by default", on_null=True, start=123)
+ identity1 = Identity("by default", cycle=True, start=123)
m = MetaData()
t = Table(
"t", m, Column("x", Integer), Column("y", Integer, identity1)
"START WITH 1 MAXVALUE 10 CYCLE",
),
(
- Sequence("foo_seq", cache=1000, order=True),
- "CACHE 1000 ORDER",
+ Sequence("foo_seq", cache=1000),
+ "CACHE 1000",
),
- (Sequence("foo_seq", order=True), "ORDER"),
(Sequence("foo_seq", minvalue=42), "MINVALUE 42"),
(Sequence("foo_seq", minvalue=-42), "MINVALUE -42"),
(
Sequence("foo_seq", minvalue=42, increment=-2),
"INCREMENT BY -2 MINVALUE 42",
),
+ (
+ # remove this when the `order` parameter is removed
+ # issue #10207 - ensure ORDER does not render
+ Sequence("foo_seq", order=True),
+ "",
+ ),
(
Sequence("foo_seq", minvalue=-42, increment=-2),
"INCREMENT BY -2 MINVALUE -42",