#include <sqlpp/queries/like_predicate.hpp>
namespace sqlpp{
namespace queries{
like_predicate::like_predicate(
query_field_shared_ptr field_,
string_type pattern_,
bool not_
)
:
m_field(field_),
m_pattern(pattern_),
m_not(not_)
{};
string_type like_predicate::get_where(select_query_base const& query_) const
{
if (!m_field)
throw exceptions::sqlpp_exception("like_predicate::get_where: field pointer is null");
std::ostringstream out;
out<<m_field->get_sql_name();
if (m_not)
out<<" NOT";
out<<" LIKE "<<to_sql_string(m_pattern);
return out.str();
}
like_predicate_shared_ptr like(
query_field_shared_ptr field_,
string_type pattern_
)
{
return like_predicate_shared_ptr(
new like_predicate(
field_,
pattern_,
false
)
);
};
like_predicate_shared_ptr not_like(
query_field_shared_ptr field_,
string_type pattern_
)
{
return like_predicate_shared_ptr(
new like_predicate(
field_,
pattern_,
true
)
);
};
};
};