Sometimes I play with monads to create my queries and I finish with things like that :
filter1 : ROM::SQL::Attribute
filter2 : ROM::SQL::Attribute
maybe_filter3 : Maybe(ROM::SQL::Attribute)
filter1 & filter2 & maybe_filter3.value_or(identity) # I would love this
As I don’t know where of if there is an identity inside ROM, I do this instead :
With this input, I will transform it into an SQL query.
Each addon modify by little the query, but sometimes some part of the database should not be filtered, like the analysis.
The base query builder will have a method like this:
def extract_analysis_level
None()
end
And an addon could have this
def extract_analysis_level
Some(dimensions[:value].not(nil))
end