From 923639283d2bae0b82cb605fa4680a3058c9d973 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 25 Jul 2012 12:13:38 +0200 Subject: Add support for defining indexes New db pragma qualifier: index. New tests: common/index, mysql/index, pgsql/index. --- odb/relational/schema.hxx | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'odb/relational/schema.hxx') diff --git a/odb/relational/schema.hxx b/odb/relational/schema.hxx index 6551119..e6d4824 100644 --- a/odb/relational/schema.hxx +++ b/odb/relational/schema.hxx @@ -494,13 +494,10 @@ namespace relational } virtual void - create (sema_rel::index& in) + columns (sema_rel::index& in) { using sema_rel::index; - os << "CREATE INDEX " << name (in) << endl - << " ON " << table_name (in) << " ("; - for (index::contains_iterator i (in.contains_begin ()); i != in.contains_end (); ++i) @@ -515,9 +512,31 @@ namespace relational } os << quote_id (i->column ().name ()); + + if (!i->options ().empty ()) + os << ' ' << i->options (); } + } + + virtual void + create (sema_rel::index& in) + { + // Default implementation that ignores the method. + // + os << "CREATE "; + + if (!in.type ().empty ()) + os << in.type () << ' '; + + os << "INDEX " << name (in) << endl + << " ON " << table_name (in) << " ("; + + columns (in); os << ")" << endl; + + if (!in.options ().empty ()) + os << ' ' << in.options () << endl; } protected: -- cgit v1.1