I'm setting up my first project that will use SA exclusively for
database access and I've run into some behavior that seems odd to me.

If I insert u"" into a column that is defined as nvarchar then when I
select that column, I receive u" ". So I'm receiving a unicode string
containing one space where I would expect to find an empty unicode
string. Does this ring any bells for anyone?

I'm using:
SQLAlchemy 0.5.0beta3
pyodbc 2.0.58
FreeTDS 0.82

Here's a test case:

import
unittest
import
pyodbc
import sqlalchemy as
sa

class
TestMSSQLConnections(unittest.TestCase):

    def
setUp(self):

        self.host
=
        self.port
=
        self.host_and_port = "%s:%s" % (self.host,
self.port)
        self.database
=
        self.user
=
        self.password
=

        engine_url = "mssql://%s:[EMAIL PROTECTED]/%s" %
\
                     (self.user,
self.password,
                      self.host_and_port,
self.database)
        self.sa_engine =
sa.create_engine(engine_url)
        self.unicode_test_table = sa.Table("unicode_test_table",
sa.MetaData(),
 
sa.Column("unicode_test_column",
 
sa.Unicode(60)))

 
self.unicode_test_table.drop(bind=self.sa_engine)
 
self.unicode_test_table.create(bind=self.sa_engine)

    def
test_sqlalchemy_over_pyodbc(self):
        assert
isinstance(self.sa_engine.dialect,
                          sa.databases.mssql.MSSQLDialect_pyodbc),
\
 
self.sa_engine.dialect

 
self.sa_engine.execute(self.unicode_test_table.insert(),
 
unicode_test_column=u"")
        rows =
list(self.sa_engine.execute(self.unicode_test_table.select()))
        assert u"" == rows[0].unicode_test_column,
\
 
repr(rows[0].unicode_test_column)

unittest.main()
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to