[SQL-CVS] r713 - in trunk/SQLObject/sqlobject: . mysql
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: <sub...@co...> - 2005-04-05 13:05:57
|
Author: phd Date: 2005-04-05 13:05:51 +0000 (Tue, 05 Apr 2005) New Revision: 713 Modified: trunk/SQLObject/sqlobject/col.py trunk/SQLObject/sqlobject/mysql/mysqlconnection.py Log: BINARY columns in MySQL are too binary - they ignore locale order and are sorted in their binary order. Because of that I have changed the entire concept of case_sensitive attribute: it is renamed to char_binary, the default is None, and it is still only meaninful for MySQL. Modified: trunk/SQLObject/sqlobject/col.py =================================================================== --- trunk/SQLObject/sqlobject/col.py 2005-04-04 20:50:38 UTC (rev 712) +++ trunk/SQLObject/sqlobject/col.py 2005-04-05 13:05:51 UTC (rev 713) @@ -352,7 +352,7 @@ def __init__(self, **kw): self.length = popKey(kw, 'length') self.varchar = popKey(kw, 'varchar', 'auto') - self.case_sensitive = popKey(kw, 'case_sensitive', True) + self.char_binary = popKey(kw, 'char_binary', None) # A hack for MySQL if not self.length: assert self.varchar == 'auto' or not self.varchar, \ "Without a length strings are treated as TEXT, not varchar" @@ -379,12 +379,12 @@ return 'CHAR(%i)' % self.length def _check_case_sensitive(self, db): - if not self.case_sensitive: - raise ValueError, "%s does not support case-insensitive columns" % db + if self.char_binary: + raise ValueError, "%s does not support binary character columns" % db def _mysqlType(self): type = self._sqlType() - if self.case_sensitive: + if self.char_binary: type += " BINARY" return type Modified: trunk/SQLObject/sqlobject/mysql/mysqlconnection.py =================================================================== --- trunk/SQLObject/sqlobject/mysql/mysqlconnection.py 2005-04-04 20:50:38 UTC (rev 712) +++ trunk/SQLObject/sqlobject/mysql/mysqlconnection.py 2005-04-05 13:05:51 UTC (rev 713) @@ -141,18 +141,18 @@ return col.IntCol, {} elif t.startswith('varchar'): if t.endswith('binary'): - return col.StringCol, {'length': int(t[8:-8])} + return col.StringCol, {'length': int(t[8:-8]), + 'char_binary': True} else: - return col.StringCol, {'length': int(t[8:-1]), - 'case_sensitive': False} + return col.StringCol, {'length': int(t[8:-1])} elif t.startswith('char'): if t.endswith('binary'): return col.StringCol, {'length': int(t[5:-8]), - 'varchar': False} + 'varchar': False, + 'char_binary': True} else: return col.StringCol, {'length': int(t[5:-1]), - 'varchar': False, - 'case_sensitive': False} + 'varchar': False} elif t.startswith('datetime'): return col.DateTimeCol, {} elif t.startswith('bool'): |