mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-29 04:17:55 +01:00
feat(Data::Statement): make statementsCount() Optional 230
This commit is contained in:
@@ -305,7 +305,7 @@ public:
|
|||||||
const std::string& toString() const;
|
const std::string& toString() const;
|
||||||
/// Creates a string from the accumulated SQL statement.
|
/// Creates a string from the accumulated SQL statement.
|
||||||
|
|
||||||
std::size_t statementsCount() const;
|
Optional<std::size_t> statementsCount() const;
|
||||||
/// Returns the total number of SQL statements held in the accummulated SQL statement.
|
/// Returns the total number of SQL statements held in the accummulated SQL statement.
|
||||||
|
|
||||||
Optional<bool> parse();
|
Optional<bool> parse();
|
||||||
|
|||||||
@@ -155,13 +155,14 @@ Statement& Statement::reset()
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t Statement::statementsCount() const
|
Optional<std::size_t> Statement::statementsCount() const
|
||||||
{
|
{
|
||||||
|
Optional<std::size_t> ret;
|
||||||
#ifndef POCO_DATA_NO_SQL_PARSER
|
#ifndef POCO_DATA_NO_SQL_PARSER
|
||||||
return _pParseResult->size();
|
if (_pImpl->session().shouldParse())
|
||||||
#else
|
ret = _pParseResult->size();
|
||||||
return 0u;
|
|
||||||
#endif
|
#endif
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1451,6 +1451,7 @@ void DataTest::testSQLParse()
|
|||||||
"'",'a',"'",-1, 1u, 1.5, "42", now);
|
"'",'a',"'",-1, 1u, 1.5, "42", now);
|
||||||
|
|
||||||
assertTrue ("SELECT 'a',-1,1,1.500000,42 FROM Person WHERE Name LIKE 'Simp%'" == stmt.toString());
|
assertTrue ("SELECT 'a',-1,1,1.500000,42 FROM Person WHERE Name LIKE 'Simp%'" == stmt.toString());
|
||||||
|
assertEqual (1u, stmt.statementsCount().value());
|
||||||
assertTrue (stmt.isSelect().value());
|
assertTrue (stmt.isSelect().value());
|
||||||
assertTrue (stmt.hasSelect().value());
|
assertTrue (stmt.hasSelect().value());
|
||||||
assertTrue (!stmt.isUpdate().value());
|
assertTrue (!stmt.isUpdate().value());
|
||||||
@@ -1470,6 +1471,7 @@ void DataTest::testSQLParse()
|
|||||||
"PREPARE prep_inst FROM 'INSERT INTO test VALUES (?, ?, ?)';"
|
"PREPARE prep_inst FROM 'INSERT INTO test VALUES (?, ?, ?)';"
|
||||||
"EXECUTE prep_inst(1, 2, 3);");
|
"EXECUTE prep_inst(1, 2, 3);");
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
|
assertEqual (8u, stmt.statementsCount().value());
|
||||||
assertTrue (!stmt.isSelect().value());
|
assertTrue (!stmt.isSelect().value());
|
||||||
assertTrue (stmt.hasSelect().value());
|
assertTrue (stmt.hasSelect().value());
|
||||||
assertTrue (!stmt.isUpdate().value());
|
assertTrue (!stmt.isUpdate().value());
|
||||||
|
|||||||
Reference in New Issue
Block a user