Closed VFLashM closed 7 years ago
Okay, I'm apparently using very old version of pytds.
Looking at current source code corresponding changes would be:
bytes_to_unicode
to varchar serializers (it can be extracted from reader/writer._session._login
, but that's ugly)bytes_to_unicode
is truebytes_to_unicode
is trueThese changes will affect VarChar70Serializer
, VarChar72Serializer
and Text70Serializer
.
Does this change make sense to you?
Do you want it in your code?
As I mentioned before, I have severe administrative problems running your test suite.
On top of that I'm not quite sure how to pass bytes_to_unicode
to serializers properly.
I still can try to implement it, though.
Sounds reasonable to me. Is there anything I can help with running test suite?
I'll try to make it work sometime next week.
What would be the best way to access bytes_to_unicode
from serializers?
As of now I just get it through reader/writer->connection->login, it doesn't look very nice.
Should I pass it through constructor (and all factories)?
Maybe we need some kind of a Context object which would contain things like that, but that would probably be too much of a refactoring, so I am ok with using reader/writer->connection->login for now, I think this is how other serializers do that currently anyway.
Legacy part of my project pipes raw bytes into sql varchars. My code is written in python2 and I need to ensure interoperability with that code.
pytds has
bytes_to_unicode
option, but setting it to false does not work as expected.Example:
With
bytes_to_unicode=True
(default) I get following result:Setting
bytes_to_unicode=False
fails with exception:Current implementation of
bytes_to_unicode
seems to be rather useless. I'd say it should not try to encode input and should pass it as it is to the database. I propose one simple change to achieve that: Intds.py
, in methodVarCharMax.write
Result after the change:
Still not perfect (I'd prefer it to return non-unicode string), but at least it works.
I'm not sure if this change affects anything else (I'm having troubles running test suite). Please let me know what you think.
I'm having troubles running test suite, but still can make a pull request if necessary.