vintasoftware / django-role-permissions

A django app for role based permissions.
http://django-role-permissions.readthedocs.org/
MIT License
728 stars 114 forks source link

Does not work with transactions? #118

Closed UrK closed 4 years ago

UrK commented 4 years ago

The following code fails when trying to assign role to user with the following error: _django.db.utils.OperationalError: (1305, 'SAVEPOINT s4590886336x1 does not exist')

This does not play well with django.test.TestCase in addition to the fact that using transactions in regular code and not only tests causes this to fail.

from django.contrib.auth.models import User
from rolepermissions.roles import AbstractUserRole

class FooRole(AbstractUserRole):
    available_permissions = {
        "foo": "bar"
    }

user = User.objects.create(username="abc")
with transaction.atomic():
    role = FooRole.assign_role_to_user(user)
filipeximenes commented 4 years ago

Thanks @UrK did you happen to trace the underlying issue? Any additional information on how we can fix this?

UrK commented 4 years ago

Sorry for not closing this. Seems like a problem with Django and MySQL connector.

https://stackoverflow.com/questions/61747732/django-nested-transaction-atomic-throw-integrityerror-savepoint-does-not-exist