Edgewall Software

Changes between Version 7 and Version 8 of TracDev/ScratchPad/DataModels


Ignore:
Timestamp:
Aug 11, 2018, 1:49:06 PM (14 months ago)
Author:
figaro
Comment:

Cosmetic changes

Legend:

Unmodified
Added
Removed
Modified
  • TracDev/ScratchPad/DataModels

    v7 v8  
    1 = Improvements to our data models
     1= Improvements to Trac's data models
    22
    3 Usually implemented in the `<subsystem>/model.py` files.
     3Trac's datamodels are usually implemented in the `<subsystem>/model.py` files.
    44
    5 In the current situation (1.0.x/1.1.1), we have different APIs and different conventions for the different models. We should try to be more consistent.
     5In the current situation (1.0.x/1.1.1), we have different APIs and different conventions for the datamodels. This page describes a few issues where the API and conventions can be improved and made more consistent.
    66
    77== Representation of data
     
    1010
    1111For tickets, when a field is unset the database value is set to `None` / `NULL` (#11018). When retrieving `NULL` values from the database, we get `None` in Python, and the value returned from the model depends on the field type:
    12 * For text fields, the empty string is returned from the model using the special value [apidoc:api/trac_util_text#trac.util.text.empty empty]. See e.g. what we do for  [source:trunk/trac/ticket/model.py@11111:127,137#L110 ticket fields].
     12* For text fields, the empty string is returned from the model using the special value [apidoc:api/trac_util_text#trac.util.text.empty empty]. See for example what we do for  [source:trunk/trac/ticket/model.py@11111:127,137#L110 ticket fields].
    1313* For time fields, `None` is returned.
    1414
     
    1717=== `NOT NULL` columns
    1818
    19 Validation of the ticket summary is done in the [browser:tags/trac-1.0.12/trac/ticket/web_ui.py@:1247-1250#L1246 IRequestHandler], to prevent creating a ticket with an empty summary. The schema could be changed to use `NOT NULL` in the column specification since the empty string is [browser:tags/trac-1.0.12/trac/ticket/model.py#L372 replaced with NULL]. Alternatively, a `TracError` could be raised in the `Ticket` model when `insert`ing or `update`ing a ticket with an empty summary (#12458).
     19Validation of the ticket summary is done in the [browser:tags/trac-1.0.12/trac/ticket/web_ui.py@:1247-1250#L1246 IRequestHandler], to prevent creating a ticket with an empty summary. The schema could be changed to use `NOT NULL` in the column specification, since the empty string is [browser:tags/trac-1.0.12/trac/ticket/model.py#L372 replaced with NULL]. Alternatively, a `TracError` could be raised in the `Ticket` model when `insert`ing or `update`ing a ticket with an empty summary (#12458).
    2020
    2121=== Class methods
    2222
    23 Class methods, one example being `select`, are used for table-wide queries.
     23Class methods are used for table-wide queries. One such example is `select`.
    2424
    2525The signature of the `select` method is not consistent across all classes.