diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-22 14:49:29 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-07-22 17:57:00 +0200 |
commit | 81ea37904e4959414b53b225b4b5e56e1b561bdc (patch) | |
tree | 6ae70d4adb9c0c3ed57679873de8061d5b9c5b19 /odb/relational/sqlite | |
parent | 246b1557bf84082cc72ec2cbe089262b21c8bc97 (diff) |
Add pragma for setting type's or member's default value
New pragma: default. New test: default.
Diffstat (limited to 'odb/relational/sqlite')
-rw-r--r-- | odb/relational/sqlite/schema.cxx | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/odb/relational/sqlite/schema.cxx b/odb/relational/sqlite/schema.cxx index 195a71e..253772d 100644 --- a/odb/relational/sqlite/schema.cxx +++ b/odb/relational/sqlite/schema.cxx @@ -19,11 +19,35 @@ namespace relational // // Create. // - struct object_columns: relational::object_columns + struct object_columns: relational::object_columns, context { object_columns (base const& x): base (x) {} virtual void + default_enum (semantics::data_member& m, tree en, string const&) + { + // Make sure the column is mapped to INTEGER. + // + if (column_sql_type (m).type != sql_type::INTEGER) + { + cerr << m.file () << ":" << m.line () << ":" << m.column () + << ": error: column with default value specified as C++ " + << "enumerator must map to SQLite INTEGER" << endl; + + throw generation_failed (); + } + + using semantics::enumerator; + + enumerator& e (dynamic_cast<enumerator&> (*unit.find (en))); + + if (e.enum_ ().unsigned_ ()) + os << " DEFAULT " << e.value (); + else + os << " DEFAULT " << static_cast<long long> (e.value ()); + } + + virtual void constraints (semantics::data_member& m) { base::constraints (m); |