mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-15 20:31:16 +08:00
is_null() throws for invalid rows
result_row objects can be constructed with raw result rows representing the end of the result set. Field values must not be accessed for such rows. Thus, is_null() now throws an exception when called for a field of an invalid row.
This commit is contained in:
parent
7370f098b0
commit
e4bcc27463
@ -95,13 +95,20 @@ namespace sqlpp
|
||||
|
||||
bool _is_trivial() const { return value() == false; }
|
||||
|
||||
bool is_null() const { return _is_null; }
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
bool value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator bool() const { return value(); }
|
||||
|
||||
private:
|
||||
|
@ -72,13 +72,20 @@ namespace sqlpp
|
||||
|
||||
bool _is_trivial() const { return value() == 0; }
|
||||
|
||||
bool is_null() const { return _is_null; }
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
int64_t value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator int64_t() const { return value(); }
|
||||
|
||||
private:
|
||||
|
@ -86,13 +86,20 @@ namespace sqlpp
|
||||
bool operator==(const std::string& rhs) const { return value() == rhs; }
|
||||
bool operator!=(const std::string& rhs) const { return not operator==(rhs); }
|
||||
|
||||
bool is_null() const { return _is_null; }
|
||||
bool is_null() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing is_null in non-existing row");
|
||||
return _is_null;
|
||||
}
|
||||
|
||||
std::string value() const
|
||||
{
|
||||
if (not _is_valid)
|
||||
throw exception("accessing value in non-existing row");
|
||||
return _value;
|
||||
}
|
||||
|
||||
operator std::string() const { return value(); }
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user