-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(db): move db constants to other file to avoid circular ref #1858
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
SYSTEM_NAMESPACE_COLLECTION: 'system.namespaces', | ||
SYSTEM_INDEX_COLLECTION: 'system.indexes', | ||
SYSTEM_PROFILE_COLLECTION: 'system.profile', | ||
SYSTEM_USER_COLLECTION: 'system.users', | ||
SYSTEM_COMMAND_COLLECTION: '$cmd', | ||
SYSTEM_JS_COLLECTION: 'system.js' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const mock = require('mongodb-mock-server'); | ||
|
||
describe('CreateIndexError', function() { | ||
const test = {}; | ||
beforeEach(() => mock.createServer().then(_server => (test.server = _server))); | ||
afterEach(() => mock.cleanup()); | ||
|
||
it('should error when createIndex fails', function(done) { | ||
const ERROR_RESPONSE = { | ||
ok: 0, | ||
errmsg: | ||
'WiredTigerIndex::insert: key too large to index, failing 1470 { : "56f37cb8e4b089e98d52ab0e", : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa..." }', | ||
code: 17280 | ||
}; | ||
|
||
test.server.setMessageHandler(request => { | ||
const doc = request.document; | ||
|
||
if (doc.ismaster) { | ||
return request.reply(Object.assign({}, mock.DEFAULT_ISMASTER)); | ||
} | ||
|
||
if (doc.createIndexes) { | ||
return request.reply(ERROR_RESPONSE); | ||
} | ||
|
||
if (doc.insert === 'system.indexes') { | ||
return request.reply(ERROR_RESPONSE); | ||
} | ||
}); | ||
|
||
const client = this.configuration.newClient(`mongodb://${test.server.uri()}`); | ||
|
||
const close = e => client.close().then(() => done(e)); | ||
|
||
client | ||
.connect() | ||
.then(() => client.db('foo').collection('bar')) | ||
.then(coll => coll.createIndex({ a: 1 })) | ||
.then( | ||
() => close('Expected createIndex to fail, but it succeeded'), | ||
e => { | ||
try { | ||
expect(e).to.have.property('ok', ERROR_RESPONSE.ok); | ||
expect(e).to.have.property('errmsg', ERROR_RESPONSE.errmsg); | ||
expect(e).to.have.property('code', ERROR_RESPONSE.code); | ||
close(); | ||
} catch (err) { | ||
close(err); | ||
} | ||
} | ||
); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to the other PR, can we just rename this file
constants.js
, in the likely event we will end up with non-db related constants. Trying to contain file bloat here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think that we shouldindividually bring the constants on to the
Db
constructor instead of usingObject.assign
? If we add new constants, it will be easy to accidentally expose them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I think that is probably best practice