FlowKit icon indicating copy to clipboard operation
FlowKit copied to clipboard

Should be able to instantiate Query without a connection

Open maxalbert opened this issue 6 years ago • 3 comments

Currently the code in Query.__init__() raises an error if no valid connection to flowdb exists.

This has various disadvantages. For example, it makes it necessary to create connections in all tests that use a flowmachine query, even if they don't require running it. A more subtle downside is that it encourages to write tests in a more integrationy style (typically running against the database and checking the result, which slows down the test suite) rather than encouraging a design which allows for more unit-style tests.

It would be beneficial if Query objects could be instantiated without requiring an active connection to flowdb (e.g. by passing a dummy connection).

maxalbert avatar Feb 15 '19 10:02 maxalbert

Definitely. Historical reason for this is that in some cases, the query needs to check against FlowDB to know if there's any chance it can be successfully run (e.g. are there missing dates), or in a few cases, to require another query to be written as a table (e.g. Random). Obviously one can either pass in the connection to init for those cases, or add a secondary pre-flight checks method that does this.

greenape avatar Feb 20 '19 09:02 greenape

Closed via #1999

greenape avatar Mar 10 '20 12:03 greenape

I'm reopening this because while there's no longer a dependence on Query.connection a connection is still required at init.

greenape avatar Oct 21 '21 11:10 greenape