Changes between Initial Version and Version 1 of Ticket #17653, comment 11


Ignore:
Timestamp:
Feb 13, 2012, 2:55:46 PM (13 years ago)
Author:
Christopher Medrela

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17653, comment 11

    initial v1  
    11Sorry for delay, but the ticket is not as easy as I thought.
    22
    3 I attached a patch similar to akaariai's patch. It validates value for primary key in new method `BaseDatabaseOperations.check_autopk_value` in module `db.backends`. The method is overriden in `DatabaseOperations` in module `db.backends.mysql`, so it does not use `allows_primary_key_0` flag. The method is called by `AutoField.get_db_prep_value` from module `db.models.fields`. The patch includes simple test.
     3I attached a patch similar to akaariai's patch. It validates value for primary key in new method `BaseDatabaseOperations.validate_autopk_value` in module `db.backends`. The method is overriden in `DatabaseOperations` in module `db.backends.mysql`, so it does not use `allows_primary_key_0` flag. The method is called by `AutoField.get_db_prep_value` from module `db.models.fields`. The patch includes simple test.
    44
    5 I'm not sure if `get_db_prep_save` is right place for validation. The doc of the method says:
     5I'm not sure if `get_db_prep_value` is right place for validation. The doc of the method says:
    66{{{
    77        Returns field's value prepared for interacting with the database
     
    1111        `get_db_prep_lookup```
    1212}}}
    13 so maybe we should add note that `get_db_prep_save` do validation and may raise error?
     13so maybe we should add note that `get_db_prep_prep` do validation and may raise error?
    1414
    1515Note that both patches (mine and akaariai's) works for `AutoField` as well as for `ForeignKey` and `ManyToManyField`, because related fields calls `AutoField.get_db_prep_value` during executing their `get_db_prep_value` method (see https://code.djangoproject.com/browser/django/trunk/django/db/models/fields/related.py#L962).
Back to Top