Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11 from BornaP/remove-db-requirement-for-conn
Browse files Browse the repository at this point in the history
Enable connecting to server without specifying database
  • Loading branch information
maxcnunes committed Apr 12, 2016
2 parents af3a9bb + 3e8b4eb commit 7910e9c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions spec/db.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/db/clients/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
];

Expand Down
1 change: 0 additions & 1 deletion src/validators/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down

0 comments on commit 7910e9c

Please sign in to comment.