brianc / node-sql

SQL generation for node.js
MIT License
1.05k stars 191 forks source link

Alias a query with AS #329

Closed danrzeppa closed 8 years ago

danrzeppa commented 8 years ago

Adds ability to alias a query using AS. For example:

var query=sql.select(
  post.select(post.count()).as("column1"),
  user.select(user.count()).as("column2")
)

will generate (properly quoted):

SELECT (SELECT COUNT(*) FROM post) AS "column1", (SELECT COUNT(*) FROM user) as "column2"
danrzeppa commented 8 years ago

It looks like I've somehow managed to get the code from pull request #302 in this request as well. Is that going to be a problem since #302 is read to merge anyways?

brianc commented 8 years ago

It shouldn't be a problem! I can merge 'em both & push a new version to the ol' npm. :smile: btw - would you like access to the npm publishing rights as well? I don't wanna be a blocker for you if you've got some new features you want to use & are just waiting on me.