Skip to content

Instantly share code, notes, and snippets.

@johnbender
Created January 17, 2009 18:34
Show Gist options
  • Save johnbender/48410 to your computer and use it in GitHub Desktop.
Save johnbender/48410 to your computer and use it in GitHub Desktop.
format_query({parts, {table, Name}, {columns, Columns}, Op, Ord}) ->
ColStr = format_columns(Name, Columns),
format_query({parts, {table, Name}, ColStr, Op, Ord});
format_query({parts, {table, Name}, Col, {operations, Ops}, Ord}) ->
OpStr = format_ops(Name, Ops),
format_query({parts, {table, Name}, Col, OpStr, Ord});
format_query({parts, {table, Name}, Col, Op, Ord}) ->
TableGen = format_generator(Name),
format_query({parts, TableGen, Col, Op, Ord});
format_query({parts, Table, Col, Op, {order, Ord}}) ->
format_query({parts, Table, Col, Op, ""});
%%!!must be last to finalize the formatted query, the ordering might take place
format_query({parts, Table, Col, Op, Ord}) -> "[" ++ string:join([Col, Table, Op], " ") ++ "]".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment