Skip to content

Commit b1dcc84

Browse files
committed
Merge branch 'mongodb-8.0' of github.com:vtomasr5/mongoengine into upgrade_mongo
2 parents d32f197 + d26f923 commit b1dcc84

File tree

14 files changed

+316
-131
lines changed

14 files changed

+316
-131
lines changed

.github/workflows/github-actions.yml

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,29 @@ on:
1313
tags:
1414
- 'v[0-9]+\.[0-9]+\.[0-9]+*'
1515
env:
16-
MONGODB_3_6: 3.6.23
17-
MONGODB_4_0: 4.0.28
18-
MONGODB_4_4: 4.4
19-
MONGODB_5_0: "5.0"
20-
MONGODB_6_0: "6.0"
21-
MONGODB_7_0: "7.0"
16+
MONGODB_4_0: "4.0.28"
17+
MONGODB_4_2: "4.2.25"
18+
MONGODB_4_4: "4.4.29"
19+
MONGODB_5_0: "5.0.31"
20+
MONGODB_6_0: "6.0.20"
21+
MONGODB_7_0: "7.0.17"
22+
MONGODB_8_0: "8.0.5"
2223

23-
PYMONGO_3_11: 3.11
24-
PYMONGO_3_12: 3.12
25-
PYMONGO_3_13: 3.13
26-
PYMONGO_4_0: 4.0
27-
PYMONGO_4_3: 4.3.3
28-
PYMONGO_4_4: 4.4.1
29-
PYMONGO_4_6: 4.6.2
30-
PYMONGO_4_7: 4.7.3
31-
PYMONGO_4_8: 4.8.0
32-
PYMONGO_4_9: 4.9
24+
PYMONGO_3_12: "3.12.3"
25+
PYMONGO_3_13: "3.13.0"
26+
PYMONGO_4_0: "4.0.2"
27+
PYMONGO_4_3: "4.3.3"
28+
PYMONGO_4_4: "4.4.1"
29+
PYMONGO_4_6: "4.6.2"
30+
PYMONGO_4_7: "4.7.3"
31+
PYMONGO_4_8: "4.8.0"
32+
PYMONGO_4_9: "4.9.2"
33+
PYMONGO_4_10: "4.10.1"
34+
PYMONGO_4_11: "4.11.2"
3335

34-
MAIN_PYTHON_VERSION: 3.9
36+
MAIN_PYTHON_VERSION: "3.9"
3537

36-
MONGOSH: 2.2.15 # Needed for MongoDB 6.0+
38+
MONGOSH: "2.4.2" # Needed for MongoDB 6.0+
3739

3840
jobs:
3941
linting:
@@ -44,7 +46,7 @@ jobs:
4446
- uses: actions/checkout@v4
4547
- uses: actions/setup-python@v5
4648
with:
47-
python-version: '3.9'
49+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
4850
check-latest: true
4951
- run: bash .github/workflows/install_ci_python_dep.sh
5052
- run: pre-commit run -a
@@ -56,14 +58,11 @@ jobs:
5658
strategy:
5759
fail-fast: false
5860
matrix:
59-
python-version: [3.7, 3.8, 3.9, "3.10", 3.11, pypy3.9, pypy3.10]
61+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"]
6062
MONGODB: [$MONGODB_4_0]
61-
PYMONGO: [$PYMONGO_3_11]
63+
PYMONGO: [$PYMONGO_3_12]
6264
include:
63-
- python-version: 3.8
64-
MONGODB: $MONGODB_3_6
65-
PYMONGO: $PYMONGO_3_12
66-
- python-version: 3.9
65+
- python-version: "3.9"
6766
MONGODB: $MONGODB_4_4
6867
PYMONGO: $PYMONGO_3_13
6968
- python-version: "3.10"
@@ -87,6 +86,21 @@ jobs:
8786
- python-version: "3.11"
8887
MONGODB: $MONGODB_7_0
8988
PYMONGO: $PYMONGO_4_9
89+
- python-version: "3.12"
90+
MONGODB: $MONGODB_7_0
91+
PYMONGO: $PYMONGO_4_9
92+
- python-version: "3.12"
93+
MONGODB: $MONGODB_8_0
94+
PYMONGO: $PYMONGO_4_9
95+
- python-version: "3.13"
96+
MONGODB: $MONGODB_8_0
97+
PYMONGO: $PYMONGO_4_9
98+
- python-version: "3.13"
99+
MONGODB: $MONGODB_8_0
100+
PYMONGO: $PYMONGO_4_10
101+
- python-version: "3.13"
102+
MONGODB: $MONGODB_8_0
103+
PYMONGO: $PYMONGO_4_11
90104
steps:
91105
- uses: actions/checkout@v4
92106
- name: Set up Python ${{ matrix.python-version }}
@@ -122,7 +136,7 @@ jobs:
122136
- name: Set up Python ${{ matrix.python-version }}
123137
uses: actions/setup-python@v5
124138
with:
125-
python-version: 3.9
139+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
126140
check-latest: true
127141
- name: install python dep
128142
run: |
@@ -140,7 +154,7 @@ jobs:
140154
- uses: actions/checkout@v4
141155
- uses: actions/setup-python@v5
142156
with:
143-
python-version: 3.9
157+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
144158
check-latest: true
145159
- name: build dummy wheel for test-pypi
146160
run: |
@@ -153,10 +167,10 @@ jobs:
153167
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
154168
steps:
155169
- uses: actions/checkout@v4
156-
- name: Set up Python 3.9
170+
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
157171
uses: actions/setup-python@v5
158172
with:
159-
python-version: 3.9
173+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
160174
check-latest: true
161175
# todo separate build from publish
162176
# https://stackoverflow.com/questions/59349905/which-properties-does-github-event-in-a-github-workflow-have

.github/workflows/install_mongo.sh

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,50 @@
11
#!/bin/bash
22

3-
MONGODB=$1
4-
5-
# Mongo > 4.0 follows different name convention for download links
6-
mongo_build=mongodb-linux-x86_64-${MONGODB}
7-
8-
if [[ "$MONGODB" == *"4.2"* ]]; then
9-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
10-
elif [[ "$MONGODB" == *"4.4"* ]]; then
11-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
12-
elif [[ "$MONGODB" == *"5.0"* ]]; then
13-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
14-
elif [[ "$MONGODB" == *"6.0"* ]]; then
15-
mongo_build=mongodb-linux-x86_64-ubuntu1804-v${MONGODB}-latest
16-
elif [[ "$MONGODB" == *"7.0"* ]]; then
17-
mongo_build=mongodb-linux-x86_64-ubuntu2004-v${MONGODB}-latest
3+
set -e # Exit immediately if a command exits with a non-zero status
4+
set -u # Treat unset variables as an error
5+
6+
if [ "$#" -ne 1 ]; then
7+
echo "Usage: $0 <mongodb-version>"
8+
echo "Example: $0 8.0.5"
9+
exit 1
10+
fi
11+
12+
MONGODB="$1"
13+
14+
# Determine build name based on version
15+
if [[ "${MONGODB}" =~ ^(7.0|8.0) ]]; then
16+
mongo_build="mongodb-linux-x86_64-ubuntu2004-${MONGODB}"
17+
elif [[ "${MONGODB}" =~ ^(4.0|4.2|4.4|5.0|6.0) ]]; then
18+
mongo_build="mongodb-linux-x86_64-ubuntu1804-${MONGODB}"
19+
else
20+
echo "Error: Unsupported MongoDB version: ${MONGODB}"
21+
usage
22+
fi
23+
24+
download_url="http://fastdl.mongodb.org/linux/${mongo_build}.tgz"
25+
tarball="${mongo_build}.tgz"
26+
27+
echo "Downloading MongoDB from ${download_url}..."
28+
if ! wget --quiet "${download_url}"; then
29+
echo "Error: Failed to download MongoDB."
30+
exit 1
31+
fi
32+
33+
echo "Extracting ${tarball}..."
34+
if ! tar xzf "${tarball}"; then
35+
echo "Error: Failed to extract ${tarball}"
36+
exit 1
37+
fi
38+
39+
mongodb_dir=$(find "${PWD}/" -type d -name "mongodb-linux-x86_64*" | head -n 1)
40+
if [ -z "${mongodb_dir}" ]; then
41+
echo "Error: Could not find MongoDB directory after extraction."
42+
exit 1
1843
fi
1944

20-
wget http://fastdl.mongodb.org/linux/$mongo_build.tgz
21-
tar xzf $mongo_build.tgz
45+
echo "MongoDB installed at: ${mongodb_dir}"
46+
"${mongodb_dir}/bin/mongod" --version
2247

23-
mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*")
24-
$mongodb_dir/bin/mongod --version
48+
# Cleanup
49+
echo "Cleaning up..."
50+
rm -f "${tarball}"
Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,56 @@
11
#!/bin/bash
22

3+
set -e # Exit immediately if a command exits with a non-zero status
4+
set -u # Treat unset variables as an error
5+
6+
if [ $# -lt 2 ]; then
7+
echo "Usage: $0 <mongodb_version> <mongosh_version>"
8+
echo "Example: $0 8.0.5 2.4.2"
9+
exit 1
10+
fi
11+
312
MONGODB=$1
413
MONGOSH=$2
514

6-
if (( $(echo "$MONGODB < 6.0" | bc -l) )); then
7-
echo "mongosh is not needed for MongoDB versions less than 6.0"
8-
exit 0
15+
PLATFORM="linux-x64"
16+
17+
# Extract major version explicitly
18+
MONGODB_MAJOR_VERSION=$(echo "$MONGODB" | cut -d'.' -f1)
19+
20+
# Check if MongoDB major version is greater than or equal to 6
21+
if [ "$MONGODB_MAJOR_VERSION" -lt 6 ]; then
22+
echo "mongosh is not needed for MongoDB versions less than 6.0"
23+
exit 0
924
fi
1025

11-
wget https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-linux-x64.tgz
12-
tar xzf mongosh-${MONGOSH}-linux-x64.tgz
26+
DOWNLOAD_URL="https://downloads.mongodb.com/compass/mongosh-${MONGOSH}-${PLATFORM}.tgz"
27+
TARBALL="mongosh-${MONGOSH}-${PLATFORM}.tgz"
28+
29+
echo "Downloading mongosh ${MONGOSH} for ${PLATFORM}..."
30+
if ! wget --quiet "$DOWNLOAD_URL"; then
31+
echo "Failed to download mongosh. Please check the version and your internet connection."
32+
exit 1
33+
fi
34+
35+
echo "Extracting mongosh..."
36+
if ! tar xzf "$TARBALL"; then
37+
echo "Failed to extract mongosh."
38+
rm -f "$TARBALL"
39+
exit 1
40+
fi
41+
42+
mongosh_dir=$(find "${PWD}/" -type d -name "mongosh-${MONGOSH}-${PLATFORM}" -print -quit)
43+
if [ ! -d "$mongosh_dir" ]; then
44+
echo "Failed to find extracted mongosh directory."
45+
rm -f "$TARBALL"
46+
exit 1
47+
fi
48+
49+
echo "Testing mongosh installation..."
50+
if ! "$mongosh_dir/bin/mongosh" --version; then
51+
echo "Failed to run mongosh."
52+
exit 1
53+
fi
1354

14-
mongosh_dir=$(find ${PWD}/ -type d -name "mongosh-${MONGOSH}-linux-x64")
15-
$mongosh_dir/bin/mongosh --version
55+
echo "Cleaning up..."
56+
rm -f "$TARBALL"

.github/workflows/start_mongo.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ mongodb_dir=$(find ${PWD}/ -type d -name "mongodb-linux-x86_64*")
77
mkdir $mongodb_dir/data
88

99
args=(--dbpath $mongodb_dir/data --logpath $mongodb_dir/mongodb.log --fork --replSet mongoengine)
10-
if (( $(echo "$MONGODB > 3.8" | bc -l) )); then
10+
11+
# Parse version components
12+
MAJOR=$(echo "$MONGODB" | cut -d'.' -f1)
13+
MINOR=$(echo "$MONGODB" | cut -d'.' -f2)
14+
if [ "$MAJOR" -gt 3 ] || ([ "$MAJOR" -eq 3 ] && [ "$MINOR" -ge 8 ]); then
1115
args+=(--setParameter maxTransactionLockRequestTimeoutMillis=1000)
1216
fi
1317

1418
$mongodb_dir/bin/mongod "${args[@]}"
1519

16-
if (( $(echo "$MONGODB < 6.0" | bc -l) )); then
20+
if [ "$MAJOR" -lt 6 ]; then
1721
mongo --verbose --eval "rs.initiate()"
1822
mongo --quiet --eval "rs.status().ok"
1923
else

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ an `API reference <https://mongoengine-odm.readthedocs.io/apireference.html>`_.
3535

3636
Supported MongoDB Versions
3737
==========================
38-
MongoEngine is currently tested against MongoDB v3.6, v4.0, v4.4, v5.0, v6.0 and v7.0. Future versions
38+
MongoEngine is currently tested against MongoDB v4.0, v4.4, v5.0, v6.0, v7.0 and v8.0. Future versions
3939
should be supported as well, but aren't actively tested at the moment. Make
4040
sure to open an issue or submit a pull request if you experience any problems
4141
with a more recent MongoDB versions.
@@ -58,7 +58,7 @@ Dependencies
5858
All of the dependencies can easily be installed via `python -m pip <https://pip.pypa.io/>`_.
5959
At the very least, you'll need these two packages to use MongoEngine:
6060

61-
- pymongo>=3.4
61+
- pymongo>=3.12
6262

6363
If you utilize a ``DateTimeField``, you might also use a more flexible date parser:
6464

docs/changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ Development
2222
- Add support for collation/hint/comment to delete/update and aggregate #2842
2323
- BREAKING CHANGE: Remove LongField as it's equivalent to IntField since we drop support to Python2 long time ago (User should simply switch to IntField) #2309
2424
- BugFix - Calling .clear on a ListField wasn't being marked as changed (and flushed to db upon .save()) #2858
25-
25+
- Improve error message in case a document assigned to a ReferenceField wasn't saved yet #1955
26+
- BugFix - Take `where()` into account when using `.modify()`, as in MyDocument.objects().where("this[field] >= this[otherfield]").modify(field='new') #2044
2627

2728
Changes in 0.29.0
2829
=================

0 commit comments

Comments
 (0)