From b5ea1bff659db653a9ede58bd8989f83a318bc22 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Mon, 20 Jun 2011 19:48:14 +0200 Subject: Correct PostgreSQL schema generation implementation --- odb/relational/pgsql/schema.cxx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/odb/relational/pgsql/schema.cxx b/odb/relational/pgsql/schema.cxx index c3a2a3d..2e4981f 100644 --- a/odb/relational/pgsql/schema.cxx +++ b/odb/relational/pgsql/schema.cxx @@ -20,7 +20,7 @@ namespace relational // Create. // - struct object_columns: relational::object_columns + struct object_columns: relational::object_columns, context { object_columns (base const& x): base (x) {} @@ -29,24 +29,25 @@ namespace relational { if (m.count ("auto")) { - // @@ Is this even vaguely correct? - // - - const sql_type& t (pgsql::context::current ().column_sql_type (m)); + const sql_type& t (column_sql_type (m)); if (t.type == sql_type::INTEGER) - os << " SERIAL"; + os << "SERIAL"; else if (t.type == sql_type::BIGINT) - os << " BIGSERIAL"; + os << "BIGSERIAL"; else { cerr << m.file () << ":" << m.line () << ":" << m.column () - << ": error: auto increment columns must be either of " - << "PostgreSQL type INTEGER or BIGINT" << endl; + << ": error: automatically assigned object ID must map " + << "to PostgreSQL INTEGER or BIGINT" << endl; throw generation_failed (); } } + else + { + base::type (m); + } } }; entry object_columns_; -- cgit v1.1