--- /dev/null
+.. change::
+ :tags: bug, sql
+ :tickets: 5722
+ :versions: 1.4.0b2
+
+ Properly render ``cycle=False`` and ``order=False`` as ``NO CYCLE`` and
+ ``NO ORDER`` in :class:`_sql.Sequence` and :class:`_sql.Identity`
+ objects.
\ No newline at end of file
text = super(OracleDDLCompiler, self).get_identity_options(
identity_options
)
- return text.replace("NO MINVALUE", "NOMINVALUE").replace(
- "NO MAXVALUE", "NOMAXVALUE"
- )
+ 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
def visit_computed_column(self, generated):
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 True:
- text.append("ORDER")
+ 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")
+ text.append("CYCLE" if identity_options.cycle else "NO CYCLE")
return " ".join(text)
def visit_create_sequence(self, create, prefix=None, **kw):
increment=7,
nominvalue=True,
nomaxvalue=True,
+ cycle=False,
+ order=False,
),
),
)
self.assert_compile(
schema.CreateTable(t),
"CREATE TABLE t (y INTEGER GENERATED ALWAYS AS IDENTITY "
- "(INCREMENT BY 7 START WITH 4 NOMINVALUE NOMAXVALUE))",
+ "(INCREMENT BY 7 START WITH 4 NOMINVALUE NOMAXVALUE "
+ "NOORDER NOCYCLE))",
)
def test_column_identity_no_generated(self):
dict(always=False, cache=1000, order=True),
"BY DEFAULT AS IDENTITY (CACHE 1000 ORDER)",
),
- (dict(order=True), "BY DEFAULT AS IDENTITY (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)",
+ ),
)
def test_create_ddl(self, identity_args, text):
if getattr(self, "__dialect__", None) != "default" and testing.against(
"oracle"
):
- text = text.replace("NO MINVALUE", "NOMINVALUE").replace(
- "NO MAXVALUE", "NOMAXVALUE"
- )
+ 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",