Ticket #28 (assigned enhancement)

Opened 1 year ago

Last modified 8 months ago

ORM Improvements

Reported by: pragma Assigned to: pragma (accepted)
Priority: minor Milestone: Version 2.0
Component: component1 Version:
Keywords: Cc:

Description (Last modified by pragma)

The ORM should be enhanced to make for easier maintenance and debugging.

Implementation details for refactoring the existing ORM:

  • ORMColumn to SQL generation and event hooks is sloppy as hell. This needs to be refactored to place these bits in the Column classes
  • Column names in the generated SQL need to be translatable to their respective model within a join, such that they can be individually referenced from where={}. Example: {'model.colname'='foobar'} can translate to "where model_colname = %(foobar)s"
  • SQL generation can be further refined by the use of "prepared statements", since SQL generation currently happens at request time.
  • The Formatter class needs to be factored away to a more generic interface, supported by the formatter methods that currently reside in model.py
  • Look into object caching to accelerate ORMRelation and load() behavior (if needed)

Change History

07/03/07 16:21:49 changed by pragma

  • owner changed from somebody to pragma.
  • status changed from new to assigned.

08/07/07 16:02:49 changed by pragma

Mostly complete. The ORM itself still has a few quirks:

  • Large Model-maps cause pages to stall a tad when crammed into an HDF. Given that the stall happens after my print trap, after the formatting pass, I'm inclined to think that this is an HDF issue.
  • Large Model-joins can create SQL code with impossible to reference columns. TopicModelWithRecentPost? is an example - querying on "topicid" yields an "ambiguous column reference" error, straight from Postgres.
  • Validation is not explicitly tied into the ORMReference and ORMJoin column types. This may remain open as I'm not 100% confident that changing this is a preferred behavior.

There are quite a few refactoring targets that should be investigated on the Genshi integration pass, if they're not handled sooner:

  • ORMColumn to SQL generation and event hooks is sloppy as hell. This needs to be refactored to place these bits in the Column classes
  • SQL generation can be further refined to use compile-on-demand rather than a massive precomp of all columns that exist under a given model
  • The Formatter class needs to be factored away to a more generic interface, supported by the formatter methods that currently reside in model.py
  • model.py needs to go away
  • Look into object caching to accelerate ORMRelation and load() behavior (if needed)

03/31/08 10:49:03 changed by pragma

  • priority changed from critical to minor.
  • milestone changed from Beta 1.0 to Version 2.0.

It looks like most of these things aren't critical blockers, but rather nice-to-haves. They'll likely stay as stand-out items for some time until either the ORM is overhauled to incorporate these items, or is replaced by a more robust system.

Pushed back to 2.0 and reduced in priority

04/10/08 15:01:18 changed by pragma

  • description changed.
  • summary changed from ORM to ORM Improvements.

Added implementation details to task.