0
0
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:
rbock 2014-02-08 00:43:20 +01:00
parent 3a875e794b
commit f7aa56b7dc
12 changed files with 34 additions and 35 deletions

View File

@ -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;
}
};

View File

@ -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;
}

View File

@ -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...> _tables;
vendor::interpretable_list_t<Database> _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

View File

@ -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<Database> _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

View File

@ -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<Database> _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

View File

@ -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<Database> _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

View File

@ -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<Database> _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

View File

@ -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<Database> _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

View File

@ -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<Database> _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

View File

@ -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<Database> _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

View File

@ -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<Database> _dynamic_tables;
};
struct no_using_t
{
no_using_t& _using = *this;
const no_using_t& _using() const { return *this; }
};
// CRTP Wrapper

View File

@ -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<Database> _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