Closed brendanator closed 9 years ago
After a long chat with @DavidGregory084 it would seem as though it is nigh on impossible to implement this and determine all the columns that are used in an extractor - the extractor would have to be run to determine this. The columns are needed so a select statement knows which columns to select
A compromise solution is to implement something like this
def choice[B](choices: Tuple[A, Extractor[B]]*): Extractor[B]
val contactDetailsExtractor = contactTypeExtractor.choice (
"Email" -> emailExtractor,
"Post" -> addressExtractor
)
Maybe a better name than choice
can be thought of
Either that or we write a really gnarly macro that traverses the tree of extractors that's returned by our A => Extractor[B]
looking for CellExtractor
s that are also AliasedColumn
s. This would probably have quite a few limitations and enforce a rigid syntax by aborting when the expressions in the function were not of the form case (a, b, c) => abcExtractor
.
This will allow the following sort of code
sqlest needs to know the extractors that are contained within another extractor so the
flatMap
method will have to be a macro that determines all the extractors used with the function