From 2a7cccd1a8e4ba2aa528ab94a256cd1bf8240a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Botond=20D=C3=A9nes?= Date: Fri, 13 Jan 2023 10:41:54 -0500 Subject: [PATCH] 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. --- test/lib/random_schema.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/lib/random_schema.cc b/test/lib/random_schema.cc index 95c24894f1..c92911c2c7 100644 --- a/test/lib/random_schema.cc +++ b/test/lib/random_schema.cc @@ -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(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 {