]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- sql
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 1 Apr 2012 23:42:54 +0000 (19:42 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 1 Apr 2012 23:42:54 +0000 (19:42 -0400)
  - [bug] Removed warning when Index is created
    with no columns; while this might not be what
    the user intended, it is a valid use case
    as an Index could be a placeholder for just an
    index of a certain name.

- mssql
  - [feature] Added interim create_engine flag
    supports_unicode_binds to PyODBC dialect,
    to force whether or not the dialect
    passes Python unicode literals to PyODBC
    or not.

CHANGES
lib/sqlalchemy/connectors/pyodbc.py
lib/sqlalchemy/dialects/mssql/pyodbc.py
lib/sqlalchemy/schema.py
test/bootstrap/config.py
test/sql/test_constraints.py

diff --git a/CHANGES b/CHANGES
index 727e7235f3d6899c3db8767046f8af852baa0cf3..88ddad8f8f38c33493ff6d375b96e663d1f9e004 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -28,6 +28,20 @@ CHANGES
     OrderingList from being pickleable
     [ticket:2454].  Courtesy Jeff Dairiki
 
+- sql
+  - [bug] Removed warning when Index is created
+    with no columns; while this might not be what 
+    the user intended, it is a valid use case 
+    as an Index could be a placeholder for just an 
+    index of a certain name.
+
+- mssql
+  - [feature] Added interim create_engine flag
+    supports_unicode_binds to PyODBC dialect,
+    to force whether or not the dialect
+    passes Python unicode literals to PyODBC 
+    or not.
+
 - postgresql
   - [feature] Added new for_update/with_lockmode()
     options for Postgresql: for_update="read"/
index 439b8f4feffbb44d3e09e053a0b7567b89e4adea..a684a2dcb6433ca822b9d059cd361096606cdf90 100644 (file)
@@ -37,6 +37,10 @@ class PyODBCConnector(Connector):
     # if the libessqlsrv.so is detected
     easysoft = False
 
+    def __init__(self, supports_unicode_binds=None, **kw):
+        super(PyODBCConnector, self).__init__(**kw)
+        self._user_supports_unicode_binds = supports_unicode_binds
+
     @classmethod
     def dbapi(cls):
         return __import__('pyodbc')
@@ -119,8 +123,12 @@ class PyODBCConnector(Connector):
         # have not tried pyodbc + python3.1 yet.
         # Py2K
         self.supports_unicode_statements = not self.freetds and not self.easysoft
-        self.supports_unicode_binds =  (not self.freetds or 
-                                            self.freetds_driver_version >= '0.91') and not self.easysoft
+        if self._user_supports_unicode_binds is not None:
+            self.supports_unicode_binds = self._user_supports_unicode_binds
+        else:
+            self.supports_unicode_binds = (not self.freetds or 
+                                            self.freetds_driver_version >= '0.91'
+                                            ) and not self.easysoft
         # end Py2K
 
         # run other initialization which asks for user name, etc.
index 7b47004ea82480c7df296f2f40a1fac4d9ab437b..434cfd43c80b4efdcce5cb1900732d6c18da0aea 100644 (file)
@@ -80,6 +80,31 @@ the python shell. For example::
     >>> urllib.quote_plus('dsn=mydsn;Database=db')
     'dsn%3Dmydsn%3BDatabase%3Ddb'
 
+Unicode Binds
+^^^^^^^^^^^^^
+
+The current state of PyODBC on a unix backend with FreeTDS and/or 
+EasySoft is poor regarding unicode; different OS platforms and versions of UnixODBC
+versus IODBC versus FreeTDS/EasySoft versus PyODBC itself dramatically 
+alter how strings are received.  The PyODBC dialect attempts to use all the information
+it knows to determine whether or not a Python unicode literal can be
+passed directly to the PyODBC driver or not; while SQLAlchemy can encode
+these to bytestrings first, some users have reported that PyODBC mis-handles
+bytestrings for certain encodings and requires a Python unicode object,
+while the author has observed widespread cases where a Python unicode
+is completely misinterpreted by PyODBC, particularly when dealing with
+the information schema tables used in table reflection, and the value 
+must first be encoded to a bytestring.
+
+It is for this reason that whether or not unicode literals for bound
+parameters be sent to PyODBC can be controlled using the 
+``supports_unicode_binds`` parameter to ``create_engine()``.  When 
+left at its default of ``None``, the PyODBC dialect will use its 
+best guess as to whether or not the driver deals with unicode literals
+well.  When ``False``, unicode literals will be encoded first, and when
+``True`` unicode literals will be passed straight through.  This is an interim
+flag that hopefully should not be needed when the unicode situation stabilizes
+for unix + PyODBC.  New in 0.7.7.
 
 """
 
index d29514377d61c9e8f6816f5674bb53b269b26267..9746af22872737efbbd8d37a94f67795026b3a67 100644 (file)
@@ -2208,8 +2208,6 @@ class Index(ColumnCollectionMixin, SchemaItem):
         self.table = None
         # will call _set_parent() if table-bound column
         # objects are present
-        if not columns:
-            util.warn("No column names or expressions given for Index.")
         ColumnCollectionMixin.__init__(self, *columns)
         self.name = name
         self.unique = kw.pop('unique', False)
index edf94fae5ff566a5949aee7392a640f4a9624e35..86dc78bcc4596f41531044bd4425b45641fd5551 100644 (file)
@@ -53,6 +53,7 @@ def _list_dbs(*args):
 def _server_side_cursors(options, opt_str, value, parser):
     db_opts['server_side_cursors'] = True
 
+
 def _zero_timeout(options, opt_str, value, parser):
     warnings.warn("--zero-timeout testing option is now on in all cases")
 
index 246878624732793179f22827bc7e14b2f3276078..5ea5a7edaac8ecd5af58f88a476ee950cf536d2f 100644 (file)
@@ -271,12 +271,8 @@ class ConstraintTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiled
             Index, "foo", 5
         )
 
-    def test_warn_no_columns(self):
-        assert_raises_message(
-            exc.SAWarning,
-            "No column names or expressions given for Index.",
-            Index, "foo"
-        )
+    def test_no_warning_w_no_columns(self):
+        Index(name="foo")
 
     def test_raise_clauseelement_not_a_column(self):
         m = MetaData()