Hello,
I'm using a custom type (TypeDecorator) to handle encrypting data on
write and decrypting data on read. Everything works fine for inserting
and reading from the database with one exception. Using the like
operator with '%' syntax is not returning any results.
For the purposes of this post, lets suppose the data manipulation is
simple base 64 encoding:
#code block:
class EncryptedString(TypeDecorator):
impl = String
def process_bind_param(self, value, dialect):
if not value:
return value
return base64.b64encode(value)
def process_result_value(self, value, dialect):
if not value:
return value
decrypted_sub_string = base64.b64decode(value)
#and a simple model:
Base = declarative.declarative_base()
class MyTable(Base):
__tablename__ = "mytable"
name = EncryptedString(128)
#and the query that does not work:
Session().query(MyTable).filter(MyTable.name.like('%foo%')
#end code block
Let's say there's a row in the table with name = 'foobar' (actually
its whatever 'foobar' encodes to) the above query will return nothing.
If I query for .like('foobar') then I will get the row returned as
expected.
Lastly, I'm on v0.5.1 (way behind I know!).
Any thoughts? Thanks so much,
Stephen
--
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.