From ffdc07d3242e7e9d93f33eb3dc7c294ef79698ff Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Apr 2013 11:38:51 +0200 Subject: Write NULL/NOT NULL before DEFAULT in generated schemas This way we avoid DEFAULT NULL NULL, except for Oracle which insists on a specific order. --- odb/relational/oracle/schema.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'odb/relational/oracle') diff --git a/odb/relational/oracle/schema.cxx b/odb/relational/oracle/schema.cxx index 298280e..5d0c107 100644 --- a/odb/relational/oracle/schema.cxx +++ b/odb/relational/oracle/schema.cxx @@ -214,6 +214,26 @@ namespace relational create (ac); } + + virtual void + constraints (sema_rel::column& c, sema_rel::primary_key* pk) + { + // Oracle wants DEFAULT before NULL even though we can end + // up with mouthfulls like DEFAULT NULL NULL. + // + if (!c.default_ ().empty ()) + os << " DEFAULT " << c.default_ (); + + null (c); + + // If this is a single-column primary key, generate it inline. + // + if (pk != 0 && pk->contains_size () == 1) + primary_key (); + + if (pk != 0 && pk->auto_ ()) + auto_ (c); + } }; entry create_column_; -- cgit v1.1