Skip to content

Commit

Permalink
#133 #132 Support mysql8
Browse files Browse the repository at this point in the history
[#133 #132] Support MySQL 8.0
  • Loading branch information
javrasya authored Jan 30, 2020
1 parent a246966 commit 0c58ec6
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ matrix:
env: TOXENV=py36-dj2.2-postgresql12
services:
- docker
- python: "3.6"
env: TOXENV=py36-dj2.2-mysql8.0
services:
- docker
install:
- pip install tox-travis
- pip install tox-docker
Expand Down
26 changes: 25 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,31 @@ Requirements
* Django (``1.11``, ``2.0``, ``2.1``, ``2.2``)
* ``Django`` >= 2.0 is supported for ``Python`` >= 3.5

\:star\: Tested with PostgreSQL ``9``, ``10``, ``11`` and ``12``
Supported (Tested) Databases:
-----------------------------

+------------+--------+---------+
| PostgreSQL | Tested | Support |
+------------+--------+---------+
| 9 |||
+------------+--------+---------+
| 10 |||
+------------+--------+---------+
| 11 |||
+------------+--------+---------+
| 12 |||
+------------+--------+---------+

+------------+--------+---------+
| MySQL | Tested | Support |
+------------+--------+---------+
| 5.6 |||
+------------+--------+---------+
| 5.7 |||
+------------+--------+---------+
| 8.0 |||
+------------+--------+---------+


Usage
-----
Expand Down
13 changes: 10 additions & 3 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
Change Logs
===========

3.1.1 (Stable)
--------------
* **Bug** - # 128_: Available approvals are not found properly when primary key is string
3.1.2 (Stable):
---------------
* **Improvement** - # 133_: Support MySQL 8.0


.. _133: https://github.com/javrasya/django-river/issues/133

3.1.1
-----
* **Bug** - # 128_: Available approvals are not found properly when primary key is string
* **Bug** - # 129_: Models with string typed primary keys violates integer field in the hooks


Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
# built documents.
#
# The short X.Y version.
version = '3.1.1'
version = '3.1.2'
# The full version, including alpha/beta/rc tags.
release = '3.1.1'
release = '3.1.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
28 changes: 27 additions & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,33 @@ Requirements
* Python (``2.7``, ``3.4``, ``3.5``, ``3.6``)
* Django (``1.11``, ``2.0``, ``2.1``, ``2.2``)
* ``Django`` >= 2.0 is supported for ``Python`` >= 3.5
* Tested with PostgreSQL ``9``, ``10``, ``11`` and ``12``


Supported (Tested) Databases:
-----------------------------

+------------+--------+---------+
| PostgreSQL | Tested | Support |
+------------+--------+---------+
| 9 |||
+------------+--------+---------+
| 10 |||
+------------+--------+---------+
| 11 |||
+------------+--------+---------+
| 12 |||
+------------+--------+---------+

+------------+--------+---------+
| MySQL | Tested | Support |
+------------+--------+---------+
| 5.6 |||
+------------+--------+---------+
| 5.7 |||
+------------+--------+---------+
| 8.0 |||
+------------+--------+---------+


Example Scenarios
-----------------
Expand Down
11 changes: 8 additions & 3 deletions river/core/instanceworkflowobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ def _transitions_before(iteration):
).earliest("iteration")

jumped_transitions = _transitions_before(jumped_transition.iteration).filter(status=PENDING)
TransitionApproval.objects.filter(pk__in=jumped_transitions.values_list("transition_approvals__pk", flat=True)).update(status=JUMPED)
for approval in TransitionApproval.objects.filter(pk__in=jumped_transitions.values_list("transition_approvals__pk", flat=True)):
approval.status = JUMPED
approval.save()
jumped_transitions.update(status=JUMPED)
self.set_state(state)
self.workflow_object.save()
Expand Down Expand Up @@ -199,8 +201,11 @@ def cancel_impossible_future(self, approved_approval):
transitions = Transition.objects.filter(qs)
iteration += 1

actual_cancelled_transitions = Transition.objects.filter(cancelled_transitions_qs & ~uncancelled_transitions_qs)
actual_cancelled_transitions.update(status=CANCELLED)
actual_cancelled_transitions = Transition.objects.select_for_update(nowait=True).filter(cancelled_transitions_qs & ~uncancelled_transitions_qs)
for actual_cancelled_transition in actual_cancelled_transitions:
actual_cancelled_transition.status = CANCELLED
actual_cancelled_transition.save()

TransitionApproval.objects.filter(transition__in=actual_cancelled_transitions).update(status=CANCELLED)

def _approve_signal(self, approval):
Expand Down
27 changes: 27 additions & 0 deletions settings/with_mysql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from uuid import uuid4

from .base import *

DB_HOST = os.environ['MYSQL_HOST']
DB_PORT = os.environ['MYSQL_3306_TCP_PORT']

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'river',
'USER': 'root',
'PASSWORD': 'river',
'HOST': DB_HOST,
'PORT': DB_PORT,
'TEST': {
'NAME': 'river' + str(uuid4()),
},
}
}

INSTALLED_APPS += (
'river.tests',
)

if django.get_version() >= '1.9.0':
MIGRATION_MODULES = DisableMigrations()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name='django-river',
version='3.1.1',
version='3.1.2',
author='Ahmet DAL',
author_email='[email protected]',
packages=find_packages(),
Expand Down
15 changes: 14 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ envlist = {py27,py34}-{dj1.11}-{sqlite3},
{py35}-{dj1.11,dj2.0,dj2.1,dj2.2}-{sqlite3},
{py36}-{dj1.11,dj2.0,dj2.1,dj2.2}-{sqlite3},
{py36}-{dj2.2}-{postgresql9,postgresql10,postgresql11,postgresql12},
{py36}-{dj2.2}-{mysql8.0},
cov,

[testenv]
Expand All @@ -11,13 +12,19 @@ docker =
postgresql10: postgres:10-alpine
postgresql11: postgres:11-alpine
postgresql12: postgres:12-alpine
mysql8.0: mysql:8.0
dockerenv =
POSTGRES_USER=river
POSTGRES_PASSWORD=river
POSTGRES_DB=river
MYSQL_ROOT_PASSWORD=river
MYSQL_USER=river
MYSQL_PASSWORD=river
MYSQL_DATABASE=river
setenv =
sqlite3: DJANGO_SETTINGS_MODULE=settings.with_sqlite3
postgresql9,postgresql10,postgresql11,postgresql12: DJANGO_SETTINGS_MODULE=settings.with_postgresql
mysql8.0: DJANGO_SETTINGS_MODULE=settings.with_mysql
deps =
{dj1.11,dj2.0,dj2.1,dj2.2}: pytest-django>3.1.2
pytest-cov
Expand All @@ -27,6 +34,7 @@ deps =
dj2.1: Django>=2.1,<2.2.0
dj2.2: Django>=2.2,<2.3.0
postgresql9,postgresql10,postgresql11,postgresql12: psycopg2
mysql8.0: mysqlclient
commands =
py.test --junitxml=../junit-{envname}.xml
python manage.py behave
Expand All @@ -41,4 +49,9 @@ deps =
commands =
py.test --ds='settings.with_sqlite3' --cov ./ --cov-report term-missing


[docker:mysql:8.0]
healthcheck_cmd = 'mysqladmin ping --silent -u root --password=river'
healthcheck_interval = 10
healthcheck_start_period = 5
healthcheck_retries = 30
healthcheck_timeout = 10

0 comments on commit 0c58ec6

Please sign in to comment.