1+ 'use strict' ;
2+
13var util = require ( 'util' ) ;
24var assert = require ( 'assert' ) ;
35var From = require ( __dirname + '/../node/from' ) ;
46var Parameter = require ( __dirname + '/../node/parameter' ) ;
57var Postgres = function ( ) {
68 this . output = [ ] ;
79 this . params = [ ] ;
8- }
10+ } ;
911
1012Postgres . prototype . getQuery = function ( queryNode ) {
1113 this . visitQuery ( queryNode ) ;
1214 return { text : this . output . join ( ' ' ) , values : this . params } ;
13- }
15+ } ;
1416
1517
1618Postgres . prototype . visit = function ( node ) {
@@ -47,17 +49,17 @@ Postgres.prototype.visit = function(node) {
4749 return this . visitModifier ( node ) ;
4850 default : throw new Error ( "Unrecognized node type " + node . type ) ;
4951 }
50- }
52+ } ;
5153
5254Postgres . prototype . quote = function ( word ) {
5355 return '"' + word + '"' ;
54- }
56+ } ;
5557
5658Postgres . prototype . visitSelect = function ( select ) {
5759 var result = [ 'SELECT' , select . nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) ] ;
5860 this . _selectOrDeleteEndIndex = this . output . length + result . length ;
5961 return result ;
60- }
62+ } ;
6163
6264Postgres . prototype . visitInsert = function ( insert ) {
6365 var self = this ;
@@ -81,12 +83,13 @@ Postgres.prototype.visitInsert = function(insert) {
8183 'VALUES' , paramNodes
8284 ] ;
8385 return result ;
84- }
86+ } ;
8587
8688Postgres . prototype . visitUpdate = function ( update ) {
8789 //don't auto-generate from clause
8890 this . _visitedFrom = true ;
8991 var params = [ ] ;
92+ /*jshint boss: true */
9093 for ( var i = 0 , node ; node = update . nodes [ i ] ; i ++ ) {
9194 this . _visitingUpdateTargetColumn = true ;
9295 var target_col = this . visit ( node ) ;
@@ -100,12 +103,12 @@ Postgres.prototype.visitUpdate = function(update) {
100103 params . join ( ', ' )
101104 ] ;
102105 return result ;
103- }
106+ } ;
104107
105108Postgres . prototype . visitDelete = function ( ) {
106109 this . _selectOrDeleteEndIndex = 1 ;
107110 return [ 'DELETE' ] ;
108- }
111+ } ;
109112
110113Postgres . prototype . visitCreate = function ( create ) {
111114 this . _visitingCreate = true ;
@@ -120,7 +123,7 @@ Postgres.prototype.visitCreate = function(create) {
120123 result . push ( '(' + col_nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) + ')' ) ;
121124 this . _visitingCreate = false ;
122125 return result ;
123- }
126+ } ;
124127
125128Postgres . prototype . visitDrop = function ( drop ) {
126129 //don't auto-generate from clause
@@ -129,7 +132,7 @@ Postgres.prototype.visitDrop = function(drop) {
129132 result = result . concat ( drop . nodes . map ( this . visit . bind ( this ) ) ) ;
130133 result . push ( this . visit ( this . _queryNode . table . toNode ( ) ) ) ;
131134 return result ;
132- }
135+ } ;
133136
134137Postgres . prototype . visitAlter = function ( alter ) {
135138 this . _visitingAlter = true ;
@@ -144,7 +147,7 @@ Postgres.prototype.visitAlter = function(alter) {
144147 ] ;
145148 this . _visitingAlter = false ;
146149 return result ;
147- }
150+ } ;
148151
149152Postgres . prototype . visitFrom = function ( from ) {
150153 this . _visitedFrom = true ;
@@ -154,22 +157,22 @@ Postgres.prototype.visitFrom = function(from) {
154157 result = result . concat ( this . visit ( from . nodes [ i ] ) ) ;
155158 }
156159 return result ;
157- }
160+ } ;
158161
159162Postgres . prototype . visitWhere = function ( where ) {
160- var result = [ 'WHERE' , where . nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) ]
163+ var result = [ 'WHERE' , where . nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) ] ;
161164 return result ;
162- }
165+ } ;
163166
164167Postgres . prototype . visitOrderBy = function ( orderBy ) {
165168 var result = [ 'ORDER BY' , orderBy . nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) ] ;
166169 return result ;
167- }
170+ } ;
168171
169172Postgres . prototype . visitGroupBy = function ( groupBy ) {
170173 var result = [ 'GROUP BY' , groupBy . nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) ] ;
171174 return result ;
172- }
175+ } ;
173176
174177Postgres . prototype . visitBinary = function ( binary ) {
175178 var self = this ;
@@ -184,11 +187,11 @@ Postgres.prototype.visitBinary = function(binary) {
184187 }
185188 result += ')' ;
186189 return result ;
187- }
190+ } ;
188191
189192Postgres . prototype . visitUnary = function ( unary ) {
190193 return '(' + this . visit ( unary . left ) + ' ' + unary . operator + ')' ;
191- }
194+ } ;
192195
193196Postgres . prototype . visitQuery = function ( queryNode ) {
194197 this . _queryNode = queryNode ;
@@ -204,7 +207,7 @@ Postgres.prototype.visitQuery = function(queryNode) {
204207 this . output = select . concat ( from ) . concat ( rest ) ;
205208 }
206209 return this ;
207- }
210+ } ;
208211
209212Postgres . prototype . visitSubquery = function ( queryNode ) {
210213 var result = [ ] ;
@@ -222,21 +225,21 @@ Postgres.prototype.visitSubquery = function(queryNode) {
222225 result [ 0 ] = '(' + result [ 0 ] ;
223226 result [ result . length - 1 ] = result [ result . length - 1 ] + ') ' + queryNode . alias ;
224227 return result ;
225- }
228+ } ;
226229
227230Postgres . prototype . visitTable = function ( tableNode ) {
228231 var table = tableNode . table ;
229232 var txt = "" ;
230233 if ( table . getSchema ( ) ) {
231234 txt = this . quote ( table . getSchema ( ) ) ;
232- txt += '.'
235+ txt += '.' ;
233236 }
234237 txt += this . quote ( table . getName ( ) ) ;
235238 if ( table . alias ) {
236239 txt += ' AS ' + table . alias ;
237240 }
238241 return txt ;
239- }
242+ } ;
240243
241244Postgres . prototype . visitColumn = function ( columnNode ) {
242245 var table = columnNode . table ;
@@ -278,41 +281,41 @@ Postgres.prototype.visitColumn = function(columnNode) {
278281 txt += ' ' + columnNode . dataType ;
279282 }
280283 return txt ;
281- }
284+ } ;
282285
283286Postgres . prototype . visitParameter = function ( parameter ) {
284287 this . params . push ( parameter . value ( ) ) ;
285288 return "$" + this . params . length ;
286- }
289+ } ;
287290
288291Postgres . prototype . visitDefault = function ( parameter ) {
289292 var params = this . params ;
290293 this . params . push ( 'DEFAULT' ) ;
291294 return "$" + params . length ;
292- }
295+ } ;
293296
294297Postgres . prototype . visitAddColumn = function ( addColumn ) {
295298 this . _visitingAddColumn = true ;
296- var result = [ 'ADD COLUMN ' + this . visit ( addColumn . nodes [ 0 ] ) ]
299+ var result = [ 'ADD COLUMN ' + this . visit ( addColumn . nodes [ 0 ] ) ] ;
297300 this . _visitingAddColumn = false ;
298301 return result ;
299- }
302+ } ;
300303
301304Postgres . prototype . visitDropColumn = function ( dropColumn ) {
302305 return [ 'DROP COLUMN ' + this . visit ( dropColumn . nodes [ 0 ] ) ] ;
303- }
306+ } ;
304307
305308Postgres . prototype . visitRenameColumn = function ( renameColumn ) {
306309 return [ 'RENAME COLUMN ' + this . visit ( renameColumn . nodes [ 0 ] ) + ' TO ' + this . visit ( renameColumn . nodes [ 1 ] ) ] ;
307- }
310+ } ;
308311
309312Postgres . prototype . visitIfExists = function ( ) {
310313 return [ 'IF EXISTS' ] ;
311- }
314+ } ;
312315
313316Postgres . prototype . visitIfNotExists = function ( ) {
314317 return [ 'IF NOT EXISTS' ] ;
315- }
318+ } ;
316319
317320Postgres . prototype . visitJoin = function ( join ) {
318321 var result = [ ] ;
@@ -322,14 +325,14 @@ Postgres.prototype.visitJoin = function(join) {
322325 result = result . concat ( 'ON' ) ;
323326 result = result . concat ( this . visit ( join . on ) ) ;
324327 return result ;
325- }
328+ } ;
326329
327330Postgres . prototype . visitReturning = function ( returning ) {
328331 return [ 'RETURNING' , returning . nodes . map ( this . visit . bind ( this ) ) . join ( ', ' ) ] ;
329- }
332+ } ;
330333
331334Postgres . prototype . visitModifier = function ( node ) {
332335 return [ node . type , node . count ] ;
333- }
336+ } ;
334337
335338module . exports = Postgres ;
0 commit comments