On 04/26/2016 06:27 AM, Piotr Dobrogost wrote:
Do I see right, that using @compiles(schema.CreateColumn, 'oracle') is not good as it's being invoked too late to have access to colspec? It seems I have to override DDLCompiler.get_column_specification() and then I have to copy & paste code from this method because there's no way to reuse code which generates DEFAULT and NULL statements, yes? Overriding DDLCompiler.get_column_specification() means I subsequently have to "register" my DDLCompiler's subclass somehow. How do I do it? I did not find any information on this in docs. Looking at PGDialect in source, there's ddl_compiler attribute but I don't see any API to change it. You don't want me to monkey patch OracleDialect, do you?.
So first we'll take a breath....breathe...and we're back. The best thing about air is that it's in most places we live and it's free. So going back to the link I sent, http://docs.sqlalchemy.org/en/rel_1_0/core/ddl.html?highlight=createtable#sqlalchemy.schema.CreateColumn , scroll down and the second example illustrates how to get the default DDL for the column, as rendered by the current compiler, here is a 5 second adaptation of that:
from sqlalchemy.schema import CreateColumn @compiles(CreateColumn, "oracle") def _do_thing(element, compiler, **kw): text = compiler.visit_create_column(element, **kw) text = text.replace("NOT NULL", "NULL") return text I hope this helps.
Regards, Piotr Dobrogost ps. I have an impression there's hardly any traffic on #sqlalchemy during Europe's working hours :(
-- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.