So I'm working a bit on this.....
> If base64 encoding within the bind_processor() can fix
> MS-SQL for now, I'd say that would be the approach for the time
> being.
turns out base64 encoding is problematic: it requires a corresponding decode
for the data retrieval, which makes it effectively useless for legacy
databases with extant values stored.
I think an out-only encoding as follows would be all that's needed for now:
class MSBinary(sqltypes.Binary):
def bind_processor(self, dialect):
def process(value):
return '0x' + value.encode('hex')
return process
...the issue is that the emitted value is getting quoted somewhere after the
type conversion:
INSERT INTO binary_table VALUES(...., '0x6df02da', ...)
but MSSQL's parser can recognize the '0x' prefix and wants the value
unquoted:
INSERT INTO binary_table VALUES(...., 0x6df02da, ...)
So how do I get the Dialect to drop the quoting behavior for the return from
bind_processor() ?
> I guess you've never gotten testtypes.py BinaryTest to run with MS-SQL?
Nope. I run so far only with pymssql, which has never had a chance of
passing with binary data.
> I would definitely want some test coverage in test/dialect/mssql.py for
this, I'm pretty shocked nobody has had this problem before.
If this works, the regular BinaryTest unit test should pass. There's a few
other basic tests in typetest.py that still fail for MSSQL. Someday in a
dream world where I have time to look at them and fix them, I will.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---