Changes between Version 15 and Version 16 of NonSqlBackends
- Timestamp:
- Aug 13, 2009, 1:59:29 AM (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
NonSqlBackends
v15 v16 6 6 = sql.subqueries = 7 7 8 The query classes defined in this module are used by QuerySet and Model, but it's not possible to override the subquery classes. 9 10 TODO: Is this necessary, at all? Probably yes if you want a clean port so provide functionality to override subquery classes. 8 The query classes defined in this module are used by QuerySet and Model. Their use should be handled by sql.Query, instead, so non-relational backends can override them. 11 9 12 10 = Fields = … … 20 18 == Multi-table inheritance == 21 19 22 In the current implementation, multi-table inheritance requires reads and writes across multiple tables. On non-relational DBs this has to be solved differently. For example, with a ListField type you could store all models which you derived from (inspired by App Engine's PolyModel). On App Engine this adds deeper composite indexes which is a problem when filtering against multiple ListFields combining that with inequality filters or results ordering (exploding indexes). Thus, this should only be used at the second inheritance level (seen from Model base class). 20 In the current implementation, multi-table inheritance requires reads and writes across multiple tables. On non-relational DBs this has to be solved differently. For example, with a ListField type you could store all models which you derived from (inspired by App Engine's PolyModel). E.g., if model B derives from model A you'd store model B in the table for model A and add B's name (app_b) to the ListField. 21 22 On App Engine this adds deeper composite indexes which is a problem when filtering against multiple ListFields combining that with inequality filters or results ordering (exploding indexes). Thus, this should only be used at the second inheritance level (seen from Model base class). 23 23 24 24 Problem: 25 If model B derives from A and you get an A instance and modify it you mustn't lose B's data. Either we always keep all data (which means you never free up data after schema changes unless you use a lower-level API) or we keep track of all derived models' fields and keep themwhile removing all unused fields (e.g., A would know about B's fields and preserve them when saving). Probably the first solution is the safest.25 Model A doesn't know about model B, but since both of them live in the same table an A instance has to know about B's fields, so when A is saved it can preserve B's data (you can't modify only specific fields; you always replace the whole row). Either we always keep all data (which means you never free up data after schema changes unless you use a lower-level API) or we keep track of all derived models' fields and preserve those while removing all unused fields (e.g., A would know about B's fields and preserve them when saving). Probably the first solution is the safest. 26 26 27 TODO: How do we store field data that doesn't have a corresponding field in themodel definition?27 TODO: How do we store field data that doesn't exist in any model definition? 28 28 29 29 == save_base() == … … 33 33 == delete() == 34 34 35 model.delete() collects all re ferenced objects using _collect_sub_objects(). For non-sql backends this is not always possible, for example, when running in a transaction on App Engine (only entities in the same entity group can be fetched from the datastore). This means that we can't guarantee referential integrity and we can't efficiently emulate SQL in this case.35 model.delete() collects all related objects using _collect_sub_objects(). For non-sql backends this is not always possible, for example, when running in a transaction on App Engine (only entities in the same entity group can be fetched from the datastore). This means that we can't guarantee referential integrity and we can't efficiently emulate SQL in this case. 36 36 37 37 = Transactions =