added test for table sequence

This commit is contained in:
2026-03-19 11:52:34 +01:00
parent 6423bd505b
commit 6b2db17f58
11 changed files with 137 additions and 26 deletions
+2
View File
@@ -13,6 +13,7 @@
namespace matador::query {
class table;
class column_expression;
// ReSharper disable CppNonExplicitConvertingConstructor
class table_column {
@@ -35,6 +36,7 @@ public:
table_column(const std::shared_ptr<abstract_column_expression>& expression) noexcept;
table_column(column_expression&& expression) noexcept;
table_column& operator=(const table_column& other);
table_column(const table_column& other) = default;
table_column(table_column&& other) noexcept = default;
+14
View File
@@ -25,6 +25,20 @@ void process(Operator &op, const Type &object) {
process(op, const_cast<Type &>(object));
}
template<class Base, class Derived, class Operator>
void process_base(Operator &op, const Derived &object) {
static_assert(!std::is_same_v<Base, Derived>, "class Base must not be of same type as class Derived");
static_assert(std::is_base_of_v<Base, Derived>, "class Base must be base of class Derived");
process(op, static_cast<const Base&>(object));
}
template<class Base, class Derived, class Operator>
void process_base(Operator &op, Derived &object) {
static_assert(!std::is_same_v<Base, Derived>, "class Base must not be of same type as class Derived");
static_assert(std::is_base_of_v<Base, Derived>, "class Base must be base of class Derived");
process(op, static_cast<Base&>(object));
}
template< class Operator, class Type >
void primary_key(Operator &op, const char *id, Type &value, const utils::primary_key_attribute &attr) {
op.on_primary_key(id, value, attr);
+14 -16
View File
@@ -8,33 +8,31 @@ namespace matador {
/**
* @brief Safely casts a given derived class to its base class
*
* @tparam B The base class type
* @tparam D The class type of the derived class
* @tparam Base The base class type
* @tparam Derived The class type of the derived class
* @param derived The derived object
* @return The cast object
*/
template < class B, class D>
const B* base_class(const D *derived)
{
static_assert(!std::is_same_v<B, D>, "class B must not be of same type as class D");
static_assert(std::is_base_of_v<B, D>, "class B must be base of class D");
return static_cast<const B*>(derived);
template < class Base, class Derived>
const Base* base_class(const Derived *derived) {
static_assert(!std::is_same_v<Base, Derived>, "class Base must not be of same type as class Derived");
static_assert(std::is_base_of_v<Base, Derived>, "class Base must be base of class Derived");
return static_cast<const Base*>(derived);
}
/**
* @brief Safely casts a given derived class to its base class
*
* @tparam B The base class type
* @tparam D The class type of the derived class
* @tparam Base The base class type
* @tparam Derived The class type of the derived class
* @param derived The derived object
* @return The cast object
*/
template < class B, class D>
B* base_class(D *derived)
{
static_assert(!std::is_same_v<B, D>, "class B must not be of same type as class D");
static_assert(std::is_base_of_v<B, D>, "class B must be base of class D");
return static_cast<B*>(derived);
template < class Base, class Derived>
Base* base_class(Derived *derived) {
static_assert(!std::is_same_v<Base, Derived>, "class Base must not be of same type as class Derived");
static_assert(std::is_base_of_v<Base, Derived>, "class Base must be base of class Derived");
return static_cast<Base*>(derived);
}
}