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
b9cf764b
Kaydet (Commit)
b9cf764b
authored
Haz 22, 2018
tarafından
Tim Graham
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29517 -- Added support for SQLite column check constraints on positive integer fields.
üst
74106185
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
base.py
django/db/backends/sqlite3/base.py
+4
-0
features.py
django/db/backends/sqlite3/features.py
+0
-1
introspection.py
django/db/backends/sqlite3/introspection.py
+26
-0
2.2.txt
docs/releases/2.2.txt
+4
-1
No files found.
django/db/backends/sqlite3/base.py
Dosyayı görüntüle @
b9cf764b
...
...
@@ -76,6 +76,10 @@ class DatabaseWrapper(BaseDatabaseWrapper):
'TimeField'
:
'time'
,
'UUIDField'
:
'char(32)'
,
}
data_type_check_constraints
=
{
'PositiveIntegerField'
:
'"
%(column)
s" >= 0'
,
'PositiveSmallIntegerField'
:
'"
%(column)
s" >= 0'
,
}
data_types_suffix
=
{
'AutoField'
:
'AUTOINCREMENT'
,
'BigAutoField'
:
'AUTOINCREMENT'
,
...
...
django/db/backends/sqlite3/features.py
Dosyayı görüntüle @
b9cf764b
...
...
@@ -14,7 +14,6 @@ class DatabaseFeatures(BaseDatabaseFeatures):
supports_timezones
=
False
max_query_params
=
999
supports_mixed_date_datetime_comparisons
=
False
supports_column_check_constraints
=
False
autocommits_when_autocommit_is_off
=
True
can_introspect_decimal_field
=
False
can_introspect_positive_integer_field
=
True
...
...
django/db/backends/sqlite3/introspection.py
Dosyayı görüntüle @
b9cf764b
...
...
@@ -231,6 +231,32 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
one or more columns.
"""
constraints
=
{}
# Find inline check constraints.
try
:
table_schema
=
cursor
.
execute
(
"SELECT sql FROM sqlite_master WHERE type='table' and name=
%
s"
%
(
self
.
connection
.
ops
.
quote_name
(
table_name
),
)
)
.
fetchone
()[
0
]
except
TypeError
:
# table_name is a view.
pass
else
:
fields_with_check_constraints
=
[
schema_row
.
strip
()
.
split
(
' '
)[
0
][
1
:
-
1
]
for
schema_row
in
table_schema
.
split
(
','
)
if
schema_row
.
find
(
'CHECK'
)
>=
0
]
for
field_name
in
fields_with_check_constraints
:
# An arbitrary made up name.
constraints
[
'__check__
%
s'
%
field_name
]
=
{
'columns'
:
[
field_name
],
'primary_key'
:
False
,
'unique'
:
False
,
'foreign_key'
:
False
,
'check'
:
True
,
'index'
:
False
,
}
# Get the index info
cursor
.
execute
(
"PRAGMA index_list(
%
s)"
%
self
.
connection
.
ops
.
quote_name
(
table_name
))
for
row
in
cursor
.
fetchall
():
...
...
docs/releases/2.2.txt
Dosyayı görüntüle @
b9cf764b
...
...
@@ -218,7 +218,10 @@ Database backend API
Miscellaneous
-------------
* ...
* On SQLite, ``PositiveIntegerField`` and ``PositiveSmallIntegerField`` now
include a check constraint to prevent negative values in the database. If you
have existing invalid data and run a migration that recreates a table, you'll
see ``CHECK constraint failed``.
.. _deprecated-features-2.2:
...
...
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