mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
Fixed possible dangling references problem
This commit is contained in:
parent
3a875e794b
commit
f7aa56b7dc
@ -116,9 +116,9 @@ namespace sqlpp
|
|||||||
static Context& _(const T& t, Context& context)
|
static Context& _(const T& t, Context& context)
|
||||||
{
|
{
|
||||||
context << "DELETE";
|
context << "DELETE";
|
||||||
interpret(t._from, context);
|
interpret(t._from(), context);
|
||||||
interpret(t._using, context);
|
interpret(t._using(), context);
|
||||||
interpret(t._where, context);
|
interpret(t._where(), context);
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -191,15 +191,15 @@ namespace sqlpp
|
|||||||
{
|
{
|
||||||
context << "SELECT ";
|
context << "SELECT ";
|
||||||
|
|
||||||
interpret(t._flag_list, context);
|
interpret(t._flag_list(), context);
|
||||||
interpret(t._column_list, context);
|
interpret(t._column_list(), context);
|
||||||
interpret(t._from, context);
|
interpret(t._from(), context);
|
||||||
interpret(t._where, context);
|
interpret(t._where(), context);
|
||||||
interpret(t._group_by, context);
|
interpret(t._group_by(), context);
|
||||||
interpret(t._having, context);
|
interpret(t._having(), context);
|
||||||
interpret(t._order_by, context);
|
interpret(t._order_by(), context);
|
||||||
interpret(t._limit, context);
|
interpret(t._limit(), context);
|
||||||
interpret(t._offset, context);
|
interpret(t._offset(), context);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
4
include/sqlpp11/vendor/from.h
vendored
4
include/sqlpp11/vendor/from.h
vendored
@ -72,7 +72,7 @@ namespace sqlpp
|
|||||||
_dynamic_tables.emplace_back(table);
|
_dynamic_tables.emplace_back(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
from_t& _from = *this;
|
const from_t& _from() const { return *this; }
|
||||||
std::tuple<Tables...> _tables;
|
std::tuple<Tables...> _tables;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_tables;
|
vendor::interpretable_list_t<Database> _dynamic_tables;
|
||||||
};
|
};
|
||||||
@ -80,7 +80,7 @@ namespace sqlpp
|
|||||||
struct no_from_t
|
struct no_from_t
|
||||||
{
|
{
|
||||||
using _is_from = std::true_type;
|
using _is_from = std::true_type;
|
||||||
no_from_t& _from = *this;
|
const no_from_t& _from() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CRTP Wrappers
|
// CRTP Wrappers
|
||||||
|
4
include/sqlpp11/vendor/group_by.h
vendored
4
include/sqlpp11/vendor/group_by.h
vendored
@ -71,7 +71,7 @@ namespace sqlpp
|
|||||||
_dynamic_expressions.emplace_back(expression);
|
_dynamic_expressions.emplace_back(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
group_by_t& _group_by = *this;
|
const group_by_t& _group_by() const { return *this; }
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||||
};
|
};
|
||||||
@ -79,7 +79,7 @@ namespace sqlpp
|
|||||||
struct no_group_by_t
|
struct no_group_by_t
|
||||||
{
|
{
|
||||||
using _is_group_by = std::true_type;
|
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
|
// CRTP Wrappers
|
||||||
|
4
include/sqlpp11/vendor/having.h
vendored
4
include/sqlpp11/vendor/having.h
vendored
@ -69,7 +69,7 @@ namespace sqlpp
|
|||||||
_dynamic_expressions.emplace_back(expr);
|
_dynamic_expressions.emplace_back(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
having_t& _having = *this;
|
const having_t& _having() const { return *this; }
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||||
};
|
};
|
||||||
@ -77,7 +77,7 @@ namespace sqlpp
|
|||||||
struct no_having_t
|
struct no_having_t
|
||||||
{
|
{
|
||||||
using _is_having = std::true_type;
|
using _is_having = std::true_type;
|
||||||
no_having_t& _having = *this;
|
const no_having_t& _having() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CRTP Wrappers
|
// CRTP Wrappers
|
||||||
|
7
include/sqlpp11/vendor/limit.h
vendored
7
include/sqlpp11/vendor/limit.h
vendored
@ -52,7 +52,7 @@ namespace sqlpp
|
|||||||
limit_t& operator=(limit_t&&) = default;
|
limit_t& operator=(limit_t&&) = default;
|
||||||
~limit_t() = default;
|
~limit_t() = default;
|
||||||
|
|
||||||
limit_t& _limit = *this;
|
const limit_t& _limit() const { return *this; }
|
||||||
Limit _value;
|
Limit _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -88,8 +88,7 @@ namespace sqlpp
|
|||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#warning this is stupid! Will get dangling references when copying
|
const dynamic_limit_t& _limit() const { return *this; }
|
||||||
dynamic_limit_t& _limit = *this;
|
|
||||||
|
|
||||||
bool _initialized = false;
|
bool _initialized = false;
|
||||||
interpretable_t<Database> _value;
|
interpretable_t<Database> _value;
|
||||||
@ -98,7 +97,7 @@ namespace sqlpp
|
|||||||
struct no_limit_t
|
struct no_limit_t
|
||||||
{
|
{
|
||||||
using _is_limit = std::true_type;
|
using _is_limit = std::true_type;
|
||||||
no_limit_t& _limit = *this;
|
const no_limit_t& _limit() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CRTP Wrappers
|
// CRTP Wrappers
|
||||||
|
6
include/sqlpp11/vendor/offset.h
vendored
6
include/sqlpp11/vendor/offset.h
vendored
@ -52,7 +52,7 @@ namespace sqlpp
|
|||||||
offset_t& operator=(offset_t&&) = default;
|
offset_t& operator=(offset_t&&) = default;
|
||||||
~offset_t() = default;
|
~offset_t() = default;
|
||||||
|
|
||||||
offset_t& _offset = *this;
|
const offset_t& _offset() const { return *this; }
|
||||||
|
|
||||||
Offset _value;
|
Offset _value;
|
||||||
};
|
};
|
||||||
@ -89,7 +89,7 @@ namespace sqlpp
|
|||||||
_initialized = true;
|
_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
dynamic_offset_t& _offset = *this;
|
const dynamic_offset_t& _offset() const { return *this; }
|
||||||
bool _initialized = false;
|
bool _initialized = false;
|
||||||
interpretable_t<Database> _value;
|
interpretable_t<Database> _value;
|
||||||
};
|
};
|
||||||
@ -97,7 +97,7 @@ namespace sqlpp
|
|||||||
struct no_offset_t
|
struct no_offset_t
|
||||||
{
|
{
|
||||||
using _is_offset = std::true_type;
|
using _is_offset = std::true_type;
|
||||||
no_offset_t& _offset = *this;
|
const no_offset_t& _offset() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CRTP Wrappers
|
// CRTP Wrappers
|
||||||
|
4
include/sqlpp11/vendor/order_by.h
vendored
4
include/sqlpp11/vendor/order_by.h
vendored
@ -70,7 +70,7 @@ namespace sqlpp
|
|||||||
_dynamic_expressions.push_back(expressions);
|
_dynamic_expressions.push_back(expressions);
|
||||||
}
|
}
|
||||||
|
|
||||||
order_by_t& _order_by = *this;
|
const order_by_t& _order_by() const { return *this; }
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||||
};
|
};
|
||||||
@ -78,7 +78,7 @@ namespace sqlpp
|
|||||||
struct no_order_by_t
|
struct no_order_by_t
|
||||||
{
|
{
|
||||||
using _is_order_by = std::true_type;
|
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
|
// CRTP Wrappers
|
||||||
|
4
include/sqlpp11/vendor/select_column_list.h
vendored
4
include/sqlpp11/vendor/select_column_list.h
vendored
@ -188,7 +188,7 @@ namespace sqlpp
|
|||||||
_dynamic_columns.push_back(namedExpr);
|
_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;
|
_parameter_tuple_t _columns;
|
||||||
dynamic_select_column_list<Database> _dynamic_columns;
|
dynamic_select_column_list<Database> _dynamic_columns;
|
||||||
};
|
};
|
||||||
@ -196,7 +196,7 @@ namespace sqlpp
|
|||||||
struct no_select_column_list_t
|
struct no_select_column_list_t
|
||||||
{
|
{
|
||||||
using _is_select_column_list = std::true_type;
|
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
|
// CRTP Wrappers
|
||||||
|
4
include/sqlpp11/vendor/select_flag_list.h
vendored
4
include/sqlpp11/vendor/select_flag_list.h
vendored
@ -70,7 +70,7 @@ namespace sqlpp
|
|||||||
_dynamic_flags.emplace_back(flag);
|
_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;
|
_parameter_tuple_t _flags;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_flags;
|
vendor::interpretable_list_t<Database> _dynamic_flags;
|
||||||
};
|
};
|
||||||
@ -78,7 +78,7 @@ namespace sqlpp
|
|||||||
struct no_select_flag_list_t
|
struct no_select_flag_list_t
|
||||||
{
|
{
|
||||||
using _is_select_flag_list = std::true_type;
|
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
|
// CRTP Wrappers
|
||||||
|
4
include/sqlpp11/vendor/using.h
vendored
4
include/sqlpp11/vendor/using.h
vendored
@ -71,14 +71,14 @@ namespace sqlpp
|
|||||||
_dynamic_tables.emplace_back(table);
|
_dynamic_tables.emplace_back(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
using_t& _using = *this;
|
const using_t& _using() const { return *this; }
|
||||||
_parameter_tuple_t _tables;
|
_parameter_tuple_t _tables;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_tables;
|
vendor::interpretable_list_t<Database> _dynamic_tables;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct no_using_t
|
struct no_using_t
|
||||||
{
|
{
|
||||||
no_using_t& _using = *this;
|
const no_using_t& _using() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CRTP Wrapper
|
// CRTP Wrapper
|
||||||
|
4
include/sqlpp11/vendor/where.h
vendored
4
include/sqlpp11/vendor/where.h
vendored
@ -71,7 +71,7 @@ namespace sqlpp
|
|||||||
_dynamic_expressions.emplace_back(expr);
|
_dynamic_expressions.emplace_back(expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
where_t& _where = *this;
|
const where_t& _where() const { return *this; }
|
||||||
_parameter_tuple_t _expressions;
|
_parameter_tuple_t _expressions;
|
||||||
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
vendor::interpretable_list_t<Database> _dynamic_expressions;
|
||||||
};
|
};
|
||||||
@ -88,7 +88,7 @@ namespace sqlpp
|
|||||||
struct no_where_t
|
struct no_where_t
|
||||||
{
|
{
|
||||||
using _is_where = std::true_type;
|
using _is_where = std::true_type;
|
||||||
no_where_t& _where = *this;
|
const no_where_t& _where() const { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CRTP Wrappers
|
// CRTP Wrappers
|
||||||
|
Loading…
Reference in New Issue
Block a user