Skip to content

Commit d61bdae

Browse files
committed
create on indexes
1 parent 0bd0ee7 commit d61bdae

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

lib/node/indexes.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
var Node = require(__dirname);
44
var IndexesNode = module.exports = Node.define({
55
type: 'INDEXES',
6-
constructor: function () {
6+
7+
constructor: function(table) {
78
Node.call(this);
8-
this.names = [];
9-
this.columns = [];
9+
this.table = table;
10+
this.names = [];
11+
this.columns = [];
1012
this.valueSets = [];
1113
}
1214
});

lib/node/query.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ var Query = Node.define({
229229
return this;
230230
},
231231
indexes: function() {
232-
this.add(new Indexes());
232+
var indexes = new Indexes({ table: this.table });
233+
this.add(indexes);
233234
return this;
234235
}
235236
});

lib/table.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,6 @@ Table.prototype.indexes = function() {
210210
var query = new Query(this);
211211
query.indexes.apply(query, arguments);
212212
return query;
213-
}
213+
};
214214

215215
module.exports = Table;

test/dialects/indexes-tests.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ Harness.test({
99
mysql: "SHOW INDEX FROM `post`",
1010
sqlite: "PRAGMA INDEX_LIST(\"post\")"
1111
});
12+
13+
Harness.test({
14+
query: post.indexes().create({
15+
type: 'unique',
16+
algorithm: 'btree',
17+
parser: 'foo',
18+
name: 'bar',
19+
columns: [post.id, post.userId]
20+
}),
21+
mysql: "CREATE UNIQUE INDEX `bar` USING BTREE ON `post` (`post`.`id`, `post`.`userId`) WITH PARSER foo"
22+
})

0 commit comments

Comments
 (0)