brianc/node-sql

Aliased column with scalar functions

Closed this issue · 1 comments

The following example produces invalid sql if the column is aliased.

var sql = require('sql');
var f = sql.functions;

var user = sql.define({
  name: 'user',
  columns: [
    { name: 'id' },
    { name: 'age', property: 'howOld' }
  ]
});

console.log(f.ROUND(user.howOld, 2).toString());

The output is:
ROUND("user"."age" AS "howOld", 2)

The alias should not be included.

+1