forked from brianc/node-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlite.js
More file actions
73 lines (55 loc) · 2.05 KB
/
sqlite.js
File metadata and controls
73 lines (55 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
var util = require('util');
var assert = require('assert');
var Sqlite = function() {
this.output = [];
this.params = [];
this._hasAddedAColumn = false;
};
var Postgres = require(__dirname + '/postgres');
util.inherits(Sqlite, Postgres);
Sqlite.prototype._myClass = Sqlite;
Sqlite.prototype._arrayAggFunctionName = 'GROUP_CONCAT';
Sqlite.prototype._getParameterValue = function(value) {
if (Buffer.isBuffer(value)) {
value = 'x' + this._getParameterValue(value.toString('hex'));
} else {
value = Postgres.prototype._getParameterValue.call(this, value);
}
return value;
};
Sqlite.prototype.visitDefault = function() {
throw new Error('SQLite requires that all rows of a multi-row insert are for the same columns.');
};
Sqlite.prototype.visitDropColumn = function() {
throw new Error('SQLite does not allow dropping columns.');
};
Sqlite.prototype.visitRenameColumn = function() {
throw new Error('SQLite does not allow renaming columns.');
};
Sqlite.prototype.visitReturning = function() {
throw new Error('SQLite does not allow returning clause.');
};
Sqlite.prototype.visitForUpdate = function() {
throw new Error('SQLite does not allow FOR UPDATE clause.');
};
Sqlite.prototype.visitForShare = function() {
throw new Error('SQLite does not allow FOR SHARE clause.');
};
Sqlite.prototype.visitAddColumn = function(addColumn) {
assert(!this._hasAddedAColumn, 'SQLite can not add more that one column at a time');
var result = Postgres.prototype.visitAddColumn.call(this, addColumn);
this._hasAddedAColumn = true;
return result;
};
Sqlite.prototype.visitIndexes = function(node) {
var tableName = this.visit(this._queryNode.table.toNode())[0];
return "PRAGMA INDEX_LIST(" + tableName + ")";
};
Sqlite.prototype.visitCascade = function() {
throw new Error('Sqlite do not support CASCADE in DROP TABLE');
};
Sqlite.prototype.visitRestrict = function() {
throw new Error('Sqlite do not support RESTRICT in DROP TABLE');
};
module.exports = Sqlite;