refactor: Break up initial sql query generation.
refactor: Break up initial sql query generation.

Instead of generating one large string, we now build up an array of
option string parts and join these up to generate the final initial sql
query.

pekim/tedious,tediousjs/tedious,tediousjs/tedious