Skip to content

Commit 9ef0714

Browse files
authored
Merge branch 'main' into revised-readme
2 parents 0d662e0 + e0ada88 commit 9ef0714

31 files changed

+599
-155
lines changed

.evergreen/config.yml

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,20 @@ functions:
3131
- command: subprocess.exec
3232
params:
3333
binary: bash
34-
env:
35-
MONGODB_VERSION: "5.0"
36-
TOPOLOGY: server
37-
AUTH: "noauth"
38-
SSL: "nossl"
34+
add_expansions_to_env: true
3935
args:
4036
- ${DRIVERS_TOOLS}/.evergreen/run-orchestration.sh
37+
- command: expansions.update
38+
params:
39+
file: mo-expansion.yml
4140

4241
"run unit tests":
4342
- command: subprocess.exec
4443
type: test
4544
params:
4645
binary: bash
4746
working_dir: "src"
48-
include_expansions_in_env: ["DRIVERS_TOOLS"]
47+
include_expansions_in_env: ["DRIVERS_TOOLS", "MONGODB_URI"]
4948
args:
5049
- ./.evergreen/run-tests.sh
5150

@@ -64,13 +63,51 @@ post:
6463
- func: teardown
6564

6665
tasks:
67-
- name: run-tests
68-
commands:
69-
- func: "run unit tests"
66+
- name: run-tests
67+
commands:
68+
- func: "run unit tests"
7069

7170
buildvariants:
72-
- name: tests
73-
display_name: Run Tests
74-
run_on: rhel87-small
75-
tasks:
76-
- name: run-tests
71+
- name: tests-5-noauth-nossl
72+
display_name: Run Tests 6.0 NoAuth NoSSL
73+
run_on: rhel87-small
74+
expansions:
75+
MONGODB_VERSION: "6.0"
76+
TOPOLOGY: server
77+
AUTH: "noauth"
78+
SSL: "nossl"
79+
tasks:
80+
- name: run-tests
81+
82+
- name: tests-5-auth-ssl
83+
display_name: Run Tests 6.0 Auth SSL
84+
run_on: rhel87-small
85+
expansions:
86+
MONGODB_VERSION: "6.0"
87+
TOPOLOGY: server
88+
AUTH: "auth"
89+
SSL: "ssl"
90+
tasks:
91+
- name: run-tests
92+
93+
- name: tests-8-noauth-nossl
94+
display_name: Run Tests 8.0 NoAuth NoSSL
95+
run_on: rhel87-small
96+
expansions:
97+
MONGODB_VERSION: "8.0"
98+
TOPOLOGY: server
99+
AUTH: "noauth"
100+
SSL: "nossl"
101+
tasks:
102+
- name: run-tests
103+
104+
- name: tests-8-auth-ssl
105+
display_name: Run Tests 8.0 Auth SSL
106+
run_on: rhel87-small
107+
expansions:
108+
MONGODB_VERSION: "8.0"
109+
TOPOLOGY: server
110+
AUTH: "auth"
111+
SSL: "ssl"
112+
tasks:
113+
- name: run-tests

.github/workflows/codeql.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626

2727
jobs:
2828
analyze:
29-
name: Analyze
29+
name: Analyze ${{ matrix.language }}
3030
runs-on: ubuntu-latest
3131
timeout-minutes: 360
3232
permissions:
@@ -36,6 +36,12 @@ jobs:
3636
packages: read
3737
actions: read
3838
contents: read
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
include:
43+
- language: python
44+
- language: actions
3945

4046
steps:
4147
- name: Checkout repository
@@ -52,7 +58,7 @@ jobs:
5258
- name: Initialize CodeQL
5359
uses: github/codeql-action/init@v3
5460
with:
55-
languages: python
61+
languages: ${{ matrix.language }}
5662
build-mode: none
5763
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
5864
queries: security-extended
@@ -62,10 +68,11 @@ jobs:
6268
- 'tests/**'
6369
6470
- shell: bash
71+
if: matrix.language == 'python'
6572
run: |
6673
pip install -e .
6774
6875
- name: Perform CodeQL Analysis
6976
uses: github/codeql-action/analyze@v3
7077
with:
71-
category: "/language:python"
78+
category: "/language:${{ matrix.language }}"

.github/workflows/mongodb_settings.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,29 @@
1-
DATABASES = {
2-
"default": {
3-
"ENGINE": "django_mongodb_backend",
4-
"NAME": "djangotests",
5-
},
6-
"other": {
7-
"ENGINE": "django_mongodb_backend",
8-
"NAME": "djangotests-other",
9-
},
10-
}
1+
import os
2+
3+
from django_mongodb_backend import parse_uri
4+
5+
if mongodb_uri := os.getenv("MONGODB_URI"):
6+
db_settings = parse_uri(mongodb_uri)
7+
8+
# Workaround for https://github.com/mongodb-labs/mongo-orchestration/issues/268
9+
if db_settings["USER"] and db_settings["PASSWORD"]:
10+
db_settings["OPTIONS"].update({"tls": True, "tlsAllowInvalidCertificates": True})
11+
DATABASES = {
12+
"default": {**db_settings, "NAME": "djangotests"},
13+
"other": {**db_settings, "NAME": "djangotests-other"},
14+
}
15+
else:
16+
DATABASES = {
17+
"default": {
18+
"ENGINE": "django_mongodb_backend",
19+
"NAME": "djangotests",
20+
},
21+
"other": {
22+
"ENGINE": "django_mongodb_backend",
23+
"NAME": "djangotests-other",
24+
},
25+
}
26+
1127
DEFAULT_AUTO_FIELD = "django_mongodb_backend.fields.ObjectIdAutoField"
1228
PASSWORD_HASHERS = ("django.contrib.auth.hashers.MD5PasswordHasher",)
1329
SECRET_KEY = "django_tests_secret_key"

.github/workflows/release-python.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ on:
1313
description: "Dry Run?"
1414
default: false
1515
type: boolean
16+
schedule:
17+
- cron: '30 5 * * *'
1618

1719
env:
1820
# Changes per repo
1921
PRODUCT_NAME: django-mongodb-backend
2022
# Changes per branch
2123
SILK_ASSET_GROUP: django-mongodb-backend-main
2224
EVERGREEN_PROJECT: django-mongodb-backend
25+
# Constant
26+
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || 'true' }}
27+
FOLLOWING_VERSION: ${{ inputs.following_version || '' }}
28+
VERSION: ${{ inputs.version || '10.10.10.10' }}
2329

2430
defaults:
2531
run:
@@ -48,8 +54,8 @@ jobs:
4854
- uses: mongodb-labs/drivers-github-tools/python/pre-publish@v2
4955
id: pre-publish
5056
with:
51-
version: ${{ inputs.version }}
52-
dry_run: ${{ inputs.dry_run }}
57+
version: ${{ env.VERSION }}
58+
dry_run: ${{ env.DRY_RUN }}
5359

5460
build-dist:
5561
needs: [pre-publish]
@@ -76,8 +82,14 @@ jobs:
7682
with:
7783
name: all-dist-${{ github.run_id }}
7884
path: dist/
85+
- name: Publish package distributions to TestPyPI
86+
uses: pypa/gh-action-pypi-publish@release/v1
87+
with:
88+
repository-url: https://test.pypi.org/legacy/
89+
skip-existing: true
90+
attestations: ${{ env.DRY_RUN }}
7991
- name: Publish package distributions to PyPI
80-
if: startsWith(inputs.dry_run, 'false')
92+
if: startsWith(env.DRY_RUN, 'false')
8193
uses: pypa/gh-action-pypi-publish@release/v1
8294

8395
post-publish:
@@ -102,11 +114,10 @@ jobs:
102114
artifactory_username: ${{ vars.ARTIFACTORY_USERNAME }}
103115
- uses: mongodb-labs/drivers-github-tools/python/post-publish@v2
104116
with:
105-
version: ${{ inputs.version }}
106-
following_version: ${{ inputs.following_version }}
117+
version: ${{ env.VERSION }}
118+
following_version: ${{ env.FOLLOWING_VERSION }}
107119
product_name: ${{ env.PRODUCT_NAME }}
108120
silk_asset_group: ${{ env.SILK_ASSET_GROUP }}
109121
evergreen_project: ${{ env.EVERGREEN_PROJECT }}
110122
token: ${{ github.token }}
111-
repository_url: https://test.pypi.org/legacy/
112-
dry_run: ${{ inputs.dry_run }}
123+
dry_run: ${{ env.DRY_RUN }}

.github/workflows/test-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ jobs:
5252
- name: Start MongoDB
5353
uses: supercharge/[email protected]
5454
with:
55-
mongodb-version: 5.0
55+
mongodb-version: 6.0
5656
- name: Run tests
5757
run: python3 django_repo/tests/runtests_.py

django_mongodb_backend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.0.0a4.dev0"
1+
__version__ = "5.0.0a3"
22

33
# Check Django compatibility before other imports which may fail if the
44
# wrong version of Django is installed.

django_mongodb_backend/compiler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def _get_column_from_expression(self, expr, alias):
5353
Create a column named `alias` from the given expression to hold the
5454
aggregate value.
5555
"""
56-
column_target = expr.output_field.__class__()
56+
column_target = expr.output_field.clone()
5757
column_target.db_column = alias
5858
column_target.set_attributes_from_name(alias)
5959
return Col(self.collection_name, column_target)
@@ -81,7 +81,7 @@ def _prepare_expressions_for_pipeline(self, expression, target, annotation_group
8181
alias = (
8282
f"__aggregation{next(annotation_group_idx)}" if sub_expr != expression else target
8383
)
84-
column_target = sub_expr.output_field.__class__()
84+
column_target = sub_expr.output_field.clone()
8585
column_target.db_column = alias
8686
column_target.set_attributes_from_name(alias)
8787
inner_column = Col(self.collection_name, column_target)

django_mongodb_backend/features.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import operator
2-
31
from django.db.backends.base.features import BaseDatabaseFeatures
42
from django.utils.functional import cached_property
53

64

75
class DatabaseFeatures(BaseDatabaseFeatures):
8-
minimum_database_version = (5, 0)
6+
minimum_database_version = (6, 0)
97
allow_sliced_subqueries_with_in = False
108
allows_multiple_constraints_on_same_fields = False
119
can_create_inline_fk = False
@@ -24,10 +22,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
2422
supports_expression_indexes = False
2523
supports_foreign_keys = False
2624
supports_ignore_conflicts = False
27-
# Before MongoDB 6.0, $in cannot be used in partialFilterExpression.
28-
supports_in_index_operator = property(operator.attrgetter("is_mongodb_6_0"))
29-
# Before MongoDB 6.0, $or cannot be used in partialFilterExpression.
30-
supports_or_index_operator = property(operator.attrgetter("is_mongodb_6_0"))
3125
supports_json_field_contains = False
3226
# BSON Date type doesn't support microsecond precision.
3327
supports_microsecond_precision = False
@@ -97,16 +91,11 @@ class DatabaseFeatures(BaseDatabaseFeatures):
9791
"expressions.tests.ExpressionOperatorTests.test_lefthand_bitwise_xor_right_null",
9892
"expressions.tests.ExpressionOperatorTests.test_lefthand_transformed_field_bitwise_or",
9993
}
100-
_django_test_expected_failures_partial_expression_in = {
101-
"schema.tests.SchemaTests.test_remove_ignored_unique_constraint_not_create_fk_index",
102-
}
10394

10495
@cached_property
10596
def django_test_expected_failures(self):
10697
expected_failures = super().django_test_expected_failures
10798
expected_failures.update(self._django_test_expected_failures)
108-
if not self.supports_in_index_operator:
109-
expected_failures.update(self._django_test_expected_failures_partial_expression_in)
11099
if not self.is_mongodb_6_3:
111100
expected_failures.update(self._django_test_expected_failures_bitwise)
112101
return expected_failures
@@ -601,10 +590,6 @@ def django_test_expected_failures(self):
601590
},
602591
}
603592

604-
@cached_property
605-
def is_mongodb_6_0(self):
606-
return self.connection.get_database_version() >= (6, 0)
607-
608593
@cached_property
609594
def is_mongodb_6_3(self):
610595
return self.connection.get_database_version() >= (6, 3)

0 commit comments

Comments
 (0)