mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 01:47:57 +03:00 
			
		
		
		
	Define set_rollback instead of using the one in rest_framework.views because of backward compatibility
This commit is contained in:
		
							parent
							
								
									459c8286d7
								
							
						
					
					
						commit
						26b95100d0
					
				| 
						 | 
					@ -864,7 +864,7 @@ def test_model_form_mutation_multiple_creation_invalid_non_atomic(client):
 | 
				
			||||||
        graphene_settings.ATOMIC_MUTATIONS = old_graphene_atomic_mutations
 | 
					        graphene_settings.ATOMIC_MUTATIONS = old_graphene_atomic_mutations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@patch("rest_framework.views.transaction.set_rollback")
 | 
					@patch("graphene_django.utils.utils.transaction.set_rollback")
 | 
				
			||||||
def test_query_errors_atomic_request(set_rollback_mock, client):
 | 
					def test_query_errors_atomic_request(set_rollback_mock, client):
 | 
				
			||||||
    old_atomic_mutations = connection.settings_dict.get("ATOMIC_MUTATIONS", False)
 | 
					    old_atomic_mutations = connection.settings_dict.get("ATOMIC_MUTATIONS", False)
 | 
				
			||||||
    old_atomic_requests = connection.settings_dict["ATOMIC_REQUESTS"]
 | 
					    old_atomic_requests = connection.settings_dict["ATOMIC_REQUESTS"]
 | 
				
			||||||
| 
						 | 
					@ -883,7 +883,7 @@ def test_query_errors_atomic_request(set_rollback_mock, client):
 | 
				
			||||||
        graphene_settings.ATOMIC_MUTATIONS = old_graphene_atomic_mutations
 | 
					        graphene_settings.ATOMIC_MUTATIONS = old_graphene_atomic_mutations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@patch("rest_framework.views.transaction.set_rollback")
 | 
					@patch("graphene_django.utils.utils.transaction.set_rollback")
 | 
				
			||||||
def test_query_errors_non_atomic(set_rollback_mock, client):
 | 
					def test_query_errors_non_atomic(set_rollback_mock, client):
 | 
				
			||||||
    old_atomic_mutations = connection.settings_dict.get("ATOMIC_MUTATIONS", False)
 | 
					    old_atomic_mutations = connection.settings_dict.get("ATOMIC_MUTATIONS", False)
 | 
				
			||||||
    old_atomic_requests = connection.settings_dict["ATOMIC_REQUESTS"]
 | 
					    old_atomic_requests = connection.settings_dict["ATOMIC_REQUESTS"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
import inspect
 | 
					import inspect
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import six
 | 
					import six
 | 
				
			||||||
from django.db import models
 | 
					from django.db import connection, models, transaction
 | 
				
			||||||
from django.db.models.manager import Manager
 | 
					from django.db.models.manager import Manager
 | 
				
			||||||
from django.utils.encoding import force_text
 | 
					from django.utils.encoding import force_text
 | 
				
			||||||
from django.utils.functional import Promise
 | 
					from django.utils.functional import Promise
 | 
				
			||||||
| 
						 | 
					@ -100,3 +100,9 @@ def import_single_dispatch():
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return singledispatch
 | 
					    return singledispatch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def set_rollback():
 | 
				
			||||||
 | 
					    atomic_requests = connection.settings_dict.get("ATOMIC_REQUESTS", False)
 | 
				
			||||||
 | 
					    if atomic_requests and connection.in_atomic_block:
 | 
				
			||||||
 | 
					        transaction.set_rollback(True)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,9 +18,8 @@ from graphql.execution import ExecutionResult
 | 
				
			||||||
from graphql.type.schema import GraphQLSchema
 | 
					from graphql.type.schema import GraphQLSchema
 | 
				
			||||||
from graphql.execution.middleware import MiddlewareManager
 | 
					from graphql.execution.middleware import MiddlewareManager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from rest_framework.views import set_rollback
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
from graphene_django.constants import MUTATION_ERRORS_FLAG
 | 
					from graphene_django.constants import MUTATION_ERRORS_FLAG
 | 
				
			||||||
 | 
					from graphene_django.utils.utils import set_rollback
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from .settings import graphene_settings
 | 
					from .settings import graphene_settings
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user