Skip to content
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

Gh 10423 adds a transform option to lean queries #11814

Merged
merged 46 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
beeddbb
improve issue templates
Uzlopak May 11, 2022
00f7f2a
Merge branch 'Automattic:master' into improve-issue-template
Uzlopak May 11, 2022
d1ffce8
when requesting help, point to the docs
Uzlopak May 11, 2022
fda32c3
refine performance issue
Uzlopak May 11, 2022
0044913
added test case
IslandRhythms May 13, 2022
2c9b417
`completeOneLean()` done
IslandRhythms May 16, 2022
b8dbcd8
removed logs
IslandRhythms May 16, 2022
92cae73
adapt changes requested by PR comments
Uzlopak May 17, 2022
6cbbaef
`_completeManyLean()` done, I think
IslandRhythms May 17, 2022
0cd4171
try to fix isAtlas
Uzlopak May 18, 2022
da4f04d
avoid prototype pollution by setDottedPath
Uzlopak May 18, 2022
0339806
fix linting error
Uzlopak May 18, 2022
c6de154
chore(deps): Included dependency review
naveensrinivasan May 19, 2022
73cc742
reworking solution
IslandRhythms May 20, 2022
da0d878
independent `completeManyLean()`
IslandRhythms May 23, 2022
9babf9c
lint fix
IslandRhythms May 23, 2022
b6e77cc
Merge branch 'Automattic:master' into Dependency-GitHub
naveensrinivasan May 27, 2022
9c8098b
Included the check within the test.yml as per the code recommendations.
naveensrinivasan May 27, 2022
0e7a7be
fix(document): fix ObjectId conversion for external schemas
coyotte508 May 27, 2022
d435d5d
Update clone.js
coyotte508 May 27, 2022
aba95a2
Update clone.js
coyotte508 May 27, 2022
9d30935
use specialParts for setDottedPath
Uzlopak May 28, 2022
f6beceb
fix documention of error handling
Uzlopak May 28, 2022
85a3d09
Update clone.js
coyotte508 May 28, 2022
cb63c7b
Update clone.js
coyotte508 May 28, 2022
2d3d5b1
Update clone.js
coyotte508 May 28, 2022
010b280
Update clone.js
coyotte508 May 28, 2022
dda76d0
refacto: use isBsonType instead of instanceof for ObjectId & Decimal128
coyotte508 May 28, 2022
901b211
improve performance of isBsonType
Uzlopak May 28, 2022
bcf3824
improve tests
Uzlopak May 28, 2022
aece69f
Merge pull request #11841 from coyotte508/patch-3
Uzlopak May 28, 2022
67af5b9
test(discriminator): add test coverage for discriminators on maps of …
vkarpov15 May 28, 2022
b11e22e
Merge pull request #11846 from Uzlopak/improve-performance-of-isBsonType
Uzlopak May 28, 2022
f8b3c76
Merge pull request #11820 from turrisxyz/Dependency-GitHub
vkarpov15 May 28, 2022
051726c
Merge pull request #11817 from Uzlopak/fix-codeql-sec-warnings
vkarpov15 May 28, 2022
8a90742
Merge pull request #11844 from Uzlopak/fix-documentation-error
vkarpov15 May 28, 2022
ec4c2c6
Merge pull request #11794 from Uzlopak/improve-issue-template
vkarpov15 May 28, 2022
1fafd09
fix schematypeoptions
Uzlopak May 28, 2022
996e48d
Merge pull request #11848 from Uzlopak/fix-schematypeoptions
Uzlopak May 28, 2022
74a3b6b
fix(document): avoid manually populating documents that are manually …
vkarpov15 May 29, 2022
283c472
docs: correct issue number re: #6796
vkarpov15 May 29, 2022
2e19312
Merge branch 'master' into gh-10423
vkarpov15 May 29, 2022
d082047
refining the logic to requests made
IslandRhythms Jun 2, 2022
4c0ecbe
reworked `completeManyLean()` to be in line with requested change
IslandRhythms Jun 3, 2022
d11c511
reworked `_completeOneLean()` to be in line with requested changes
IslandRhythms Jun 3, 2022
1c7696e
should work now
IslandRhythms Jun 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

62 changes: 62 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 🪲 Bug report
description: Create a report to help us improve

body:
- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
options:
- label: I have written a descriptive issue title
required: true
- label: |
I have searched existing issues to ensure the bug has not already been reported
required: true

- type: input
id: mongoose-version
attributes:
label: Mongoose version
placeholder: 6.x.x
validations:
required: true

- type: input
id: node-version
attributes:
label: Node.js version
placeholder: 14.x
validations:
required: true

- type: input
id: mongo-version
attributes:
label: MongoDB server version
placeholder: 5.x
validations:
required: true

- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of what the bug is.
validations:
required: true

- type: textarea
id: steps-to-reproduce
attributes:
label: Steps to Reproduce
description: |
List of steps, sample code, or a link to code or a project that reproduces the behavior.
Make sure you place a stack trace inside a [code (```) block](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks) to avoid linking unrelated issues.
validations:
required: true

- type: textarea
id: expected-behavior
attributes:
label: Expected Behavior
description: A clear and concise description of what you expected to happen.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
documentation:
- name: 📘 Documentation
url: https://mongoosejs.com/docs/guide.html
about: Mongoose Docs
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 🚀 Feature Proposal
description: Submit a proposal for a new feature
labels: ['enhancement', 'new feature']

body:
- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
options:
- label: I have written a descriptive issue title
required: true
- label: |
I have searched existing issues to ensure the feature has not already been requested
required: true

- type: textarea
id: proposal
attributes:
label: 🚀 Feature Proposal
description: A clear and concise description of what the feature is.
validations:
required: true

- type: textarea
id: motivation
attributes:
label: Motivation
description: The motivation for the proposal.

- type: textarea
id: example
attributes:
label: Example
description: |
An example for how this feature would be used.
Make sure you place example code inside a [code (```) block](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks) to avoid linking unrelated issues.
67 changes: 67 additions & 0 deletions .github/ISSUE_TEMPLATE/help.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: 🙋 Help
description: Open an issue and request for individual help
labels: ['help', 'help wanted']

body:
- type: markdown
attributes:
value: |
Before you submit an issue we recommend to read the [documentation](https://mongoosejs.com/docs/guide.html).

- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
options:
- label: I have written a descriptive issue title
required: true

- type: input
id: mongoose-version
attributes:
label: Mongoose version
placeholder: 6.x.x
validations:
required: true

- type: input
id: node-version
attributes:
label: Node.js version
placeholder: 14.x
validations:
required: true

- type: input
id: mongo-version
attributes:
label: MongoDB version
placeholder: 5.x
validations:
required: true

- type: dropdown
id: os
attributes:
label: Operating system
options:
- Linux
- macOS
- Windows
validations:
required: false

- type: input
id: os-version
attributes:
label: Operating system version (i.e. 20.04, 11.3, 10)
validations:
required: false

- type: textarea
id: text
attributes:
label: Issue
description: |
Give as much detail as you can to help us understand.
Make sure you place example code inside a [code (```) block](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks) to avoid linking unrelated issues.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/other.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: ❔ Other
description: Open an issue that is not feature or bug related

body:
- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
options:
- label: I have written a descriptive issue title
required: true
- label: |
I have searched existing issues to ensure the issue has not already been raised
required: true

- type: textarea
id: text
attributes:
label: Issue
description: |
Give as much detail as you can to help us understand.
Make sure you place example code inside a [code (```) block](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks) to avoid linking unrelated issues.
63 changes: 63 additions & 0 deletions .github/ISSUE_TEMPLATE/performance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: 🦥 Performance issue
description: Report a performance issue
labels: ['performance']

body:
- type: checkboxes
id: prerequisites
attributes:
label: Prerequisites
options:
- label: I have written a descriptive issue title
required: true
- label: |
I have searched existing issues to ensure the performance issue has not already been reported
required: true

- type: input
id: working-version
attributes:
label: Last performant version
placeholder: 1.x.x
validations:
required: true

- type: input
id: stopped-working-version
attributes:
label: Slowed down in version
placeholder: 2.x.x
validations:
required: true

- type: input
id: node-version
attributes:
label: Node.js version
placeholder: 14.x
validations:
required: true

- type: textarea
id: description
attributes:
label: 🦥 Performance issue
description: A clear and concise description of what the performance issue is.
validations:
required: true

- type: textarea
id: steps-to-reproduce
attributes:
label: Steps to Reproduce
description: |
List of steps, sample code, or a link to code or a project that reproduces the behavior.
Make sure you place a stack trace inside a [code (```) block](https://docs.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks) to avoid linking unrelated issues.
validations:
required: true

- type: textarea
id: expected-behavior
attributes:
label: Expected Behavior
description: A clear and concise description of what you expected to happen.
13 changes: 12 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,15 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
path: coverage
dependency-review:
name: Dependency Review
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Check out repo
uses: actions/checkout@v3
- name: Dependency review
uses: actions/dependency-review-action@v1
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ Connection.prototype.dropDatabase = _wrapConnHelper(function dropDatabase(cb) {
// If `dropDatabase()` is called, this model's collection will not be
// init-ed. It is sufficiently common to call `dropDatabase()` after
// `mongoose.connect()` but before creating models that we want to
// support this. See gh-6967
// support this. See gh-6796
for (const name of Object.keys(this.models)) {
delete this.models[name].$init;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1378,7 +1378,7 @@ Document.prototype.$set = function $set(path, val, type, options) {
})();

let didPopulate = false;
if (refMatches && val instanceof Document) {
if (refMatches && val instanceof Document && (!val.$__.wasPopulated || utils.deepEqual(val.$__.wasPopulated.value, val._id))) {
const unpopulatedValue = (schema && schema.$isSingleNested) ? schema.cast(val, this) : val._id;
this.$populated(path, unpopulatedValue, { [populateModelSymbol]: val.constructor });
val.$__.wasPopulated = { value: unpopulatedValue };
Expand Down
4 changes: 2 additions & 2 deletions lib/error/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* Mongoose-specific errors.
*
* #### Example:
* const Model = mongoose.model('Test', new Schema({ answer: Number }));
* const Model = mongoose.model('Test', new mongoose.Schema({ answer: Number }));
* const doc = new Model({ answer: 'not a number' });
* const err = doc.validateSync();
*
* err instanceof mongoose.Error; // true
* err instanceof mongoose.Error.ValidationError; // true
*
* @constructor Error
* @param {String} msg Error message
Expand Down
2 changes: 1 addition & 1 deletion lib/helpers/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function clone(obj, options, isArrayChild) {
}
}

if (obj instanceof ObjectId) {
if (isBsonType(obj, 'ObjectID')) {
return new ObjectId(obj.id);
}

Expand Down
7 changes: 3 additions & 4 deletions lib/helpers/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
*/

const Binary = require('../driver').get().Binary;
const Decimal128 = require('../types/decimal128');
const ObjectId = require('../types/objectid');
const isBsonType = require('./isBsonType');
const isMongooseObject = require('./isMongooseObject');

exports.flatten = flatten;
Expand Down Expand Up @@ -99,9 +98,9 @@ function shouldFlatten(val) {
return val &&
typeof val === 'object' &&
!(val instanceof Date) &&
!(val instanceof ObjectId) &&
!isBsonType(val, 'ObjectID') &&
(!Array.isArray(val) || val.length !== 0) &&
!(val instanceof Buffer) &&
!(val instanceof Decimal128) &&
!isBsonType(val, 'Decimal128') &&
!(val instanceof Binary);
}
4 changes: 2 additions & 2 deletions lib/helpers/discriminator/areDiscriminatorValuesEqual.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const ObjectId = require('../../types/objectid');
const isBsonType = require('../isBsonType');

module.exports = function areDiscriminatorValuesEqual(a, b) {
if (typeof a === 'string' && typeof b === 'string') {
Expand All @@ -9,7 +9,7 @@ module.exports = function areDiscriminatorValuesEqual(a, b) {
if (typeof a === 'number' && typeof b === 'number') {
return a === b;
}
if (a instanceof ObjectId && b instanceof ObjectId) {
if (isBsonType(a, 'ObjectID') && isBsonType(b, 'ObjectID')) {
return a.toString() === b.toString();
}
return false;
Expand Down
Loading