From 0568a5a36175b64abe0afa32aee8efe0c23a31d0 Mon Sep 17 00:00:00 2001 From: lukaseder Date: Mon, 17 Dec 2018 12:49:12 +0100 Subject: [PATCH] [#8124] Support regular expressions in MockFileDatabase --- .../resources/org/jooq/web/manual-3.12.xml | 49 ++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml index 087aeee3db..88a84a4117 100644 --- a/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml +++ b/jOOQ-manual/src/main/resources/org/jooq/web/manual-3.12.xml @@ -14330,7 +14330,7 @@ update t set x = 1; The above database supports exactly two statements in total, and is completely stateless (e.g. an INSERT statement cannot be made to affect the results of a subsequent SELECT statement on the same table). It can be loaded through the MockFileDatabase can be used as follows:

- result = create.select(inline("C")).fetch();]]>

In situations where the expected set of queries are well-defined, the MockFileDatabase can offer a very effective way of mocking parts of the database engine, without offering the complete functionality of the .

+ +

Matching statements using regular expressions

+ +

+ Alternatively, regular expressions can be used to match statements in order of definition in the file. +

+ + A B +> - - +> A B +@ rows: 1 + +# All other select statements are assumed to return only a column A +select .*; +> A +> - +> A +@ rows: 1 +]]> + +

+ The same rules apply as before. The first matching statement will be applied for any given input statement. +

+ +

+ This feature is "opt-in", so it has to be configured appropriately: +

+ + result = create.select(inline("X")).fetch(); + +// This returns columns A and B +Result result = create.select(inline("A"), inline("B"), inline("C")).fetch();]]>