jsharmony-db-mssql
Version:
jsHarmony Database Connector for SQL Server
48 lines (38 loc) • 1.8 kB
JavaScript
/*
Copyright 2020 apHarmony
This file is part of jsHarmony.
jsHarmony is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
jsHarmony is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this package. If not, see <http://www.gnu.org/licenses/>.
*/
var JSHmssql = require('../index');
var JSHdb = require('jsharmony-db');
var shouldGenerateFormSql = require('jsharmony-db/test/shared/sql');
var path = require('path');
var fs = require('fs');
var _ = require('lodash');
var os = require('os');
var dbconfig = { };
var path_TestDBConfig = path.join(os.homedir(),'jsharmony/testdb_mssql.json');
if(fs.existsSync(path_TestDBConfig)){
dbconfig = JSON.parse(fs.readFileSync(path_TestDBConfig,'utf8'));
console.log('\r\n==== Loading test database config ====\r\n'+JSON.stringify(dbconfig,null,4)+'\r\n');
}
dbconfig = _.extend({_driver: new JSHmssql(), host: "server.domain.com", database: "DBNAME", user: "DBUSER", password: "DBPASS", options: { pooled: true }, pool: { max: 1 } },dbconfig);
var db = new JSHdb(dbconfig);
var sqlFuncs = {
DropTableIfExists: {
params: ['TABLE'],
sql: "IF OBJECT_ID('%%%TABLE%%%', 'U') is not null drop table %%%TABLE%%%",
}
};
describe('MSSQL forms',function(){
shouldGenerateFormSql(db, JSHdb, 'integer primary key identity', 'timestamp', sqlFuncs);
});