I'm trying to use types.TypeDecorator to define a set of strings
stored in the database as a csv list, where the empty set is stored as
null. process_bind_param seems to work, as values set on the bound
field seem to get entered correctly; but process_result_value never
seems to be called when reading that field, or when loading an
instance from the database.

What am I doing wrong? (I'm using 0.4.2p3)

class StringSet (types.TypeDecorator):

    """A type that receives an iterable of strings, and returns a set
of those strings.

    Stored in the database as a csv list of strings.
    """

    impl = types.String

    def process_bind_param (self, value, engine):
        if not value:
            return None
        else:
            return ",".join(set(value))

    def process_result_value (self, value, engine):
        if not value:
            return set()
        else:
            return set(value.split(","))

    def copy (self):
        return StringSet(self.impl.length)



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to