Skip to content

Commit dc1987b

Browse files
author
Eric Sessoms
committed
lints cleanly
1 parent ce775dc commit dc1987b

56 files changed

Lines changed: 222 additions & 103 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.jshintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"node": true
3+
}

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.PHONY: jshint test
2+
3+
jshint:
4+
jshint lib test
5+
6+
test:
7+
npm test

lib/column.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var ColumnNode = require(__dirname + '/node/column');
24
var ParameterNode = require(__dirname + '/node/parameter');
35
var BinaryNode = require(__dirname + '/node/binary');
@@ -41,50 +43,50 @@ var unaryMethod = function(name, operator) {
4143
left: this.toNode(),
4244
operator: operator
4345
});
44-
}
45-
}
46+
};
47+
};
4648

4749
var contextify = function(base) {
4850
var context = Object.create(Column.prototype);
4951
Object.keys(base).forEach(function (key) {
5052
context[key] = base[key];
51-
})
53+
});
5254
return context;
53-
}
55+
};
5456

5557
Column.prototype.value = function(value) {
5658
this._value = value;
5759
return this;
58-
}
60+
};
5961

6062
Column.prototype.getValue = function() {
6163
return this._value;
62-
}
64+
};
6365

6466
Column.prototype.toNode = function() {
6567
//creates a query node from this column
6668
return new ColumnNode(contextify(this));
67-
}
69+
};
6870

6971
Column.prototype.as = function(alias) {
7072
var context = contextify(this);
7173
context.alias = alias;
7274
return new ColumnNode(context);
73-
}
75+
};
7476

7577
Column.prototype.arrayAgg = function(alias) {
7678
var context = contextify(this);
7779
context.asArray = true;
7880
context.alias = alias || context.name + 's';
7981
return new ColumnNode(context);
80-
}
82+
};
8183

8284
Column.prototype.count = function(alias) {
8385
var context = contextify(this);
8486
context.aggCount = true;
8587
context.alias = alias || context.name + '_count';
8688
return new ColumnNode(context);
87-
}
89+
};
8890

8991
binaryMethod('equals', '=');
9092
binaryMethod('equal', '=');

lib/dialect/postgres.js

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
'use strict';
2+
13
var util = require('util');
24
var assert = require('assert');
35
var From = require(__dirname + '/../node/from');
46
var Parameter = require(__dirname + '/../node/parameter');
57
var Postgres = function() {
68
this.output = [];
79
this.params = [];
8-
}
10+
};
911

1012
Postgres.prototype.getQuery = function(queryNode) {
1113
this.visitQuery(queryNode);
1214
return { text: this.output.join(' '), values: this.params };
13-
}
15+
};
1416

1517

1618
Postgres.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

5254
Postgres.prototype.quote = function(word) {
5355
return '"' + word + '"';
54-
}
56+
};
5557

5658
Postgres.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

6264
Postgres.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

8688
Postgres.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

105108
Postgres.prototype.visitDelete = function() {
106109
this._selectOrDeleteEndIndex = 1;
107110
return ['DELETE'];
108-
}
111+
};
109112

110113
Postgres.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

125128
Postgres.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

134137
Postgres.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

149152
Postgres.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

159162
Postgres.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

164167
Postgres.prototype.visitOrderBy = function(orderBy) {
165168
var result = ['ORDER BY', orderBy.nodes.map(this.visit.bind(this)).join(', ')];
166169
return result;
167-
}
170+
};
168171

169172
Postgres.prototype.visitGroupBy = function(groupBy) {
170173
var result = ['GROUP BY', groupBy.nodes.map(this.visit.bind(this)).join(', ')];
171174
return result;
172-
}
175+
};
173176

174177
Postgres.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

189192
Postgres.prototype.visitUnary = function(unary) {
190193
return '(' + this.visit(unary.left) + ' ' + unary.operator + ')';
191-
}
194+
};
192195

193196
Postgres.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

209212
Postgres.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

227230
Postgres.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

241244
Postgres.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

283286
Postgres.prototype.visitParameter = function(parameter) {
284287
this.params.push(parameter.value());
285288
return "$"+this.params.length;
286-
}
289+
};
287290

288291
Postgres.prototype.visitDefault = function(parameter) {
289292
var params = this.params;
290293
this.params.push('DEFAULT');
291294
return "$"+params.length;
292-
}
295+
};
293296

294297
Postgres.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

301304
Postgres.prototype.visitDropColumn = function(dropColumn) {
302305
return ['DROP COLUMN ' + this.visit(dropColumn.nodes[0])];
303-
}
306+
};
304307

305308
Postgres.prototype.visitRenameColumn = function(renameColumn) {
306309
return ['RENAME COLUMN ' + this.visit(renameColumn.nodes[0]) + ' TO ' + this.visit(renameColumn.nodes[1])];
307-
}
310+
};
308311

309312
Postgres.prototype.visitIfExists = function() {
310313
return ['IF EXISTS'];
311-
}
314+
};
312315

313316
Postgres.prototype.visitIfNotExists = function() {
314317
return ['IF NOT EXISTS'];
315-
}
318+
};
316319

317320
Postgres.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

327330
Postgres.prototype.visitReturning = function(returning) {
328331
return ['RETURNING', returning.nodes.map(this.visit.bind(this)).join(', ')];
329-
}
332+
};
330333

331334
Postgres.prototype.visitModifier = function(node) {
332335
return [node.type, node.count];
333-
}
336+
};
334337

335338
module.exports = Postgres;

lib/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var Table = require(__dirname + '/table');
24

35
var sql = {

lib/node/addColumn.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var Node = require(__dirname);
24

35
module.exports = Node.define({

lib/node/alter.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var Node = require(__dirname);
24

35
module.exports = Node.define({

lib/node/binary.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var BinaryNode = module.exports = require(__dirname).define({
24
type: 'BINARY',
35
constructor: function(config) {
@@ -19,4 +21,4 @@ var BinaryNode = module.exports = require(__dirname).define({
1921
right: node
2022
});
2123
}
22-
})
24+
});

lib/node/column.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var Node = require(__dirname);
24

35
module.exports = Node.define({

lib/node/create.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var Node = require(__dirname);
24

35
module.exports = Node.define({

0 commit comments

Comments
 (0)