Re: [sqlalchemy] Sequences support for CYCLE and MIN/MAX values
Thanks for the info. Since it is NOCYCLE in oracle and NO CYCLE in postgres, I would check the engine.dialect.name in the compile, method correct? if eng.dialect.name == 'oracle': sql += " NOCYCLE" elif eng.dialect.name == 'postgres': sql += " NO CYCLE" else: raise Exception("RSequence is only implemented for Oracle and PostgreSQL!") How do I get a hold of the engine from within a Sequence object? On 3/26/2010 2:26 PM, Michael Bayer wrote: Kent wrote: Any plans to support MINVALUE, MAXVALUE, CYCLE, NOCYCLE for sequences (for both postgres and oracle)? I've implemented a subclass of Sequence myself, but it isn't very elegant, because I'm not familiar enough with the code to know which methods to override for create() output. correction: redefine the compilation for CreateSequence: from sqlalchemy import * from sqlalchemy import schema from sqlalchemy.ext.compiler import compiles class MySeq(Sequence): def __init__(self, *args, **kw): self.cycle = kw.pop('cycle', False) super(MySeq, self).__init__(*args, **kw) @compiles(schema.CreateSequence) def compile(element, compiler, **kw): if isinstance(element.element, MySeq): return "CREATE SEQUENCE %s %s" % (element.element.name, element.element.cycle and "CYCLE" or "") else: return compiler.visit_create_sequence(element) -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Sequences support for CYCLE and MIN/MAX values
Kent wrote: > Any plans to support MINVALUE, MAXVALUE, CYCLE, NOCYCLE for sequences > (for both postgres and oracle)? > > I've implemented a subclass of Sequence myself, but it isn't very > elegant, because I'm not familiar enough with the code to know which > methods to override for create() output. correction: redefine the compilation for CreateSequence: from sqlalchemy import * from sqlalchemy import schema from sqlalchemy.ext.compiler import compiles class MySeq(Sequence): def __init__(self, *args, **kw): self.cycle = kw.pop('cycle', False) super(MySeq, self).__init__(*args, **kw) @compiles(schema.CreateSequence) def compile(element, compiler, **kw): if isinstance(element.element, MySeq): return "CREATE SEQUENCE %s %s" % (element.element.name, element.element.cycle and "CYCLE" or "") else: return compiler.visit_create_sequence(element) > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
Re: [sqlalchemy] Sequences support for CYCLE and MIN/MAX values
Kent wrote: > Any plans to support MINVALUE, MAXVALUE, CYCLE, NOCYCLE for sequences > (for both postgres and oracle)? > > I've implemented a subclass of Sequence myself, but it isn't very > elegant, because I'm not familiar enough with the code to know which > methods to override for create() output. im not familiar with those options but to implement a subclass of Sequence with additional options, you'd also implement a subclass of sqlalchemy.schema.CreateSequence and use @compiles to define its compilation, as in http://www.sqlalchemy.org/docs/reference/ext/compiler.html#dialect-specific-compilation-rules > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to sqlalch...@googlegroups.com. > To unsubscribe from this group, send email to > sqlalchemy+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.