diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-08 11:55:19 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-04-10 18:46:44 +0200 |
commit | 104cdccab69dd0b68a756f5d54126a6b74914408 (patch) | |
tree | e2be6ae3abc6e1c93dd0ae3330e660ea716ed33c /odb/relational/schema.hxx | |
parent | ffdc07d3242e7e9d93f33eb3dc7c294ef79698ff (diff) |
Improve output of columns in PRIMARY KEY, FOREIGN KEY, and REFERENCES
Diffstat (limited to 'odb/relational/schema.hxx')
-rw-r--r-- | odb/relational/schema.hxx | 39 |
1 files 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); } |