0
0
mirror of https://github.com/rbock/sqlpp11.git synced 2024-11-15 20:31:16 +08:00

Use clang-tidy to wrap single-line blocks into {}

This commit is contained in:
rbock 2017-09-10 15:05:34 +02:00
parent f4612061d7
commit 6a9715b59d
24 changed files with 90 additions and 0 deletions

View File

@ -98,7 +98,9 @@ namespace sqlpp
serialize_operand(t._expr, context);
}
else
{
serialize(t._expr, context);
}
context << ")";
return context;

View File

@ -48,9 +48,13 @@ namespace sqlpp
{
target._bind_text_result(index, &text, &len);
if (text)
{
this->_value.assign(text, len);
}
else
{
this->_value.assign("");
}
this->_is_null = (text == nullptr);
}
@ -59,9 +63,13 @@ namespace sqlpp
{
target._post_bind_text_result(index, &text, &len);
if (text)
{
this->_value.assign(text, len);
}
else
{
this->_value.assign("");
}
this->_is_null = (text == nullptr);
}
};

View File

@ -87,9 +87,13 @@ namespace sqlpp
for (const auto column : t._dynamic_columns)
{
if (first)
{
first = false;
}
else
{
context << ',';
}
serialize(column, context);
}
return context;

View File

@ -108,9 +108,13 @@ namespace sqlpp
for (const auto& entry : t._container)
{
if (first)
{
first = false;
}
else
{
context << ',';
}
serialize_operand(value(entry), context);
}

View File

@ -260,11 +260,15 @@ namespace sqlpp
static Context& _(const T& t, Context& context)
{
if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty())
{
return context;
}
context << " GROUP BY ";
interpret_tuple(t._expressions, ',', context);
if (sizeof...(Expressions) and not t._dynamic_expressions.empty())
{
context << ',';
}
interpret_list(t._dynamic_expressions, ',', context);
return context;
}

View File

@ -302,7 +302,9 @@ namespace sqlpp
context << " HAVING ";
serialize(t._expression, context);
if (not t._dynamic_expressions.empty())
{
context << " AND ";
}
interpret_list(t._dynamic_expressions, " AND ", context);
return context;
}

View File

@ -83,9 +83,13 @@ namespace sqlpp
serialize(t._operand, context);
context << " IN(";
if (sizeof...(Args) == 1)
{
serialize(std::get<0>(t._args), context);
}
else
{
interpret_tuple(t._args, ',', context);
}
context << ')';
return context;
}

View File

@ -109,9 +109,13 @@ namespace sqlpp
context << "NULL";
}
else if (t._is_default)
{
context << "DEFAULT";
}
else
{
serialize_operand(t._value, context);
}
return context;
}
};

View File

@ -587,9 +587,13 @@ namespace sqlpp
for (const auto& row : t._insert_values)
{
if (not first)
{
context << ',';
}
else
{
first = false;
}
context << '(';
interpret_tuple(row, ",", context);
context << ')';
@ -616,12 +620,16 @@ namespace sqlpp
context << " (";
interpret_tuple(t._columns, ",", context);
if (sizeof...(Assignments) and not t._dynamic_columns.empty())
{
context << ',';
}
interpret_list(t._dynamic_columns, ',', context);
context << ") VALUES(";
interpret_tuple(t._values, ",", context);
if (sizeof...(Assignments) and not t._dynamic_values.empty())
{
context << ',';
}
interpret_list(t._dynamic_values, ',', context);
context << ")";
}

View File

@ -39,11 +39,17 @@ namespace sqlpp
const Element& element, const Separator& separator, Context& context, const UseBraces& /*unused*/, size_t index)
{
if (index)
{
context << separator;
}
if (UseBraces::value)
{
serialize_operand(element, context);
}
else
{
serialize(element, context);
}
}
template <typename Tuple, typename Separator, typename Context, typename UseBraces, size_t... Is>

View File

@ -130,7 +130,9 @@ namespace sqlpp
context << ')';
}
else
{
t.serialize(context);
}
return context;
}

View File

@ -140,7 +140,9 @@ namespace sqlpp
context << ')';
}
else
{
t.serialize(context);
}
return context;
}

View File

@ -83,9 +83,13 @@ namespace sqlpp
serialize_operand(t._operand, context);
context << " NOT IN(";
if (sizeof...(Args) == 1)
{
serialize(std::get<0>(t._args), context);
}
else
{
interpret_tuple(t._args, ',', context);
}
context << ')';
return context;
}

View File

@ -258,11 +258,15 @@ namespace sqlpp
static Context& _(const T& t, Context& context)
{
if (sizeof...(Expressions) == 0 and t._dynamic_expressions.empty())
{
return context;
}
context << " ORDER BY ";
interpret_tuple(t._expressions, ',', context);
if (sizeof...(Expressions) and not t._dynamic_expressions.empty())
{
context << ',';
}
interpret_list(t._dynamic_expressions, ',', context);
return context;
}

View File

@ -87,14 +87,18 @@ namespace sqlpp
bool is_null() const
{
if (not _is_valid)
{
throw exception("accessing is_null in non-existing row");
}
return _is_null;
}
bool _is_trivial() const
{
if (not _is_valid)
{
throw exception("accessing is_null in non-existing row");
}
return value() == _cpp_storage_type{};
}
@ -102,7 +106,9 @@ namespace sqlpp
_cpp_value_type value() const
{
if (not _is_valid)
{
throw exception("accessing value in non-existing row");
}
if (_is_null)
{

View File

@ -436,7 +436,9 @@ namespace sqlpp
{
interpret_tuple(t._columns, ',', context);
if (sizeof...(Columns) and not t._dynamic_columns.empty())
{
context << ',';
}
serialize(t._dynamic_columns, context);
return context;
}

View File

@ -249,10 +249,14 @@ namespace sqlpp
{
interpret_tuple(t._flags, ' ', context);
if (sizeof...(Flags))
{
context << ' ';
}
interpret_list(t._dynamic_flags, ',', context);
if (not t._dynamic_flags.empty())
{
context << ' ';
}
return context;
}
};

View File

@ -48,7 +48,9 @@ namespace sqlpp
context << ')';
}
else
{
serializer_t<Context, T>::_(t, context);
}
return context;
}

View File

@ -50,13 +50,17 @@ namespace sqlpp
for (const auto c : arg)
{
if (c == '\'')
{
retVal.push_back(c);
}
retVal.push_back(c);
}
return retVal;
}
else
{
return arg;
}
}
std::ostream& _os;

View File

@ -108,10 +108,14 @@ namespace sqlpp
static Context& _(const T& t, Context& context)
{
if (requires_braces_t<Table>::value)
{
context << "(";
}
serialize(t._table, context);
if (requires_braces_t<Table>::value)
{
context << ")";
}
context << " AS " << name_of<T>::char_ptr();
return context;
}

View File

@ -296,7 +296,9 @@ namespace sqlpp
context << " SET ";
interpret_tuple(t._assignments, ",", context);
if (sizeof...(Assignments) and not t._dynamic_assignments.empty())
{
context << ',';
}
interpret_list(t._dynamic_assignments, ',', context);
return context;
}

View File

@ -248,11 +248,15 @@ namespace sqlpp
static Context& _(const T& t, Context& context)
{
if (sizeof...(Tables) == 0 and t._dynamic_tables.empty())
{
return context;
}
context << " USING ";
interpret_tuple(t._tables, ',', context);
if (sizeof...(Tables) and not t._dynamic_tables.empty())
{
context << ',';
}
interpret_list(t._dynamic_tables, ',', context);
return context;
}

View File

@ -370,7 +370,9 @@ namespace sqlpp
context << " WHERE ";
serialize(t._expression, context);
if (not t._dynamic_expressions.empty())
{
context << " AND ";
}
interpret_list(t._dynamic_expressions, " AND ", context);
return context;
}

View File

@ -201,7 +201,9 @@ namespace sqlpp
// FIXME: If there is a recursive CTE, add a "RECURSIVE" here
context << " WITH ";
if (T::_is_recursive::value)
{
context << "RECURSIVE ";
}
interpret_tuple(t._expressions, ',', context);
context << ' ';
return context;