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
8ddc79a7
Kaydet (Commit)
8ddc79a7
authored
Haz 05, 2015
tarafından
Marc Tamlyn
Kaydeden (comit)
Tim Graham
Mar 02, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #26285 -- Deprecated the MySQL-specific __search lookup.
üst
04240b23
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
10 deletions
+46
-10
operations.py
django/db/backends/base/operations.py
+1
-0
operations.py
django/db/backends/mysql/operations.py
+1
-0
lookups.py
django/db/models/lookups.py
+6
-0
deprecation.txt
docs/internals/deprecation.txt
+3
-0
fields.txt
docs/ref/models/fields.txt
+2
-9
querysets.txt
docs/ref/models/querysets.txt
+5
-0
1.10.txt
docs/releases/1.10.txt
+22
-0
models.py
tests/lookup/models.py
+1
-0
tests.py
tests/lookup/tests.py
+5
-1
No files found.
django/db/backends/base/operations.py
Dosyayı görüntüle @
8ddc79a7
...
@@ -191,6 +191,7 @@ class BaseDatabaseOperations(object):
...
@@ -191,6 +191,7 @@ class BaseDatabaseOperations(object):
search of the given field_name. Note that the resulting string should
search of the given field_name. Note that the resulting string should
contain a '
%
s' placeholder for the value being searched against.
contain a '
%
s' placeholder for the value being searched against.
"""
"""
# RemovedInDjango20Warning
raise
NotImplementedError
(
'Full-text search is not implemented for this database backend'
)
raise
NotImplementedError
(
'Full-text search is not implemented for this database backend'
)
def
last_executed_query
(
self
,
cursor
,
sql
,
params
):
def
last_executed_query
(
self
,
cursor
,
sql
,
params
):
...
...
django/db/backends/mysql/operations.py
Dosyayı görüntüle @
8ddc79a7
...
@@ -91,6 +91,7 @@ class DatabaseOperations(BaseDatabaseOperations):
...
@@ -91,6 +91,7 @@ class DatabaseOperations(BaseDatabaseOperations):
return
[(
None
,
(
"NULL"
,
[],
False
))]
return
[(
None
,
(
"NULL"
,
[],
False
))]
def
fulltext_search_sql
(
self
,
field_name
):
def
fulltext_search_sql
(
self
,
field_name
):
# RemovedInDjango20Warning
return
'MATCH (
%
s) AGAINST (
%%
s IN BOOLEAN MODE)'
%
field_name
return
'MATCH (
%
s) AGAINST (
%%
s IN BOOLEAN MODE)'
%
field_name
def
last_executed_query
(
self
,
cursor
,
sql
,
params
):
def
last_executed_query
(
self
,
cursor
,
sql
,
params
):
...
...
django/db/models/lookups.py
Dosyayı görüntüle @
8ddc79a7
import
warnings
from
copy
import
copy
from
copy
import
copy
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -7,6 +8,7 @@ from django.db.models.fields import (
...
@@ -7,6 +8,7 @@ from django.db.models.fields import (
)
)
from
django.db.models.query_utils
import
RegisterLookupMixin
from
django.db.models.query_utils
import
RegisterLookupMixin
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
django.utils.functional
import
cached_property
from
django.utils.functional
import
cached_property
from
django.utils.six.moves
import
range
from
django.utils.six.moves
import
range
...
@@ -373,6 +375,10 @@ class Search(BuiltinLookup):
...
@@ -373,6 +375,10 @@ class Search(BuiltinLookup):
lookup_name
=
'search'
lookup_name
=
'search'
def
as_sql
(
self
,
compiler
,
connection
):
def
as_sql
(
self
,
compiler
,
connection
):
warnings
.
warn
(
'The `__search` lookup is deprecated. See the 1.10 release notes '
'for how to replace it.'
,
RemovedInDjango20Warning
,
stacklevel
=
2
)
lhs
,
lhs_params
=
self
.
process_lhs
(
compiler
,
connection
)
lhs
,
lhs_params
=
self
.
process_lhs
(
compiler
,
connection
)
rhs
,
rhs_params
=
self
.
process_rhs
(
compiler
,
connection
)
rhs
,
rhs_params
=
self
.
process_rhs
(
compiler
,
connection
)
sql_template
=
connection
.
ops
.
fulltext_search_sql
(
field_name
=
lhs
)
sql_template
=
connection
.
ops
.
fulltext_search_sql
(
field_name
=
lhs
)
...
...
docs/internals/deprecation.txt
Dosyayı görüntüle @
8ddc79a7
...
@@ -141,6 +141,9 @@ details on these changes.
...
@@ -141,6 +141,9 @@ details on these changes.
* Support for query lookups using the model name when
* Support for query lookups using the model name when
``Meta.default_related_name`` is set will be removed.
``Meta.default_related_name`` is set will be removed.
* The ``__search`` query lookup and the
``DatabaseOperations.fulltext_search_sql()`` method will be removed.
.. _deprecation-removed-in-1.10:
.. _deprecation-removed-in-1.10:
1.10
1.10
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
8ddc79a7
...
@@ -1847,15 +1847,8 @@ Field API reference
...
@@ -1847,15 +1847,8 @@ Field API reference
.. method:: get_prep_lookup(lookup_type, value)
.. method:: get_prep_lookup(lookup_type, value)
Prepares ``value`` to the database prior to be used in a lookup.
Prepares ``value`` to the database prior to be used in a lookup.
The ``lookup_type`` will be one of the valid Django filter lookups:
The ``lookup_type`` will be the registered name of the lookup. For
``"exact"``, ``"iexact"``, ``"contains"``, ``"icontains"``,
example: ``"exact"``, ``"iexact"``, or ``"contains"``.
``"gt"``, ``"gte"``, ``"lt"``, ``"lte"``, ``"in"``, ``"startswith"``,
``"istartswith"``, ``"endswith"``, ``"iendswith"``, ``"range"``,
``"year"``, ``"month"``, ``"day"``, ``"isnull"``, ``"search"``,
``"regex"``, and ``"iregex"``.
If you are using :doc:`Custom lookups </ref/models/lookups>` the
``lookup_type`` can be any ``lookup_name`` registered in the field.
See :ref:`preparing-values-for-use-in-database-lookups` for usage.
See :ref:`preparing-values-for-use-in-database-lookups` for usage.
...
...
docs/ref/models/querysets.txt
Dosyayı görüntüle @
8ddc79a7
...
@@ -2771,6 +2771,11 @@ SQL equivalent::
...
@@ -2771,6 +2771,11 @@ SQL equivalent::
``search``
``search``
~~~~~~~~~~
~~~~~~~~~~
.. deprecated:: 1.10
See :ref:`the 1.10 release notes <search-lookup-replacement>` for how to
replace it.
A boolean full-text search, taking advantage of full-text indexing. This is
A boolean full-text search, taking advantage of full-text indexing. This is
like :lookup:`contains` but is significantly faster due to full-text indexing.
like :lookup:`contains` but is significantly faster due to full-text indexing.
...
...
docs/releases/1.10.txt
Dosyayı görüntüle @
8ddc79a7
...
@@ -740,6 +740,28 @@ use the default_related_name ``bars``::
...
@@ -740,6 +740,28 @@ use the default_related_name ``bars``::
>>> Foo.object.get(bars=bar)
>>> Foo.object.get(bars=bar)
.. _search-lookup-replacement:
``__search`` query lookup
-------------------------
The ``search`` lookup, which supports MySQL only and is extremely limited in
features, is deprecated. Replace it with a custom lookup::
from django.db import models
class Search(models.Lookup):
lookup_name = 'search'
def as_mysql(self, compiler, connection):
lhs, lhs_params = self.process_lhs(compiler, connection)
rhs, rhs_params = self.process_rhs(compiler, connection)
params = lhs_params + rhs_params
return 'MATCH (%s) AGAINST (%s IN BOOLEAN MODE)' % (lhs, rhs), params
models.CharField.register_lookup(Search)
models.TextField.register_lookup(Search)
Miscellaneous
Miscellaneous
-------------
-------------
...
...
tests/lookup/models.py
Dosyayı görüntüle @
8ddc79a7
...
@@ -79,6 +79,7 @@ class Player(models.Model):
...
@@ -79,6 +79,7 @@ class Player(models.Model):
# is only available when using MySQL 5.6, or when using MyISAM
# is only available when using MySQL 5.6, or when using MyISAM
# tables. As 5.6 isn't common yet, lets use MyISAM table for
# tables. As 5.6 isn't common yet, lets use MyISAM table for
# testing. The table is manually created by the test method.
# testing. The table is manually created by the test method.
# RemovedInDjango20Warning
class
MyISAMArticle
(
models
.
Model
):
class
MyISAMArticle
(
models
.
Model
):
headline
=
models
.
CharField
(
max_length
=
100
)
headline
=
models
.
CharField
(
max_length
=
100
)
...
...
tests/lookup/tests.py
Dosyayı görüntüle @
8ddc79a7
...
@@ -7,7 +7,10 @@ from unittest import skipUnless
...
@@ -7,7 +7,10 @@ from unittest import skipUnless
from
django.core.exceptions
import
FieldError
from
django.core.exceptions
import
FieldError
from
django.db
import
connection
from
django.db
import
connection
from
django.test
import
TestCase
,
TransactionTestCase
,
skipUnlessDBFeature
from
django.test
import
(
TestCase
,
TransactionTestCase
,
ignore_warnings
,
skipUnlessDBFeature
,
)
from
django.utils.deprecation
import
RemovedInDjango20Warning
from
.models
import
Article
,
Author
,
Game
,
MyISAMArticle
,
Player
,
Season
,
Tag
from
.models
import
Article
,
Author
,
Game
,
MyISAMArticle
,
Player
,
Season
,
Tag
...
@@ -792,6 +795,7 @@ class LookupTests(TestCase):
...
@@ -792,6 +795,7 @@ class LookupTests(TestCase):
class
LookupTransactionTests
(
TransactionTestCase
):
class
LookupTransactionTests
(
TransactionTestCase
):
available_apps
=
[
'lookup'
]
available_apps
=
[
'lookup'
]
@ignore_warnings
(
category
=
RemovedInDjango20Warning
)
@skipUnless
(
connection
.
vendor
==
'mysql'
,
'requires MySQL'
)
@skipUnless
(
connection
.
vendor
==
'mysql'
,
'requires MySQL'
)
def
test_mysql_lookup_search
(
self
):
def
test_mysql_lookup_search
(
self
):
# To use fulltext indexes on MySQL either version 5.6 is needed, or one must use
# To use fulltext indexes on MySQL either version 5.6 is needed, or one must use
...
...
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