Changes between Version 10 and Version 11 of NoSqlSupport


Ignore:
Timestamp:
Apr 27, 2011, 2:22:43 AM (13 years ago)
Author:
Waldemar Kornewald
Comment:

explain AutoField changes

Legend:

Unmodified
Added
Removed
Modified
  • NoSqlSupport

    v10 v11  
    6666= !AutoField =
    6767
    68 In some DB systems the primary key is a string. Currently, `AutoField` assumes that it's always an Integer.
     68In some DB systems the primary key is a string. Currently, `AutoField` assumes that it's always an Integer. There are two ways to support string-based primary keys. Either we can add a `StringAutoField` and require developers to explicitly use that. The disadvantage of this solution is that it becomes impossible to reuse existing Django models and NoSQL models become less portable even across NoSQL databases. The better alternative is to change `AutoField` to support both integers and strings. Since some existing code assumes that an exception is raised when assigning a string to an `AutoField` we could try to detect the installed backends and keep the old behavior (but additionally show a deprecation warning) when only SQL backends are in use. When using a NoSQL backend the new behavior would be activated and `AutoField` would accept both integers and strings without raising an exception.
    6969
    70 Implementing an auto-increment field in SimpleDB would be extremely difficult.  I would say impossible, actually.  The eventual consistency model just doesn't support it.  For the persistence layers I have written on top of SimpleDB, I use a UUID (type 4) as the ID of the object.  --garnaat
     70Portable code should never assume that the "pk" field is a number. If an entity uses a string pk the application should continue to work. This is currently a problem in Django's auth app (see #14881).
    7171
    72 Conclusion: Portable code should never assume that the "pk" field is a number. If an entity uses a string pk the application should continue to work. This is currently a problem in Django's auth app in 1.3 trunk (see #14881).
    73 
    74 This is already implemented in Django-nonrel.
     72This is already implemented in Django-nonrel, but it's missing the deprecation warning and backwards-compatible mode when only using SQL backends.
    7573
    7674= !ListField =
Back to Top