rockdai / sql-bricks

Transparent, Schemaless SQL Generation
http://csnw.github.io/sql-bricks
MIT License
213 stars 25 forks source link

Add a hook to allow complex aliases #49

Closed Suor closed 10 years ago

Suor commented 10 years ago

To allow queries like SELECT * FROM (VALUES ($1, $2), ($3, $4)) V (name, value)

prust commented 10 years ago

@Suor: Thanks!

I'm not so sure about the "str" prefix in _strAlias indicating that it's a function... also you have to duplicate the ._alias logic... What if we put the responsibility on the Statement to be able to stringify itself as a nested expression (Statement._toNestedString()) and split out the current alias stringify to its own method (_aliasToString()) so you can re-use it? See #50 for an proposed implementation...