Changeset 207
- Timestamp:
- 07/19/05 10:24:03 (3 years ago)
- Files:
-
- django/trunk/django/core/db/backends/mysql.py (modified) (1 diff)
- django/trunk/django/core/db/backends/postgresql.py (modified) (1 diff)
- django/trunk/docs/db-api.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/db/backends/mysql.py
r190 r207 100 100 'lte': '<=', 101 101 'startswith': 'LIKE', 102 'endswith': 'LIKE' 102 'endswith': 'LIKE', 103 'istartswith': 'ILIKE', 104 'iendswith': 'ILIKE', 103 105 } 104 106 django/trunk/django/core/db/backends/postgresql.py
r161 r207 94 94 'lte': '<=', 95 95 'startswith': 'LIKE', 96 'endswith': 'LIKE' 96 'endswith': 'LIKE', 97 'istartswith': 'ILIKE', 98 'iendswith': 'ILIKE', 97 99 } 98 100 django/trunk/docs/db-api.txt
r67 r207 53 53 Type Description 54 54 ========== ============================================================== 55 exact Exact match: ``polls.get_object(id__exact=14)`` 55 exact Exact match: ``polls.get_object(id__exact=14)``. 56 56 iexact Case-insensitive exact match: 57 57 ``polls.get_list(slug__iexact="foo")`` matches a slug of ``foo``, … … 59 59 contains Case-sensitive containment test: 60 60 ``polls.get_list(question__contains="spam")`` returns all polls 61 that contain "spam" in the question. 62 icontains Case-insensitive containment test 63 gt Greater than: ``polls.get_list(id__gt=4)`` 64 gte Greater than or equal to 65 lt Less than 66 lte Less than or equal to 61 that contain "spam" in the question. (PostgreSQL only. MySQL 62 doesn't support case-sensitive LIKE statements; ``contains`` 63 will act like ``icontains`` for MySQL.) 64 icontains Case-insensitive containment test. 65 gt Greater than: ``polls.get_list(id__gt=4)``. 66 gte Greater than or equal to. 67 lt Less than. 68 lte Less than or equal to. 67 69 startswith Case-sensitive starts-with: 68 ``polls.get_list(question_startswith="Would")`` 69 endswith Case-sensitive ends-with 70 ``polls.get_list(question_startswith="Would")``. (PostgreSQL 71 only. MySQL doesn't support case-sensitive LIKE statements; 72 ``startswith`` will act like ``istartswith`` for MySQL.) 73 endswith Case-sensitive ends-with. (PostgreSQL only. MySQL doesn't 74 support case-sensitive LIKE statements; ``endswith`` will act 75 like ``iendswith`` for MySQL.) 76 istartswith Case-insensitive starts-with. 77 iendswith Case-insensitive ends-with. 70 78 range Range test: 71 79 ``polls.get_list(pub_date__range=(start_date, end_date))`` … … 309 317 of objects then calling save() on them:: 310 318 311 >>> p = polls.Poll(id=None, 319 >>> p = polls.Poll(id=None, 312 320 ... slug="eggs", 313 321 ... question="How do you like your eggs?", … … 315 323 ... expire_date=some_future_date) 316 324 >>> p.save() 317 325 318 326 Calling ``save()`` on an object with an id if ``None`` signifies to 319 327 Django that the object is new and should be inserted. … … 327 335 >>> p.get_choice_count() 328 336 4 329 337 330 338 Each of those ``add_choice`` methods is equivilent to (except obviously much 331 339 simpler than):: … … 336 344 ... votes=0) 337 345 >>> c.save() 338 346 339 347 Note that when using the `add_foo()`` methods, you do not give any value 340 for the ``id`` field, nor do you give a value for the field that stores 348 for the ``id`` field, nor do you give a value for the field that stores 341 349 the relation (``poll_id`` in this case). 342 350
