-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SQLite index name collision test case
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var _ = require('lodash'); | ||
var should = require('should'); | ||
var helper = require('../support/spec_helper'); | ||
var ORM = require('../../'); | ||
var common = require('../common'); | ||
|
||
describe("Model.sync", function () { | ||
var db = null; | ||
|
||
before(function(done) { | ||
helper.connect(function (connection) { | ||
db = connection; | ||
done(); | ||
}); | ||
}); | ||
|
||
after(function () { | ||
db.close(); | ||
}); | ||
|
||
// SQLite scopes index names to a database and NOT a table, so | ||
// index name collisions were possible. This tests the workaround. | ||
it("should work with multiple same-named indexes", function (done) { | ||
var A, B, C; | ||
|
||
A = db.define('a', { name: String }); | ||
B = db.define('b', { name: String }); | ||
C = db.define('c', { name: String }); | ||
|
||
A.hasMany('bees', B, {}, { reverse: 'eighs' }); | ||
A.hasMany('cees', C, {}, { reverse: 'eighs' }); | ||
|
||
helper.dropSync([A, B, C], function (err) { | ||
should.not.exist(err); | ||
done(); | ||
}); | ||
}); | ||
}); |