[#8093] Add support for result less statements in MockFileDatabase

This commit is contained in:
lukaseder 2018-12-07 10:40:12 +01:00
parent 2af798aae1
commit 8085ca66af
4 changed files with 30 additions and 13 deletions

View File

@ -13935,11 +13935,16 @@ select 'A';
> A
@ rows: 1
select 'A', 'B';
select 'A', 'B' union all 'C', 'D';
> A B
> - -
> A B
@ rows: 1
> C D
@ rows: 2
# Statements without result sets just leave that section empty
update t set x = 1;
@ rows: 3
]]></text><html>
<p>

View File

@ -14166,11 +14166,16 @@ select 'A';
> A
@ rows: 1
select 'A', 'B';
select 'A', 'B' union all 'C', 'D';
> A B
> - -
> A B
@ rows: 1
> C D
@ rows: 2
# Statements without result sets just leave that section empty
update t set x = 1;
@ rows: 3
]]></text><html>
<p>

View File

@ -14302,11 +14302,16 @@ select 'A';
> A
@ rows: 1
select 'A', 'B';
select 'A', 'B' union all 'C', 'D';
> A B
> - -
> A B
@ rows: 1
> C D
@ rows: 2
# Statements without result sets just leave that section empty
update t set x = 1;
@ rows: 3
]]></text><html>
<p>

View File

@ -283,7 +283,7 @@ public class MockFileDatabase implements MockDataProvider {
MockResult mock = parse(line);
results.add(mock);
if (log.isDebugEnabled()) {
if (mock.data != null && log.isDebugEnabled()) {
String comment = "Loaded Result";
for (String l : mock.data.format(5).split("\n")) {
@ -298,13 +298,15 @@ public class MockFileDatabase implements MockDataProvider {
if (rowString.startsWith("@ rows:"))
rows = Integer.parseInt(rowString.substring(7).trim());
MockResult result = new MockResult(rows,
nullLiteral == null
? create.fetchFromTXT(currentResult.toString())
: create.fetchFromTXT(currentResult.toString(), nullLiteral)
);
String resultText = currentResult.toString();
MockResult result = resultText.isEmpty()
? new MockResult(rows)
: new MockResult(rows, nullLiteral == null
? create.fetchFromTXT(resultText)
: create.fetchFromTXT(resultText, nullLiteral)
);
if (rows != result.data.size())
if (result.data != null && rows != result.data.size())
throw new MockFileDatabaseException("Rows mismatch. Declared: " + rows + ". Actual: " + result.data.size() + ".");
return result;