diff --git a/include/sqlpp11/remove.h b/include/sqlpp11/remove.h index 68c2397d..d7601bc8 100644 --- a/include/sqlpp11/remove.h +++ b/include/sqlpp11/remove.h @@ -116,9 +116,9 @@ namespace sqlpp static Context& _(const T& t, Context& context) { context << "DELETE"; - interpret(t._from, context); - interpret(t._using, context); - interpret(t._where, context); + interpret(t._from(), context); + interpret(t._using(), context); + interpret(t._where(), context); return context; } }; diff --git a/include/sqlpp11/select.h b/include/sqlpp11/select.h index 0da74235..07dadf0a 100644 --- a/include/sqlpp11/select.h +++ b/include/sqlpp11/select.h @@ -191,15 +191,15 @@ namespace sqlpp { context << "SELECT "; - interpret(t._flag_list, context); - interpret(t._column_list, context); - interpret(t._from, context); - interpret(t._where, context); - interpret(t._group_by, context); - interpret(t._having, context); - interpret(t._order_by, context); - interpret(t._limit, context); - interpret(t._offset, context); + interpret(t._flag_list(), context); + interpret(t._column_list(), context); + interpret(t._from(), context); + interpret(t._where(), context); + interpret(t._group_by(), context); + interpret(t._having(), context); + interpret(t._order_by(), context); + interpret(t._limit(), context); + interpret(t._offset(), context); return context; } diff --git a/include/sqlpp11/vendor/from.h b/include/sqlpp11/vendor/from.h index f0a816cd..8cdfa710 100644 --- a/include/sqlpp11/vendor/from.h +++ b/include/sqlpp11/vendor/from.h @@ -72,7 +72,7 @@ namespace sqlpp _dynamic_tables.emplace_back(table); } - from_t& _from = *this; + const from_t& _from() const { return *this; } std::tuple _tables; vendor::interpretable_list_t _dynamic_tables; }; @@ -80,7 +80,7 @@ namespace sqlpp struct no_from_t { using _is_from = std::true_type; - no_from_t& _from = *this; + const no_from_t& _from() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/group_by.h b/include/sqlpp11/vendor/group_by.h index bdb7b169..d5e90eb8 100644 --- a/include/sqlpp11/vendor/group_by.h +++ b/include/sqlpp11/vendor/group_by.h @@ -71,7 +71,7 @@ namespace sqlpp _dynamic_expressions.emplace_back(expression); } - group_by_t& _group_by = *this; + const group_by_t& _group_by() const { return *this; } _parameter_tuple_t _expressions; vendor::interpretable_list_t _dynamic_expressions; }; @@ -79,7 +79,7 @@ namespace sqlpp struct no_group_by_t { using _is_group_by = std::true_type; - no_group_by_t& _group_by = *this; + const no_group_by_t& _group_by() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/having.h b/include/sqlpp11/vendor/having.h index cc5de0ac..63698dad 100644 --- a/include/sqlpp11/vendor/having.h +++ b/include/sqlpp11/vendor/having.h @@ -69,7 +69,7 @@ namespace sqlpp _dynamic_expressions.emplace_back(expr); } - having_t& _having = *this; + const having_t& _having() const { return *this; } _parameter_tuple_t _expressions; vendor::interpretable_list_t _dynamic_expressions; }; @@ -77,7 +77,7 @@ namespace sqlpp struct no_having_t { using _is_having = std::true_type; - no_having_t& _having = *this; + const no_having_t& _having() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/limit.h b/include/sqlpp11/vendor/limit.h index 1a8426a2..bdae95fc 100644 --- a/include/sqlpp11/vendor/limit.h +++ b/include/sqlpp11/vendor/limit.h @@ -52,7 +52,7 @@ namespace sqlpp limit_t& operator=(limit_t&&) = default; ~limit_t() = default; - limit_t& _limit = *this; + const limit_t& _limit() const { return *this; } Limit _value; }; @@ -88,8 +88,7 @@ namespace sqlpp _initialized = true; } -#warning this is stupid! Will get dangling references when copying - dynamic_limit_t& _limit = *this; + const dynamic_limit_t& _limit() const { return *this; } bool _initialized = false; interpretable_t _value; @@ -98,7 +97,7 @@ namespace sqlpp struct no_limit_t { using _is_limit = std::true_type; - no_limit_t& _limit = *this; + const no_limit_t& _limit() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/offset.h b/include/sqlpp11/vendor/offset.h index c8f1f119..1c839887 100644 --- a/include/sqlpp11/vendor/offset.h +++ b/include/sqlpp11/vendor/offset.h @@ -52,7 +52,7 @@ namespace sqlpp offset_t& operator=(offset_t&&) = default; ~offset_t() = default; - offset_t& _offset = *this; + const offset_t& _offset() const { return *this; } Offset _value; }; @@ -89,7 +89,7 @@ namespace sqlpp _initialized = true; } - dynamic_offset_t& _offset = *this; + const dynamic_offset_t& _offset() const { return *this; } bool _initialized = false; interpretable_t _value; }; @@ -97,7 +97,7 @@ namespace sqlpp struct no_offset_t { using _is_offset = std::true_type; - no_offset_t& _offset = *this; + const no_offset_t& _offset() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/order_by.h b/include/sqlpp11/vendor/order_by.h index 9c6f32ed..63ee7421 100644 --- a/include/sqlpp11/vendor/order_by.h +++ b/include/sqlpp11/vendor/order_by.h @@ -70,7 +70,7 @@ namespace sqlpp _dynamic_expressions.push_back(expressions); } - order_by_t& _order_by = *this; + const order_by_t& _order_by() const { return *this; } _parameter_tuple_t _expressions; vendor::interpretable_list_t _dynamic_expressions; }; @@ -78,7 +78,7 @@ namespace sqlpp struct no_order_by_t { using _is_order_by = std::true_type; - no_order_by_t& _order_by = *this; + const no_order_by_t& _order_by() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/select_column_list.h b/include/sqlpp11/vendor/select_column_list.h index 7872ac62..ea90f17b 100644 --- a/include/sqlpp11/vendor/select_column_list.h +++ b/include/sqlpp11/vendor/select_column_list.h @@ -188,7 +188,7 @@ namespace sqlpp _dynamic_columns.push_back(namedExpr); } - select_column_list_t& _column_list = *this; + const select_column_list_t& _column_list() const { return *this; } _parameter_tuple_t _columns; dynamic_select_column_list _dynamic_columns; }; @@ -196,7 +196,7 @@ namespace sqlpp struct no_select_column_list_t { using _is_select_column_list = std::true_type; - no_select_column_list_t& _column_list = *this; + const no_select_column_list_t& _column_list() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/select_flag_list.h b/include/sqlpp11/vendor/select_flag_list.h index 48860aa7..dc6b4b8e 100644 --- a/include/sqlpp11/vendor/select_flag_list.h +++ b/include/sqlpp11/vendor/select_flag_list.h @@ -70,7 +70,7 @@ namespace sqlpp _dynamic_flags.emplace_back(flag); } - select_flag_list_t& _flag_list = *this; + const select_flag_list_t& _flag_list() const { return *this; } _parameter_tuple_t _flags; vendor::interpretable_list_t _dynamic_flags; }; @@ -78,7 +78,7 @@ namespace sqlpp struct no_select_flag_list_t { using _is_select_flag_list = std::true_type; - no_select_flag_list_t& _flag_list = *this; + const no_select_flag_list_t& _flag_list() const { return *this; } }; // CRTP Wrappers diff --git a/include/sqlpp11/vendor/using.h b/include/sqlpp11/vendor/using.h index 0cd2222f..1ad27720 100644 --- a/include/sqlpp11/vendor/using.h +++ b/include/sqlpp11/vendor/using.h @@ -71,14 +71,14 @@ namespace sqlpp _dynamic_tables.emplace_back(table); } - using_t& _using = *this; + const using_t& _using() const { return *this; } _parameter_tuple_t _tables; vendor::interpretable_list_t _dynamic_tables; }; struct no_using_t { - no_using_t& _using = *this; + const no_using_t& _using() const { return *this; } }; // CRTP Wrapper diff --git a/include/sqlpp11/vendor/where.h b/include/sqlpp11/vendor/where.h index b1805212..89ceeece 100644 --- a/include/sqlpp11/vendor/where.h +++ b/include/sqlpp11/vendor/where.h @@ -71,7 +71,7 @@ namespace sqlpp _dynamic_expressions.emplace_back(expr); } - where_t& _where = *this; + const where_t& _where() const { return *this; } _parameter_tuple_t _expressions; vendor::interpretable_list_t _dynamic_expressions; }; @@ -88,7 +88,7 @@ namespace sqlpp struct no_where_t { using _is_where = std::true_type; - no_where_t& _where = *this; + const no_where_t& _where() const { return *this; } }; // CRTP Wrappers