Added by Plug Gulp over 3 years ago
How do I specify a not null constraint on a field? I don't see any option to specify that in the Wt::Dbo::field
function. Is there any other way to do that?
I believe that Dbo will create table fields as not null by default. This can be seen in the generated SQL in https://www.webtoolkit.eu/wt/doc/tutorial/dbo.html. However, you can declare a field with std::optional (or boost::optional) to indicate that null values are supported. See the "Detailed Description" section under: https://www.webtoolkit.eu/wt/doc/reference/html/structWt_1_1Dbo_1_1sql_*value*_traits.html. There are also some usage examples with optional types in the Wt source in test/dbo/DboTest.C.