From 104cdccab69dd0b68a756f5d54126a6b74914408 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 8 Apr 2013 11:55:19 +0200 Subject: Improve output of columns in PRIMARY KEY, FOREIGN KEY, and REFERENCES --- odb/relational/schema.hxx | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/odb/relational/schema.hxx b/odb/relational/schema.hxx index ed0084e..146e526 100644 --- a/odb/relational/schema.hxx +++ b/odb/relational/schema.hxx @@ -617,14 +617,9 @@ namespace relational i != pk.contains_end (); ++i) { - if (pk.contains_size () > 1) - { - if (i != pk.contains_begin ()) - os << ","; - - os << endl - << " "; - } + if (i != pk.contains_begin ()) + os << "," << endl + << " "; os << quote_id (i->column ().name ()); } @@ -735,35 +730,27 @@ namespace relational i != fk.contains_end (); ++i) { - if (fk.contains_size () > 1) - { - if (i != fk.contains_begin ()) - os << ","; - - os << endl - << " "; - } + if (i != fk.contains_begin ()) + os << "," << endl + << " "; os << quote_id (i->column ().name ()); } + string tn (table_name (fk)); + string tn_pad (tn.size (), ' '); + os << ")" << endl - << " REFERENCES " << table_name (fk) << " ("; + << " REFERENCES " << tn << " ("; foreign_key::columns const& refs (fk.referenced_columns ()); - for (foreign_key::columns::const_iterator i (refs.begin ()); i != refs.end (); ++i) { - if (refs.size () > 1) - { - if (i != refs.begin ()) - os << ","; - - os << endl - << " "; - } + if (i != refs.begin ()) + os << "," << endl + << " " << tn_pad; os << quote_id (*i); } -- cgit v1.1