knex/scripts/wait-for-mssql-server.js
Mikael Lepistö b349ac4a8c
Various fixes to mssql dialect (#2653)
* Fixed float type of mssql to be float

* Many tests where postgres test was not actually ran at all

* Migrations to be mssql compatible

Mssql driver doesn't handle if multiple queries are sent to same transaction concurrently.

* Prevented mssql failing when invalid schema builder was executed by accident

Instead of trying to generate sql from broken schema calls, just make exception to leak before query compiling is started

* Fixed mssql trx rollback to always throw an error

Also modified some connection test query to be mssql compatible

* Fixed various bugs from MSSQL driver to make tests run

* Fixed mssql unique index to be compatible with other dialect implementations

* Enable running mssql tests on CI

* Test for #2588

* Updated tests to not be dependend on tables left from previous test rans

* Trying to make mssql server work on travis
2018-06-29 10:47:06 +03:00

51 lines
1.2 KiB
JavaScript

var Connection = require('tedious').Connection;
var config = {
userName: "sa",
password: "S0meVeryHardPassword",
server: "localhost",
options: {
database: "knex_test",
}
};
let didConnect = false;
let tryCount = 0;
function tryToConnect() {
tryCount++;
if (tryCount > 50) {
console.log("Giving up... it fails if it fails");
process.exit(0);
}
console.log("Connecting... to mssql");
var connection = new Connection(config);
connection.on('end', () => {
if (!didConnect) {
console.log("Couldnt connnect yet... try again in two secs...");
setTimeout(tryToConnect, 2000);
}
});
connection.on('error', () => {
// prevent leaking errors.. driver seems to sometimes emit error event,
// sometimes connect event with error
// and some times just closes connection without error / connect events
// (debug event says that socket was ended and thats it...)
});
connection.on('connect', (err) => {
if (!err) {
console.log("Connecting mssql server was a great success!");
didConnect = true;
} else {
console.log("Error was passed to connect event.");
}
connection.close();
});
}
tryToConnect();