WIP: Implement multiline query output #230
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first pass at adding support for matching query output line by line without attempting to parse column types and values. The general idea here is that we can use a
query multiline
directive to compare query results line by line, rather than attempting to parse and validate individual values. The idea being that this allows custom database drivers to just output formatted tables like such:So far this PR appears to behave as intended by applying it to a personal project. The testing is extremely light, and there are a few different ways I could see implementing this feature. However, this seemed like the most direct approach after I spent at least 30m skimming the current implementation. I have verified that both matching and file updating work from the library implementation. I have not run this against the CLI version or attempted to add engine support. I can look into adding that as well if its desired.
The implementation is slightly wonky in that it just relies on the implementations of DB and AsyncDB to return a new DBOutput::MultiLine variant from the
run(sql: &str)
method. However, given the current state of those traits, I don't think there's much better to be done at the moment.Speaking of those traits, and improving things, I think it'd be possible to do a progressive upgrade to those traits to add
run_statement
,run_query
, andrun_multiline_query
methods that default just callrun
. However, I didn't feel like mixing up that level of change with this PR given this is already a bit half baked.Let me know if there's any interest in me fleshing this out into a full PR with lots more test coverage and any CLI/engine stuff that needs to happen. Also, thanks for sqllogictest! Its a great tool that's proving rather useful!