Skip to content

Commit

Permalink
Add SQLite index name collision test case
Browse files Browse the repository at this point in the history
  • Loading branch information
dxg committed May 20, 2014
1 parent 8e8ce96 commit 88019cf
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/integration/model-sync.js
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();
});
});
});

0 comments on commit 88019cf

Please sign in to comment.