#5421: Add "db_select" hooks for database Fields
-----------------------+----------------------------------------------------
Reporter: adrian | Owner: nobody
Status: new | Component: Uncategorized
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
-----------------------+----------------------------------------------------
I'm proposing a "db_select" method on the database {{{Field}}} class. This
would specify the raw SQL to use when listing the field in the
{{{SELECT}}} clause of an SQL statement. This will allow for more useful
SELECTs in the case of opaque data types such as PostGIS "geometry"
fields, which are returned by default as an encoded series of bytes.
It could also allow certain fields, such as BLOBs, to *never* be returned
in a SELECT statement. (I'm 50/50 on this particular idea.)
{{{
#!python
class Field:
def db_select(self, table):
# Default behavior is to select the column name.
return '%s.%s' % (table, self.db_column)
class GeometryField(Field):
def db_select(self, table):
# For a PostGIS geometry field, select the textual version of the
geometry.
return 'AsText(%s.%s)' % (table, self.db_column)
class BlobField(Field):
def db_select(self, table):
# None means "Don't ever include this field in a SELECT list."
return None
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/5421>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---