Opened 17 years ago
Closed 14 years ago
#5421 closed (fixed)
Add "db_select" hooks for database Fields
Reported by: | Adrian Holovaty | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | feature_request | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.)
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
Change History (3)
comment:1 by , 17 years ago
Component: | Uncategorized → Database wrapper |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 17 years ago
Keywords: | feature_request added |
---|
comment:3 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
There are other internals for doing this now.