diff options
Diffstat (limited to 'evolution')
-rw-r--r-- | evolution/alter-column/driver.cxx | 15 | ||||
-rw-r--r-- | evolution/alter-column/model.hxx | 9 |
2 files changed, 20 insertions, 4 deletions
diff --git a/evolution/alter-column/driver.cxx b/evolution/alter-column/driver.cxx index 28e6e7c..193289f 100644 --- a/evolution/alter-column/driver.cxx +++ b/evolution/alter-column/driver.cxx @@ -63,11 +63,13 @@ main (int argc, char* argv[]) assert (!p->str); assert (p->num && *p->num == 123); + assert (!p->num1); // Migration. // p->str = "abc"; p->num.reset (); + p->num1 = 123; db->update (*p); t.commit (); @@ -93,12 +95,25 @@ main (int argc, char* argv[]) try { object o2 (2); + o2.num1 = 234; // str is NULL transaction t (db->begin ()); db->persist (o2); assert (false); } catch (const odb::exception& ) {} + + try + { + object o3 (3); + o3.str = "bcd"; // num1 is NULL + + transaction t (db->begin ()); + db->persist (o3); + assert (false); + } + catch (const odb::exception& ) {} + break; } default: diff --git a/evolution/alter-column/model.hxx b/evolution/alter-column/model.hxx index c244eb0..0b31e1c 100644 --- a/evolution/alter-column/model.hxx +++ b/evolution/alter-column/model.hxx @@ -30,9 +30,6 @@ namespace MODEL_NAMESPACE(MODEL_VERSION) odb::nullable<std::string> str; unsigned long num; - - #pragma db null - unsigned long dummy; // Test multiple ALTER COLUMN clauses. #else // Use nullable to be able to access during migration. // @@ -41,7 +38,11 @@ namespace MODEL_NAMESPACE(MODEL_VERSION) odb::nullable<unsigned long> num; - unsigned long dummy; + // Test adding NOT NULL column. It should be added NULL in pre + // and then converted to NOT NULL in post. + // + #pragma db not_null + odb::nullable<unsigned long> num1; #endif }; } |