On Sat, Feb 2, 2019 at 11:34 PM hashim muqtadir <hashim.muqta...@gmail.com> wrote:
> > As long as you at least know the schema you're working with, you could > even generate select statements for all possible sets of columns at compile > time, and then just choose the right statement dynamically with a runtime > function. > > That did occur to me, and was my other idea compared to eval, up until I'd > figured out the INJECT thing, but I didn't do it as then there would be a > huge amount of select statements. The idea was to basically take the column > list, sort it, string-join, and then get the relevant select from a hash > table. But there'd be way too many. > > … > > One of the problems we face is of moving too much data around. Mobile > applications that have to mainly work offline and periodically sync, they > have to move around lots of data on horrible connections. (We do gzip and > all. Choosing a data format that's not json is an option I'll evaluate in > the future.) > > So selecting a list of fields when getting data for different entites is > something we provide in our APIs. > It occurred to me you could also consider a sort of middle option. The `sql` library can already handle dynamically filling in the names and order of the columns to select: the only restriction is that the *number* of columns must be specified at compile-time (aside from with `ScalarExpr:INJECT`). So, if you know your table has N columns, you could generate select statements for 1 to N columns, with the names of the columns to be filled in at runtime. That would do much less code generation than compiling a select statement for every possible combination of columns (or, worse, permutation), while also being less of a hack than `ScalarExpr:INJECT` (which I still think is a reasonable workaround). You could use a `case` expression or a vector of functions for dispatch. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.