mirror of
https://github.com/rbock/sqlpp11.git
synced 2026-01-10 07:02:11 -06:00
Added some (no-op) statement executions
This commit is contained in:
@@ -98,6 +98,7 @@ namespace sqlpp
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template<bool TrivialIsNull = false>
|
||||
struct _result_entry_t
|
||||
{
|
||||
_result_entry_t():
|
||||
@@ -189,7 +190,8 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const boolean::_result_entry_t& e)
|
||||
template<bool TrivialIsNull>
|
||||
inline std::ostream& operator<<(std::ostream& os, const boolean::_result_entry_t<TrivialIsNull>& e)
|
||||
{
|
||||
return os << e.value();
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ namespace sqlpp
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template<bool TrivialIsNull = false>
|
||||
struct _result_entry_t
|
||||
{
|
||||
using _value_type = integral;
|
||||
@@ -237,7 +238,8 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const floating_point::_result_entry_t& e)
|
||||
template<bool TrivialIsNull>
|
||||
inline std::ostream& operator<<(std::ostream& os, const floating_point::_result_entry_t<TrivialIsNull>& e)
|
||||
{
|
||||
return os << e.value();
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ namespace sqlpp
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template<bool NullIsTrivial = false>
|
||||
struct _result_entry_t
|
||||
{
|
||||
using _value_type = integral;
|
||||
@@ -244,7 +245,8 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const integral::_result_entry_t& e)
|
||||
template<bool NullIsTrivial>
|
||||
inline std::ostream& operator<<(std::ostream& os, const integral::_result_entry_t<NullIsTrivial>& e)
|
||||
{
|
||||
return os << e.value();
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace sqlpp
|
||||
|
||||
template<size_t level, size_t index, typename NamedExpr, typename... Rest>
|
||||
struct result_row_impl<level, index, NamedExpr, Rest...>:
|
||||
public NamedExpr::_name_t::template _member_t<typename NamedExpr::_value_type::_result_entry_t>,
|
||||
public NamedExpr::_name_t::template _member_t<typename NamedExpr::_value_type::template _result_entry_t<NamedExpr::_trivial_value_is_null>>,
|
||||
public result_row_impl<level, index + 1, Rest...>
|
||||
{
|
||||
using _field = typename NamedExpr::_name_t::template _member_t<typename NamedExpr::_value_type::_result_entry_t>;
|
||||
using _field = typename NamedExpr::_name_t::template _member_t<typename NamedExpr::_value_type::template _result_entry_t<NamedExpr::_trivial_value_is_null>>;
|
||||
using _rest = result_row_impl<level, index + 1, Rest...>;
|
||||
static constexpr size_t _last_index = _rest::_last_index;
|
||||
|
||||
@@ -225,7 +225,7 @@ namespace sqlpp
|
||||
struct dynamic_result_row_t: public detail::result_row_impl<0, 0, NamedExpr...>
|
||||
{
|
||||
using _impl = detail::result_row_impl<0, 0, NamedExpr...>;
|
||||
using _field_type = detail::text::_result_entry_t;
|
||||
using _field_type = detail::text::_result_entry_t<>;
|
||||
static constexpr size_t _last_static_index = _impl::_last_index;
|
||||
|
||||
bool _is_valid;
|
||||
|
||||
@@ -38,6 +38,16 @@ namespace sqlpp
|
||||
return vendor::serializer_t<Context, T>::_(t, context);
|
||||
}
|
||||
|
||||
namespace vendor // Required if you want to call serialize(sqlpp::value(7), printer), for instance
|
||||
{
|
||||
template<typename T, typename Context>
|
||||
auto serialize(const T& t, Context& context)
|
||||
-> decltype(vendor::serializer_t<Context, T>::_(t, context))
|
||||
{
|
||||
return vendor::serializer_t<Context, T>::_(t, context);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -42,15 +42,21 @@ namespace sqlpp
|
||||
return _os << t;
|
||||
}
|
||||
|
||||
void flush()
|
||||
static std::string escape(std::string arg)
|
||||
{
|
||||
_os << std::endl;
|
||||
}
|
||||
|
||||
std::string escape(std::string arg)
|
||||
{
|
||||
// FIXME: Need to do better escaping
|
||||
return arg;
|
||||
if (arg.find('\''))
|
||||
{
|
||||
std::string retVal;
|
||||
for (const auto c : arg)
|
||||
{
|
||||
if (c == '\'')
|
||||
retVal.push_back(c);
|
||||
retVal.push_back(c);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
else
|
||||
return arg;
|
||||
}
|
||||
|
||||
std::ostream& _os;
|
||||
|
||||
@@ -97,6 +97,7 @@ namespace sqlpp
|
||||
bool _is_null;
|
||||
};
|
||||
|
||||
template<bool TrivialIsNull = false>
|
||||
struct _result_entry_t
|
||||
{
|
||||
_result_entry_t():
|
||||
@@ -195,7 +196,8 @@ namespace sqlpp
|
||||
};
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& os, const text::_result_entry_t& e)
|
||||
template<bool TrivialIsNull>
|
||||
inline std::ostream& operator<<(std::ostream& os, const text::_result_entry_t<TrivialIsNull>& e)
|
||||
{
|
||||
return os << e.value();
|
||||
}
|
||||
|
||||
@@ -92,6 +92,7 @@ namespace sqlpp
|
||||
SQLPP_IS_COLUMN_TRAIT_GENERATOR(must_not_update);
|
||||
SQLPP_IS_COLUMN_TRAIT_GENERATOR(require_insert);
|
||||
SQLPP_IS_COLUMN_TRAIT_GENERATOR(can_be_null);
|
||||
SQLPP_IS_COLUMN_TRAIT_GENERATOR(trivial_value_is_null);
|
||||
|
||||
SQLPP_TYPE_TRAIT_GENERATOR(is_noop);
|
||||
SQLPP_TYPE_TRAIT_GENERATOR(is_table);
|
||||
|
||||
7
include/sqlpp11/vendor/field.h
vendored
7
include/sqlpp11/vendor/field.h
vendored
@@ -33,11 +33,12 @@ namespace sqlpp
|
||||
{
|
||||
namespace vendor
|
||||
{
|
||||
template<typename NameType, typename ValueType>
|
||||
template<typename NameType, typename ValueType, bool TrivialValueIsNull>
|
||||
struct field_t
|
||||
{
|
||||
using _name_t = NameType;
|
||||
using _value_type = ValueType;
|
||||
static constexpr bool _trivial_value_is_null = TrivialValueIsNull;
|
||||
};
|
||||
|
||||
template<typename AliasProvider, typename FieldTuple>
|
||||
@@ -50,7 +51,9 @@ namespace sqlpp
|
||||
template<typename NamedExpr>
|
||||
struct make_field_t_impl
|
||||
{
|
||||
using type = field_t<typename NamedExpr::_name_t, typename NamedExpr::_value_type::_base_value_type>;
|
||||
using type = field_t<typename NamedExpr::_name_t,
|
||||
typename NamedExpr::_value_type::_base_value_type,
|
||||
trivial_value_is_null_t<NamedExpr>::value>;
|
||||
};
|
||||
|
||||
template<typename AliasProvider, typename... NamedExpr>
|
||||
|
||||
2
include/sqlpp11/vendor/interpretable.h
vendored
2
include/sqlpp11/vendor/interpretable.h
vendored
@@ -63,7 +63,7 @@ namespace sqlpp
|
||||
template<typename Context>
|
||||
auto serialize(Context& context) const
|
||||
-> typename std::enable_if<std::is_same<Context, _serializer_context_t>::value
|
||||
and not std::is_same<Context, sqlpp::serializer_context_t>::value, void>::type
|
||||
and not std::is_same<Context, sqlpp::serializer_context_t>::value, Context&>::type
|
||||
{
|
||||
return _impl->db_serialize(context);
|
||||
}
|
||||
|
||||
2
include/sqlpp11/vendor/named_interpretable.h
vendored
2
include/sqlpp11/vendor/named_interpretable.h
vendored
@@ -61,7 +61,7 @@ namespace sqlpp
|
||||
template<typename Context>
|
||||
auto serialize(Context& context) const
|
||||
-> typename std::enable_if<std::is_same<Context, _serializer_context_t>::value
|
||||
and not std::is_same<Context, sqlpp::serializer_context_t>::value, void>::type
|
||||
and not std::is_same<Context, sqlpp::serializer_context_t>::value, Context&>::type
|
||||
{
|
||||
return _impl->db_serialize(context);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user