diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2023-01-11 14:40:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2023-01-11 14:40:02 +0200 |
commit | 5652354aa256426c5ab32c4a1c5687e5509af868 (patch) | |
tree | ac59964abb8696c12ec4ea71c56e9219dd4245e6 /odb/relational/mysql/model.cxx | |
parent | 2a7a60a29cc72f07263ec7534732141f8869b5ed (diff) |
Add support for custom table definition options
Diffstat (limited to 'odb/relational/mysql/model.cxx')
-rw-r--r-- | odb/relational/mysql/model.cxx | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/odb/relational/mysql/model.cxx b/odb/relational/mysql/model.cxx index 2ec9d8b..17ed4c0 100644 --- a/odb/relational/mysql/model.cxx +++ b/odb/relational/mysql/model.cxx @@ -110,10 +110,23 @@ namespace relational member_create (base const& x): base (x) {} virtual string - table_options (semantics::data_member&, semantics::type&) + table_options (semantics::data_member& m, semantics::type& c) { + string r (relational::member_create::table_options (m, c)); + string const& engine (options.mysql_engine ()); - return engine != "default" ? "ENGINE=" + engine : ""; + if (engine != "default") + { + // Note: MySQL table options can be separated with spaces. + // + if (!r.empty ()) + r += ' '; + + r += "ENGINE="; + r += engine; + } + + return r; } }; entry<member_create> member_create_; @@ -123,10 +136,23 @@ namespace relational class_ (base const& x): base (x) {} virtual string - table_options (type&) + table_options (type& c) { + string r (relational::class_::table_options (c)); + string const& engine (options.mysql_engine ()); - return engine != "default" ? "ENGINE=" + engine : ""; + if (engine != "default") + { + // Note: MySQL table options can be separated with spaces. + // + if (!r.empty ()) + r += ' '; + + r += "ENGINE="; + r += engine; + } + + return r; } }; entry<class_> class__; |