コード例 #1
0
def test_query_select_related_and_for_update_when_using_of():
    with query_lock_limiter(enable=True):
        list(SampleModelWithFK.objects.select_related().select_for_update(of=("self",)))
コード例 #2
0
def test_query_select_related_and_for_update():
    with pytest.raises(WouldSelectMultipleTablesForUpdate):
        with query_lock_limiter(enable=True):
            list(SampleModelWithFK.objects.select_related().select_for_update())
コード例 #3
0
def test_query_locking_whitelisted_multiple_tables():
    whitelist = [["tests_samplemodel", "tests_samplemodelwithfk"]]
    with query_lock_limiter(enable=True, whitelisted_table_sets=whitelist):
        list(SampleModelWithFK.objects.filter(parent__a="").select_for_update())
コード例 #4
0
def test_query_locking_multiple_tables():
    with pytest.raises(WouldSelectMultipleTablesForUpdate):
        with query_lock_limiter(enable=True):
            list(SampleModelWithFK.objects.filter(parent__a="").select_for_update())
コード例 #5
0
def test_queries_locking_single_tables():
    with query_lock_limiter(enable=True):
        list(SampleModel.objects.all().select_for_update())
        list(SampleModelWithFK.objects.all().select_for_update())
コード例 #6
0
def test_nonlocking_queries():
    with query_lock_limiter(enable=True):
        list(SampleModel.objects.all())
        list(SampleModelWithFK.objects.all().select_related())