diff --git a/spec/db.spec.js b/spec/db.spec.js index a22f5fc..e1db5cd 100644 --- a/spec/db.spec.js +++ b/spec/db.spec.js @@ -39,6 +39,20 @@ describe('db', () => { return expect(dbConn.connect()).to.not.be.rejected; }); + + it('should connect into server without database specified', () => { + const serverInfo = { + ...config[dbClient], + database: db.CLIENTS.find(c => c.key === dbClient).defaultDatabase, + name: dbClient, + client: dbClient, + }; + + const serverSession = db.createServer(serverInfo); + const dbConn = serverSession.createConnection(serverInfo.database); + + return expect(dbConn.connect()).to.not.be.rejected; + }); }); describe('given is already connected', () => { diff --git a/src/db/clients/index.js b/src/db/clients/index.js index 1108914..bf8bfd1 100644 --- a/src/db/clients/index.js +++ b/src/db/clients/index.js @@ -8,7 +8,7 @@ import sqlserver from './sqlserver'; */ export const CLIENTS = [ { key: 'mysql', name: 'MySQL' }, - { key: 'postgresql', name: 'PostgreSQL' }, + { key: 'postgresql', name: 'PostgreSQL', defaultDatabase: 'postgres' }, { key: 'sqlserver', name: 'Microsoft SQL Server' }, ]; diff --git a/src/validators/server.js b/src/validators/server.js index fa340cd..fadf7b6 100644 --- a/src/validators/server.js +++ b/src/validators/server.js @@ -89,7 +89,6 @@ const SERVER_SCHEMA = { ], database: [ { sanitizer: Valida.Sanitizer.trim }, - { validator: Valida.Validator.required }, { validator: Valida.Validator.len, min: 1, max: 100 }, ], user: [