File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -689,7 +689,7 @@ Postgres.prototype.visitTable = function(tableNode) {
689
689
txt += '.' ;
690
690
}
691
691
txt += this . quote ( table . getName ( ) ) ;
692
- if ( table . alias ) {
692
+ if ( typeof table . alias === 'string' ) {
693
693
txt += this . _aliasText + this . quote ( table . alias ) ;
694
694
}
695
695
return [ txt ] ;
@@ -729,7 +729,7 @@ Postgres.prototype.visitColumn = function(columnNode) {
729
729
}
730
730
}
731
731
if ( ! inInsertUpdateClause && ! this . visitingReturning && ! this . _visitingCreate && ! this . _visitingAlter && ! columnNode . subfieldContainer ) {
732
- if ( table . alias ) {
732
+ if ( typeof table . alias === 'string' ) {
733
733
txt . push ( this . quote ( table . alias ) ) ;
734
734
} else {
735
735
if ( table . getSchema ( ) ) {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ var sql = require(__dirname + '/../lib');
6
6
describe ( 'column' , function ( ) {
7
7
var table = sql . define ( {
8
8
name : 'user' ,
9
- columns : [ 'id' , 'created' ]
9
+ columns : [ 'id' , 'created' , 'alias' ]
10
10
} ) ;
11
11
12
12
it ( 'can be accessed by property and array' , function ( ) {
@@ -18,6 +18,10 @@ describe('column', function() {
18
18
assert . equal ( table . id . toQuery ( ) . text , '"user"."id"' ) ;
19
19
} ) ;
20
20
21
+ it ( 'works with a column name of "alias"' , function ( ) {
22
+ assert . equal ( table . alias . toQuery ( ) . text , '"user"."alias"' ) ;
23
+ } ) ;
24
+
21
25
it ( 'respects AS rename' , function ( ) {
22
26
assert . equal ( table . id . as ( 'userId' ) . toQuery ( ) . text , '"user"."id" AS "userId"' ) ;
23
27
} ) ;
You can’t perform that action at this time.
0 commit comments