Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
e654180c
Kaydet (Commit)
e654180c
authored
Mar 11, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improved the API of set_autocommit.
üst
f3210093
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
24 deletions
+24
-24
__init__.py
django/db/backends/__init__.py
+2
-2
creation.py
django/db/backends/creation.py
+1
-1
transaction.py
django/db/transaction.py
+1
-1
transactions.txt
docs/topics/db/transactions.txt
+5
-5
tests.py
tests/backends/tests.py
+6
-6
tests.py
tests/fixtures_model_package/tests.py
+4
-4
tests.py
tests/fixtures_regress/tests.py
+2
-2
tests.py
tests/transactions/tests.py
+3
-3
No files found.
django/db/backends/__init__.py
Dosyayı görüntüle @
e654180c
...
...
@@ -108,7 +108,7 @@ class BaseDatabaseWrapper(object):
self
.
connection
=
self
.
get_new_connection
(
conn_params
)
self
.
init_connection_state
()
if
self
.
settings_dict
[
'AUTOCOMMIT'
]:
self
.
set_autocommit
()
self
.
set_autocommit
(
True
)
connection_created
.
send
(
sender
=
self
.
__class__
,
connection
=
self
)
def
ensure_connection
(
self
):
...
...
@@ -314,7 +314,7 @@ class BaseDatabaseWrapper(object):
if
managed
==
self
.
autocommit
:
self
.
set_autocommit
(
not
managed
)
def
set_autocommit
(
self
,
autocommit
=
True
):
def
set_autocommit
(
self
,
autocommit
):
"""
Enable or disable autocommit.
"""
...
...
django/db/backends/creation.py
Dosyayı görüntüle @
e654180c
...
...
@@ -466,7 +466,7 @@ class BaseDatabaseCreation(object):
warnings
.
warn
(
"set_autocommit was moved from BaseDatabaseCreation to "
"BaseDatabaseWrapper."
,
PendingDeprecationWarning
,
stacklevel
=
2
)
return
self
.
connection
.
set_autocommit
()
return
self
.
connection
.
set_autocommit
(
True
)
def
sql_table_creation_suffix
(
self
):
"""
...
...
django/db/transaction.py
Dosyayı görüntüle @
e654180c
...
...
@@ -124,7 +124,7 @@ def get_autocommit(using=None):
"""
return
get_connection
(
using
)
.
autocommit
def
set_autocommit
(
using
=
None
,
autocommit
=
Tru
e
):
def
set_autocommit
(
autocommit
,
using
=
Non
e
):
"""
Set the autocommit status of the connection.
"""
...
...
docs/topics/db/transactions.txt
Dosyayı görüntüle @
e654180c
...
...
@@ -255,7 +255,7 @@ database connection, if you need to.
.. function:: get_autocommit(using=None)
.. function:: set_autocommit(
using=None, autocommit=Tru
e)
.. function:: set_autocommit(
autocommit, using=Non
e)
These functions take a ``using`` argument which should be the name of a
database. If it isn't provided, Django uses the ``"default"`` database.
...
...
@@ -600,11 +600,11 @@ To disable autocommit temporarily, instead of::
you should now use::
transaction.set_autocommit(
autocommit=
False)
transaction.set_autocommit(False)
try:
# do stuff
finally:
transaction.set_autocommit(
autocommit=
True)
transaction.set_autocommit(True)
To enable autocommit temporarily, instead of::
...
...
@@ -613,11 +613,11 @@ To enable autocommit temporarily, instead of::
you should now use::
transaction.set_autocommit(
autocommit=
True)
transaction.set_autocommit(True)
try:
# do stuff
finally:
transaction.set_autocommit(
autocommit=
False)
transaction.set_autocommit(False)
Disabling transaction management
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
tests/backends/tests.py
Dosyayı görüntüle @
e654180c
...
...
@@ -522,7 +522,7 @@ class FkConstraintsTests(TransactionTestCase):
"""
When constraint checks are disabled, should be able to write bad data without IntegrityErrors.
"""
transaction
.
set_autocommit
(
autocommit
=
False
)
transaction
.
set_autocommit
(
False
)
try
:
# Create an Article.
models
.
Article
.
objects
.
create
(
headline
=
"Test article"
,
pub_date
=
datetime
.
datetime
(
2010
,
9
,
4
),
reporter
=
self
.
r
)
...
...
@@ -538,13 +538,13 @@ class FkConstraintsTests(TransactionTestCase):
finally
:
transaction
.
rollback
()
finally
:
transaction
.
set_autocommit
(
autocommit
=
True
)
transaction
.
set_autocommit
(
True
)
def
test_disable_constraint_checks_context_manager
(
self
):
"""
When constraint checks are disabled (using context manager), should be able to write bad data without IntegrityErrors.
"""
transaction
.
set_autocommit
(
autocommit
=
False
)
transaction
.
set_autocommit
(
False
)
try
:
# Create an Article.
models
.
Article
.
objects
.
create
(
headline
=
"Test article"
,
pub_date
=
datetime
.
datetime
(
2010
,
9
,
4
),
reporter
=
self
.
r
)
...
...
@@ -559,14 +559,14 @@ class FkConstraintsTests(TransactionTestCase):
finally
:
transaction
.
rollback
()
finally
:
transaction
.
set_autocommit
(
autocommit
=
True
)
transaction
.
set_autocommit
(
True
)
def
test_check_constraints
(
self
):
"""
Constraint checks should raise an IntegrityError when bad data is in the DB.
"""
try
:
transaction
.
set_autocommit
(
autocommit
=
False
)
transaction
.
set_autocommit
(
False
)
# Create an Article.
models
.
Article
.
objects
.
create
(
headline
=
"Test article"
,
pub_date
=
datetime
.
datetime
(
2010
,
9
,
4
),
reporter
=
self
.
r
)
# Retrive it from the DB
...
...
@@ -580,7 +580,7 @@ class FkConstraintsTests(TransactionTestCase):
finally
:
transaction
.
rollback
()
finally
:
transaction
.
set_autocommit
(
autocommit
=
True
)
transaction
.
set_autocommit
(
True
)
class
ThreadTests
(
TestCase
):
...
...
tests/fixtures_model_package/tests.py
Dosyayı görüntüle @
e654180c
...
...
@@ -25,7 +25,7 @@ class SampleTestCase(TestCase):
class
TestNoInitialDataLoading
(
TransactionTestCase
):
def
test_syncdb
(
self
):
transaction
.
set_autocommit
(
autocommit
=
False
)
transaction
.
set_autocommit
(
False
)
try
:
Book
.
objects
.
all
()
.
delete
()
...
...
@@ -37,7 +37,7 @@ class TestNoInitialDataLoading(TransactionTestCase):
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
transaction
.
rollback
()
finally
:
transaction
.
set_autocommit
(
autocommit
=
True
)
transaction
.
set_autocommit
(
True
)
def
test_flush
(
self
):
...
...
@@ -49,7 +49,7 @@ class TestNoInitialDataLoading(TransactionTestCase):
lambda
a
:
a
.
name
)
transaction
.
set_autocommit
(
autocommit
=
False
)
transaction
.
set_autocommit
(
False
)
try
:
management
.
call_command
(
'flush'
,
...
...
@@ -61,7 +61,7 @@ class TestNoInitialDataLoading(TransactionTestCase):
self
.
assertQuerysetEqual
(
Book
.
objects
.
all
(),
[])
transaction
.
rollback
()
finally
:
transaction
.
set_autocommit
(
autocommit
=
True
)
transaction
.
set_autocommit
(
True
)
class
FixtureTestCase
(
TestCase
):
...
...
tests/fixtures_regress/tests.py
Dosyayı görüntüle @
e654180c
...
...
@@ -684,8 +684,8 @@ class TestTicket11101(TransactionTestCase):
@skipUnlessDBFeature
(
'supports_transactions'
)
def
test_ticket_11101
(
self
):
"""Test that fixtures can be rolled back (ticket #11101)."""
transaction
.
set_autocommit
(
autocommit
=
False
)
transaction
.
set_autocommit
(
False
)
try
:
self
.
ticket_11101
()
finally
:
transaction
.
set_autocommit
(
autocommit
=
True
)
transaction
.
set_autocommit
(
True
)
tests/transactions/tests.py
Dosyayı görüntüle @
e654180c
...
...
@@ -269,19 +269,19 @@ class AtomicMergeTests(TransactionTestCase):
class
AtomicErrorsTests
(
TransactionTestCase
):
def
test_atomic_requires_autocommit
(
self
):
transaction
.
set_autocommit
(
autocommit
=
False
)
transaction
.
set_autocommit
(
False
)
try
:
with
self
.
assertRaises
(
transaction
.
TransactionManagementError
):
with
transaction
.
atomic
():
pass
finally
:
transaction
.
set_autocommit
(
autocommit
=
True
)
transaction
.
set_autocommit
(
True
)
def
test_atomic_prevents_disabling_autocommit
(
self
):
autocommit
=
transaction
.
get_autocommit
()
with
transaction
.
atomic
():
with
self
.
assertRaises
(
transaction
.
TransactionManagementError
):
transaction
.
set_autocommit
(
autocommit
=
not
autocommit
)
transaction
.
set_autocommit
(
not
autocommit
)
# Make sure autocommit wasn't changed.
self
.
assertEqual
(
connection
.
autocommit
,
autocommit
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment