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

feat: add MongoDB 5.1 compatibility #7682

Merged
merged 43 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
ba3cf52
add issue bot for prs
mtrezza Aug 27, 2021
2af6350
Update CHANGELOG.md
mtrezza Aug 27, 2021
d7a34ce
Update issue-bot.yml
mtrezza Aug 27, 2021
c2f2481
Merge remote-tracking branch 'upstream/master'
mtrezza Aug 27, 2021
60537fe
Merge remote-tracking branch 'upstream/master'
mtrezza Aug 31, 2021
2e69bc7
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 2, 2021
ac221a1
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 2, 2021
23e78ae
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 2, 2021
ab2d9ed
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 3, 2021
59c4214
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 4, 2021
ebefede
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 7, 2021
81165cc
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 7, 2021
a26006e
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 7, 2021
3a3d4fa
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 7, 2021
4f3ad39
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 10, 2021
695f00a
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 10, 2021
7cffb87
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 10, 2021
e0c066e
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 13, 2021
a863c82
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 14, 2021
5610dc5
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 16, 2021
e680e4a
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 24, 2021
6f04834
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 30, 2021
55b7521
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 30, 2021
7857020
Merge remote-tracking branch 'upstream/master'
mtrezza Sep 30, 2021
0b3a4a1
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 10, 2021
08040e1
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 11, 2021
056e242
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 12, 2021
157b5bd
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 12, 2021
8bcadc1
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 12, 2021
e1305b9
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 13, 2021
fe0bf69
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 13, 2021
6a40c49
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 14, 2021
69356bb
Merge remote-tracking branch 'upstream/master'
mtrezza Oct 14, 2021
f9c09a8
ci: bump environment
mtrezza Oct 15, 2021
1e37c84
Merge branch 'alpha' into ci-bump-environment
mtrezza Nov 8, 2021
c83aa9e
add mongodb 5.1.0 ci check
mtrezza Nov 8, 2021
ba23a6d
Update README.md
mtrezza Nov 8, 2021
0826382
Merge branch 'alpha' into ci-bump-environment
mtrezza Nov 12, 2021
1f63edf
Merge branch 'alpha' into ci-bump-environment
mtrezza Feb 6, 2022
db60d0b
Merge branch 'alpha' into ci-bump-environment
mtrezza Mar 24, 2022
519966e
Merge branch 'alpha' into ci-bump-environment
mtrezza Mar 27, 2022
d59a901
Update README.md
mtrezza Mar 27, 2022
006621d
fix tests
mtrezza Mar 27, 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
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ jobs:
strategy:
matrix:
include:
- name: MongoDB 5.1, ReplicaSet, WiredTiger
MONGODB_VERSION: 5.1.0
MONGODB_TOPOLOGY: replicaset
MONGODB_STORAGE_ENGINE: wiredTiger
NODE_VERSION: 14.18.1
- name: MongoDB 5.0, ReplicaSet, WiredTiger
MONGODB_VERSION: 5.0.3
MONGODB_TOPOLOGY: replicaset
Expand Down
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ Before you start make sure you have installed:
#### Node.js
Parse Server is continuously tested with the most recent releases of Node.js to ensure compatibility. We follow the [Node.js Long Term Support plan](https://github.com/nodejs/Release) and only test against versions that are officially supported and have not reached their end-of-life date.

| Version | Latest Version | End-of-Life | Compatible |
|------------|----------------|-------------|---------------|
| Version | Latest Version | End-of-Life | Compatible |
|------------|----------------|-------------|--------------|
| Node.js 12 | 12.22.7 | April 2022 | ✅ Yes |
| Node.js 14 | 14.18.1 | April 2023 | ✅ Yes |
| Node.js 16 | 16.13.0 | April 2024 | ✅ Yes |
Expand All @@ -124,20 +124,21 @@ Parse Server is continuously tested with the most recent releases of MongoDB to

| Version | Latest Version | End-of-Life | Compatible |
|-------------|----------------|--------------|------------|
| MongoDB 4.0 | 4.0.27 | April 2022 | ✅ Yes |
| MongoDB 4.2 | 4.2.17 | TBD | ✅ Yes |
| MongoDB 4.4 | 4.4.10 | TBD | ✅ Yes |
| MongoDB 5.0 | 5.0.3 | January 2024 | ✅ Yes |

| MongoDB 4.0 | 4.0.27 | April 2022 | ✅ Yes |
| MongoDB 4.2 | 4.2.17 | TBD | ✅ Yes |
| MongoDB 4.4 | 4.4.10 | TBD | ✅ Yes |
| MongoDB 5.0 | 5.0.3 | January 2024 | ✅ Yes |
| MongoDB 5.1 | 5.1.0 | January 2024 | ✅ Yes |

#### PostgreSQL
Parse Server is continuously tested with the most recent releases of PostgreSQL and PostGIS to ensure compatibility, using [PostGIS docker images](https://registry.hub.docker.com/r/postgis/postgis/tags?page=1&ordering=last_updated). We follow the [PostgreSQL support schedule](https://www.postgresql.org/support/versioning) and [PostGIS support schedule](https://www.postgis.net/eol_policy/) and only test against versions that are officially supported and have not reached their end-of-life date. Due to the extensive PostgreSQL support duration of 5 years, Parse Server drops support if a version is older than 3.5 years and a newer version has been available for at least 2.5 years.

| Version | PostGIS Version | End-of-Life | Parse Server Support End | Compatible |
|-------------|-----------------|---------------|--------------------------|------------|
| Postgres 11 | 3.0, 3.1, 3.2 | November 2023 | April 2022 | ✅ Yes |
| Postgres 12 | 3.2 | November 2024 | April 2023 | ✅ Yes |
| Postgres 13 | 3.2 | November 2025 | April 2024 | ✅ Yes |
| Postgres 14 | 3.2 | November 2026 | April 2025 | ✅ Yes |
| Postgres 11 | 3.0, 3.1, 3.2 | November 2023 | April 2022 | ✅ Yes |
| Postgres 12 | 3.2 | November 2024 | April 2023 | ✅ Yes |
| Postgres 13 | 3.2 | November 2025 | April 2024 | ✅ Yes |
| Postgres 14 | 3.2 | November 2026 | April 2025 | ✅ Yes |

### Locally
```bash
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,13 @@
"test:mongodb:4.2.17": "npm run test:mongodb --dbversion=4.2.17",
"test:mongodb:4.4.10": "npm run test:mongodb --dbversion=4.4.10",
"test:mongodb:5.0.5": "npm run test:mongodb --dbversion=5.0.5",
"test:mongodb:5.1.0": "npm run test:mongodb --dbversion=5.1.0",
"posttest:mongodb": "mongodb-runner stop",
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.0.5} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} mongodb-runner start",
"testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.0.5} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} TESTING=1 jasmine",
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.1.0} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} mongodb-runner start",
"testonly": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.1.0} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} TESTING=1 jasmine",
"test": "npm run testonly",
"posttest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.0.5} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} mongodb-runner stop",
"coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.0.5} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} TESTING=1 nyc jasmine",
"posttest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.1.0} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} mongodb-runner stop",
"coverage": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=5.1.0} MONGODB_TOPOLOGY=${MONGODB_TOPOLOGY:=standalone} MONGODB_STORAGE_ENGINE=${MONGODB_STORAGE_ENGINE:=wiredTiger} TESTING=1 nyc jasmine",
"start": "node ./bin/parse-server",
"prettier": "prettier --write {src,spec}/{**/*,*}.js",
"prepare": "npm run build",
Expand Down
36 changes: 35 additions & 1 deletion spec/MongoStorageAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
await expectAsync(adapter.getClass('UnknownClass')).toBeRejectedWith(undefined);
});

it('should use index for caseInsensitive query', async () => {
it_only_mongodb_version('<5.1')('should use index for caseInsensitive query', async () => {
const user = new Parse.User();
user.set('username', 'Bugs');
user.set('password', 'Bunny');
Expand Down Expand Up @@ -342,6 +342,40 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
expect(postIndexPlan.executionStats.executionStages.stage).toBe('FETCH');
});

it_only_mongodb_version('>=5.1')('should use index for caseInsensitive query', async () => {
const user = new Parse.User();
user.set('username', 'Bugs');
user.set('password', 'Bunny');
await user.signUp();

const database = Config.get(Parse.applicationId).database;
await database.adapter.dropAllIndexes('_User');

const preIndexPlan = await database.find(
'_User',
{ username: 'bugs' },
{ caseInsensitive: true, explain: true }
);

const schema = await new Parse.Schema('_User').get();

await database.adapter.ensureIndex(
'_User',
schema,
['username'],
'case_insensitive_username',
true
);

const postIndexPlan = await database.find(
'_User',
{ username: 'bugs' },
{ caseInsensitive: true, explain: true }
);
expect(preIndexPlan.queryPlanner.winningPlan.queryPlan.stage).toBe('COLLSCAN');
expect(postIndexPlan.queryPlanner.winningPlan.queryPlan.stage).toBe('FETCH');
});

it('should delete field without index', async () => {
const database = Config.get(Parse.applicationId).database;
const obj = new Parse.Object('MyObject');
Expand Down
144 changes: 138 additions & 6 deletions spec/ParseQuery.hint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
await TestUtils.destroyAllDataPermanently(false);
});

it('query find with hint string', async () => {
it_only_mongodb_version('<5.1')('query find with hint string', async () => {
const object = new TestObject();
await object.save();

Expand All @@ -39,7 +39,18 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(explain.queryPlanner.winningPlan.inputStage.indexName).toBe('_id_');
});

it('query find with hint object', async () => {
it_only_mongodb_version('>=5.1')('query find with hint string', async () => {
const object = new TestObject();
await object.save();

const collection = await config.database.adapter._adaptiveCollection('TestObject');
const explain = await collection._rawFind({ _id: object.id }, { hint: '_id_', explain: true });
expect(explain.queryPlanner.winningPlan.queryPlan.stage).toBe('FETCH');
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('IXSCAN');
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('<5.1')('query find with hint object', async () => {
const object = new TestObject();
await object.save();

Expand All @@ -53,6 +64,20 @@ describe_only_db('mongo')('Parse.Query hint', () => {
});
});

it_only_mongodb_version('>=5.1')('query find with hint object', async () => {
const object = new TestObject();
await object.save();

const collection = await config.database.adapter._adaptiveCollection('TestObject');
const explain = await collection._rawFind(
{ _id: object.id },
{ hint: { _id: 1 }, explain: true }
);
expect(explain.queryPlanner.winningPlan.queryPlan.stage).toBe('FETCH');
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('IXSCAN');
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('<4.4')('query aggregate with hint string', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
Expand All @@ -73,7 +98,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=4.4')('query aggregate with hint string', async () => {
it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint string', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -97,6 +122,30 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=5.1')('query aggregate with hint string', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

const collection = await config.database.adapter._adaptiveCollection('TestObject');
let result = await collection.aggregate([{ $group: { _id: '$foo' } }], {
explain: true,
});
let { queryPlanner } = result[0].stages[0].$cursor;
expect(queryPlanner.winningPlan.queryPlan.stage).toBe('PROJECTION_SIMPLE');
expect(queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('COLLSCAN');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage).toBeUndefined();

result = await collection.aggregate([{ $group: { _id: '$foo' } }], {
hint: '_id_',
explain: true,
});
queryPlanner = result[0].stages[0].$cursor.queryPlanner;
expect(queryPlanner.winningPlan.queryPlan.stage).toBe('PROJECTION_SIMPLE');
expect(queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('FETCH');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.stage).toBe('IXSCAN');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('<4.4')('query aggregate with hint object', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
Expand All @@ -117,7 +166,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=4.4')('query aggregate with hint object', async () => {
it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint object', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

Expand All @@ -142,7 +191,32 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it('query find with hint (rest)', async () => {
it_only_mongodb_version('>=5.1')('query aggregate with hint object', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();

const collection = await config.database.adapter._adaptiveCollection('TestObject');
let result = await collection.aggregate([{ $group: { _id: '$foo' } }], {
explain: true,
});
let { queryPlanner } = result[0].stages[0].$cursor;
expect(queryPlanner.winningPlan.queryPlan.stage).toBe('PROJECTION_SIMPLE');
expect(queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('COLLSCAN');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage).toBeUndefined();

result = await collection.aggregate([{ $group: { _id: '$foo' } }], {
hint: { _id: 1 },
explain: true,
});
queryPlanner = result[0].stages[0].$cursor.queryPlanner;
expect(queryPlanner.winningPlan.queryPlan.stage).toBe('PROJECTION_SIMPLE');
expect(queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('FETCH');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.stage).toBe('IXSCAN');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.indexName).toBe('_id_');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('<5.1')('query find with hint (rest)', async () => {
const object = new TestObject();
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand All @@ -167,6 +241,31 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(explain.queryPlanner.winningPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('>=5.1')('query find with hint (rest)', async () => {
const object = new TestObject();
await object.save();
let options = Object.assign({}, masterKeyOptions, {
url: Parse.serverURL + '/classes/TestObject',
qs: {
explain: true,
},
});
let response = await request(options);
let explain = response.data.results;
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('COLLSCAN');

options = Object.assign({}, masterKeyOptions, {
url: Parse.serverURL + '/classes/TestObject',
qs: {
explain: true,
hint: '_id_',
},
});
response = await request(options);
explain = response.data.results;
expect(explain.queryPlanner.winningPlan.queryPlan.inputStage.inputStage.indexName).toBe('_id_');
});

it_only_mongodb_version('<4.4')('query aggregate with hint (rest)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
Expand Down Expand Up @@ -194,7 +293,7 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=4.4')('query aggregate with hint (rest)', async () => {
it_only_mongodb_version('>=4.4<5.1')('query aggregate with hint (rest)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
let options = Object.assign({}, masterKeyOptions, {
Expand Down Expand Up @@ -226,4 +325,37 @@ describe_only_db('mongo')('Parse.Query hint', () => {
expect(queryPlanner.winningPlan.inputStage.inputStage.indexName).toBe('_id_');
expect(queryPlanner.winningPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});

it_only_mongodb_version('>=5.1')('query aggregate with hint (rest)', async () => {
const object = new TestObject({ foo: 'bar' });
await object.save();
let options = Object.assign({}, masterKeyOptions, {
url: Parse.serverURL + '/aggregate/TestObject',
qs: {
explain: true,
group: JSON.stringify({ objectId: '$foo' }),
},
});
let response = await request(options);
let { queryPlanner } = response.data.results[0].stages[0].$cursor;
expect(queryPlanner.winningPlan.queryPlan.stage).toBe('PROJECTION_SIMPLE');
expect(queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('COLLSCAN');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage).toBeUndefined();

options = Object.assign({}, masterKeyOptions, {
url: Parse.serverURL + '/aggregate/TestObject',
qs: {
explain: true,
hint: '_id_',
group: JSON.stringify({ objectId: '$foo' }),
},
});
response = await request(options);
queryPlanner = response.data.results[0].stages[0].$cursor.queryPlanner;
expect(queryPlanner.winningPlan.queryPlan.stage).toBe('PROJECTION_SIMPLE');
expect(queryPlanner.winningPlan.queryPlan.inputStage.stage).toBe('FETCH');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.stage).toBe('IXSCAN');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.indexName).toBe('_id_');
expect(queryPlanner.winningPlan.queryPlan.inputStage.inputStage.keyPattern).toEqual({ _id: 1 });
});
});