Michael Bayer wrote:
> the question is, do you ever want that whitespace in the application  
> space ?  you might want to just create a custom String subclass that  
> converts the whitespace in and out at the Table level.  that would be  
> cleaner.

That's really the best way to do it.

I probably should have read the documentation more carefully, it's
actually all in there. Kudos again for all of this.

Is this the correct implementation?

import sqlalchemy.types as types

class Name(types.TypeDecorator):
    """Right trimmed, lowercased Strings."""
    impl = types.String
    def convert_bind_param(self, value, engine):
        return value.rstrip(' ').lower()
    def convert_result_value(self, value, engine):
        return value.rstrip(' ').lower()

user = Table('user', metadata,
    Column('name', Name, primary_key=True),
    Column('pwd', Name, primary_key=True),
)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sqlalchemy
-~----------~----~----~----~------~----~------~--~---

Reply via email to