diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-01-24 15:10:22 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-01-24 15:10:22 +0200 |
commit | ce03afff5ef2e8da677def73079864c31c6618d8 (patch) | |
tree | f0dd5ace26fcfb5c16dee9930a70cf274a80cfc0 /odb/relational/processor.cxx | |
parent | 7c9d4543838490670b632c7049bea53d58d78487 (diff) |
Add support for mapping char[N] to CHAR/VARCHAR database types
Also improve query support for arrays (decaying).
Diffstat (limited to 'odb/relational/processor.cxx')
-rw-r--r-- | odb/relational/processor.cxx | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/odb/relational/processor.cxx b/odb/relational/processor.cxx index 3888b1e..6c36e61 100644 --- a/odb/relational/processor.cxx +++ b/odb/relational/processor.cxx @@ -144,19 +144,24 @@ namespace relational if (id_type.empty ()) id_type = database_type (t, hint, true); - if (type.empty ()) - type = database_type (t, hint, false); - if (id_type.empty () && wt != 0) id_type = database_type (*wt, whint, true); + bool null (false); + if (type.empty ()) + type = database_type (t, hint, false, &null); + if (type.empty () && wt != 0) - type = database_type (*wt, whint, false); + type = database_type (*wt, whint, false, &null); // Use id mapping for discriminators. // if (id (m) || discriminator (m)) type = id_type; + // Allow NULL if requested by the default mapping. + // + else if (null && !m.count ("not-null")) + m.set ("null", true); } if (kind == unknown && !type.empty ()) @@ -333,11 +338,17 @@ namespace relational if (type.empty () && wt != 0 && wt->count ("type")) type = wt->get<string> ("type"); + bool null (false); if (type.empty ()) - type = database_type (t, hint, false); + type = database_type (t, hint, false, &null); if (type.empty () && wt != 0) - type = database_type (*wt, wh, false); + type = database_type (*wt, wh, false, &null); + + // Allow NULL if requested by the default mapping. + // + if (null && !m.count (prefix + "-not-null")) + m.set (prefix + "-null", true); } if (!type.empty ()) |