I used to do a lot of mocks for database inside of functional tests and, sometimes, it's difficult to read all the information there so, I think the better is implemente the capability functional tests can be extended, for example...
<functional>
...
<dbi xmlns="dbi:dbi_tests">
<query><![CDATA[SELECT * FROM mitable WHERE name = $1]]></query>
<params>
<param id="1">Alice</param>
</params>
<result type="JSON"><![CDATA[
["Alice", "female", 1970]
]]></result>
<send event="queried"/>
</dbi>
...
</functional>
In Params we can use:
To accept whatever param in that position and, the query can use:
<query type="begins_with"><![CDATA[SELECT * FROM mytable]]></query>
And then the query can match with whatever query, even if we adds GROUP BY, ORDER BY, WHERE, ...
About events:
This is equivalent to the next code, inside of the code part of the mock:
(_,_,_) -> PID ! queried, {"Alice", "female", 1970}