test/lib/random_schema: type_generator(): don't generate duration_type for keys

And for any embedded type (collection, tuple members, etc.).
Its not allowed as I recently learned it.
This commit is contained in:
Botond Dénes
2023-01-13 10:41:54 -05:00
parent c9f54e539d
commit 2a7cccd1a8

View File

@@ -103,7 +103,17 @@ type_generator::type_generator(random_schema_specification& spec) : _spec(spec)
data_type type_generator::operator()(std::mt19937& engine, is_multi_cell multi_cell) {
auto dist = std::uniform_int_distribution<size_t>(0, _generators.size() - 1);
return _generators.at(dist(engine))(engine, multi_cell);
auto type = _generators.at(dist(engine))(engine, multi_cell);
// duration type is not allowed in:
// * primary key components
// * as member types of collections
//
// To cover all this, we simply disallow it altogether when multi_cell is
// no, which will be the case in all the above cases.
while (!multi_cell && type == duration_type) {
type = (*this)(engine, multi_cell);
}
return type;
}
namespace {