>>>       ProgrammingError: (1064, "You have an error in your SQL syntax; 
>> check the manual that corresponds to your MySQL server version for the 
>> right syntax to use near 'NULL)\n)' at line 3")
> 
>    Ha! MySQL! MySQL doesn't allow NULLs in EnumCol. There is a patch in the
> SF tracker:
> http://sourceforge.net/tracker/index.php?func=detail&aid=1496014&group_id=74338&atid=540672
> and it would be helpful if you review and comment it.

Works fine. Here are some additional tests to make sure its handling of 
defaults etc. is correct.

Index: tests/test_enum.py
===================================================================
--- tests/test_enum.py  (revision 1953)
+++ tests/test_enum.py  (working copy)
@@ -19,7 +19,12 @@
           Enum1._connection.module.ProgrammingError,
           Invalid),
          Enum1, l='b')
-
+    raises(
+        (Enum1._connection.module.IntegrityError,
+         Enum1._connection.module.ProgrammingError,
+         Invalid),
+        Enum1, l=None)
+
  class EnumWithNone(SQLObject):

      l = EnumCol(enumValues=['a', 'bcd', 'e', None])
@@ -27,5 +32,29 @@
  def testNone():
      setupClass(EnumWithNone)
      for l in [None, 'a', 'bcd', 'a', 'e', None]:
-        EnumWithNone(l=l)
-
+        e = EnumWithNone(l=l)
+        assert e.l == l
+
+class EnumWithDefaultNone(SQLObject):
+
+    l = EnumCol(enumValues=['a', 'bcd', 'e', None], default=None)
+
+def testDefaultNone():
+    setupClass(EnumWithDefaultNone)
+
+    e = EnumWithDefaultNone()
+    assert e.l == None
+
+class EnumWithDefaultOther(SQLObject):
+
+    l = EnumCol(enumValues=['a', 'bcd', 'e', None], default='a')
+
+def testDefaultOther():
+    setupClass(EnumWithDefaultOther)
+
+    e = EnumWithDefaultOther()
+    assert e.l == 'a'
+
+



> 
>> [/.../SQLObject/sqlobject/tests/test_blob.py:18]
>>
>> E                   myquery = unicode(query, self.encoding)
>>>                   UnicodeDecodeError: 'ascii' codec can't decode byte 
>> 0x80 in position 167: ordinal not in range(128)
> 
>    MySQLdb 1.2.1+? You have to specify an encodings in DB URI:

Yes.

> mysql://host/db?debug=1&charset=utf-8&sqlobject_encoding=utf-8
> 
>    for example. "charset" is for DB encoding, sqlobject_encoding is for
> client encoding.

Actually, need to use "charset=utf8&sqlobject_encoding=utf8"

but still get an error:

     def decode(input, errors='strict'):
E       return codecs.utf_8_decode(input, errors, True)
 >       UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in 
position 167: unexpected code byte

Cheers!

nathan


-- 
Nathan Edwards, Ph.D.
Center for Bioinformatics and Computational Biology
3119 Biomolecular Sciences Bldg. #296
University of Maryland, College Park, MD 20742
Phone: +1 301-405-9901
Email: [EMAIL PROTECTED]
WWWeb: http://www.umiacs.umd.edu/~nedwards

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to