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

Adds additional citus and django versions #197

Merged
merged 17 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
48 changes: 38 additions & 10 deletions .github/workflows/django-multitenant-tests.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
name: "Django Multitenant Tests"
on:
push:
branches:
- "**"
pull_request:
types: [ opened, reopened, synchronize ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
static-checks:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -40,17 +41,44 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.7","3.8","3.9","3.10","3.11"]
django_version: ["3.2","4.0"]
citus_version: ["10","11"]
exclude:
python_version: ["3.8","3.9","3.10","3.11"]
django_version: ["3.2","4.0","4.1","4.2"]
citus_version: ["10","11","12"]
include:
- python_version: "3.7"
django_version: "4.0"
django_version: "3.2"
citus_version: "10"
- python_version: "3.7"
django_version: "4.0"
django_version: "3.2"
citus_version: "11"

- python_version: "3.7"
django_version: "3.2"
citus_version: "12"
exclude:
- python_version: "3.8"
django_version: "4.1"
citus_version: "10"
- python_version: "3.9"
django_version: "4.1"
citus_version: "10"
- python_version: "3.10"
django_version: "4.1"
citus_version: "10"
- python_version: "3.11"
django_version: "4.1"
citus_version: "10"
- python_version: "3.8"
django_version: "4.2"
citus_version: "10"
- python_version: "3.9"
django_version: "4.2"
citus_version: "10"
- python_version: "3.10"
django_version: "4.2"
citus_version: "10"
- python_version: "3.11"
django_version: "4.2"
citus_version: "10"
env:
PYTHON_VERSION: ${{ matrix.python_version }}
CITUS_VERSION: ${{ matrix.citus_version }}
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ https://www.citusdata.com/blog/2023/05/09/evolving-django-multitenant-to-build-s

| Python | Django |Citus |
| ----------------------| --------------|---------------|
| 3.8 3.9 3.10 3.11 | 4.1 | 11 |
| 3.8 3.9 3.10 3.11 | 4.0 | 10 11 |
| 3.7 | 3.2 | 10 11 |
| 3.8 3.9 3.10 3.11 | 4.2 | 11 12 |
| 3.8 3.9 3.10 3.11 | 4.1 | 11 12 |
| 3.8 3.9 3.10 3.11 | 4.0 | 10 11 12 |
| 3.7 | 3.2 | 10 11 12 |



Expand Down
23 changes: 18 additions & 5 deletions django_multitenant/tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from datetime import date
import re
import pytest
import django

from django.conf import settings
from django.db.models import Count
Expand Down Expand Up @@ -304,11 +305,16 @@ def test_delete_tenant_set(self):
self.assertEqual(Project.objects.count(), 30)

set_current_tenant(account)
with self.assertNumQueries(7) as captured_queries:
query_count = 9 if django.VERSION >= (4, 2) else 7
with self.assertNumQueries(query_count) as captured_queries:
Project.objects.all().delete()
unset_current_tenant()

for query in captured_queries.captured_queries:
print(f"SQL: {query['sql']}")

if query["sql"] in ["BEGIN", "COMMIT"]:
continue
if "tests_revenue" in query["sql"]:
self.assertTrue(f'"acc_id" = {account.id}' in query["sql"])
else:
Expand Down Expand Up @@ -471,7 +477,9 @@ def test_delete_cascade_distributed(self):

project = Project.objects.first()

with self.assertNumQueries(12) as captured_queries:
query_count = 14 if django.VERSION >= (4, 2) else 12

with self.assertNumQueries(query_count) as captured_queries:
project.delete()

self.assertEqual(Project.objects.count(), 9)
Expand Down Expand Up @@ -502,7 +510,8 @@ def test_delete_cascade_reference_to_distributed(self):

self.assertEqual(Account.objects.count(), 2)

with self.assertNumQueries(16) as captured_queries:
query_count = 18 if django.VERSION >= (4, 2) else 16
with self.assertNumQueries(query_count) as captured_queries:
country.delete()

self.assertEqual(Account.objects.count(), 0)
Expand Down Expand Up @@ -543,7 +552,9 @@ def test_delete_cascade_distributed_to_reference(self):
self.assertEqual(Project.objects.count(), 30)

set_current_tenant(account)
with self.assertNumQueries(28) as captured_queries:

query_count = 29 if django.VERSION >= (4, 2) else 28
with self.assertNumQueries(query_count) as captured_queries:
account.delete()

# Once deleted, we don't have a current tenant
Expand Down Expand Up @@ -670,7 +681,9 @@ def test_delete_tenant_set(self):
self.assertEqual(Project.objects.count(), 30)

set_current_tenant(accounts)
with self.assertNumQueries(8) as captured_queries:

query_count = 10 if django.VERSION >= (4, 2) else 8
with self.assertNumQueries(query_count) as captured_queries:
Project.objects.all().delete()

for query in captured_queries.captured_queries:
Expand Down
22 changes: 11 additions & 11 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# This file is autogenerated by pip-compile with Python 3.8
# by the following command:
#
# pip-compile --resolver=backtracking docs/requirements.in
# pip-compile --output-file=docs/requirements.txt --resolver=backtracking docs/requirements.in
#
alabaster==0.7.13
# via sphinx
babel==2.12.1
# via sphinx
certifi==2023.5.7
certifi==2023.7.22
# via requests
charset-normalizer==3.1.0
charset-normalizer==3.2.0
# via requests
docutils==0.18.1
# via
Expand All @@ -20,31 +20,31 @@ idna==3.4
# via requests
imagesize==1.4.1
# via sphinx
importlib-metadata==6.6.0
importlib-metadata==6.8.0
# via sphinx
jinja2==3.1.2
# via sphinx
markupsafe==2.1.2
markupsafe==2.1.3
# via jinja2
packaging==23.1
# via sphinx
pygments==2.15.1
pygments==2.16.1
# via sphinx
pytz==2023.3
pytz==2023.3.post1
# via babel
readthedocs-sphinx-search==0.3.1
# via -r docs/requirements.in
requests==2.31.0
# via sphinx
snowballstemmer==2.2.0
# via sphinx
sphinx==6.2.1
sphinx==7.1.2
# via
# -r docs/requirements.in
# sphinx-rtd-theme
# sphinxcontrib-jquery
# sphinxnotes-strike
sphinx-rtd-theme==1.2.1
sphinx-rtd-theme==1.3.0
# via -r docs/requirements.in
sphinxcontrib-applehelp==1.0.4
# via sphinx
Expand All @@ -62,7 +62,7 @@ sphinxcontrib-serializinghtml==1.1.5
# via sphinx
sphinxnotes-strike==1.2
# via -r docs/requirements.in
urllib3==2.0.2
urllib3==2.0.5
# via requests
zipp==3.15.0
zipp==3.17.0
# via importlib-metadata
13 changes: 7 additions & 6 deletions docs/source/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ Installation
Supported Django and Citus versions/Pre-requisites
===================================================

================= ====== =====
================= ====== =========
Python Django Citus
================= ====== =====
3.7,3.8,3.9,3.10 3.2 10 11
3.8 3.9 3.10 3.11 4.0 10 11
3.8 3.9 3.10 3.11 4.1 11
================= ====== =====
================= ====== =========
3.8 3.9 3.10 3.11 4.2 11 12
3.8 3.9 3.10 3.11 4.1 11 12
3.8 3.9 3.10 3.11 4.0 10 11 12
3.7 3.2 10 11 12
================= ====== =========
31 changes: 14 additions & 17 deletions requirements/release-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,26 @@
#
# pip-compile --output-file=requirements/release-requirements.txt --resolver=backtracking requirements/release.in
#
bleach==6.0.0
# via readme-renderer
build==0.10.0
build==1.0.3
# via -r requirements/release.in
certifi==2023.5.7
certifi==2023.7.22
# via requests
cffi==1.15.1
# via cryptography
charset-normalizer==3.2.0
# via requests
cryptography==41.0.2
cryptography==41.0.4
# via secretstorage
docutils==0.20.1
# via readme-renderer
idna==3.4
# via requests
importlib-metadata==6.8.0
# via
# build
# keyring
# twine
importlib-resources==6.0.0
importlib-resources==6.1.0
# via keyring
jaraco-classes==3.3.0
# via keyring
Expand All @@ -38,21 +37,23 @@ markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
more-itertools==9.1.0
more-itertools==10.1.0
# via jaraco-classes
nh3==0.2.14
# via readme-renderer
packaging==23.1
# via build
pkginfo==1.9.6
# via twine
pycparser==2.21
# via cffi
pygments==2.15.1
pygments==2.16.1
# via
# readme-renderer
# rich
pyproject-hooks==1.0.0
# via build
readme-renderer==40.0
readme-renderer==42.0
# via twine
requests==2.31.0
# via
Expand All @@ -62,27 +63,23 @@ requests-toolbelt==1.0.0
# via twine
rfc3986==2.0.0
# via twine
rich==13.4.2
rich==13.5.3
# via twine
secretstorage==3.3.3
# via keyring
six==1.16.0
# via bleach
tomli==2.0.1
# via
# build
# pyproject-hooks
twine==4.0.2
# via -r requirements/release.in
typing-extensions==4.7.1
typing-extensions==4.8.0
# via rich
urllib3==2.0.3
urllib3==2.0.5
# via
# requests
# twine
webencodings==0.5.1
# via bleach
zipp==3.16.0
zipp==3.17.0
# via
# importlib-metadata
# importlib-resources
Loading