Make QueryBuilder backend agnostic #3632
Labels
priority/quality-of-life
would simplify development
topic/database-backend
topic/query-builder
type/refactoring
Currently the
QueryBuilder
is written with relational databases in mind, and in fact probabaly specifically with using eitherDjango
orSQLA
. This is at odds with the rest of the entities inaiida.orm
which could suppot any backend type which implements the general backend interfaces (found inaiida.orm.implementation
).There are a number of implications to this beyond just not being able to use the current implemetation should a new backend ever be added including that the methods in
QueryBuilder
are very long and come with a corresponding greater maintenance difficulty. This would be helped by splitting things up into the things general to theQueryBuilder
and things related to relational databases.Given that there is quite a bit of shared implenetation between
Django
andSQLA
(given thatSQLA
is used for querying in both cases), I would be tempted to to have a superclass for bothDjango
andSQLA
that implementsaiida.orm.implementation.BackendQueryBuilder
.Amongst other things the final implementation would:
sqlalchemy
imports inaiida.orm.QueryBuilder
sqlalchemy
imports inaiida.orm.implementation.BackendQueryBuilder
get_filter_expr
,get_filter_expr_from_column
andget_filter_expr_from_attributes
would be moved out ofaiida.orm.QueryBuilder
and down to the implemetation level only because a generalQueryBuilder
should not even rely on there being an expression that performs the query (it may just ben an API call)The text was updated successfully, but these errors were encountered: