Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 257

Show
Ignore:
Timestamp:
12/01/08 05:44:57
Author:
fumanchu
Message:

Some slightly-hackish fixes to get MySQL tests almost working (still some unicode issues).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/geniusql/providers/mysql.py

    r256 r257  
    6767         
    6868        if ignore_case: 
    69             return ("CONVERT(" + op1.sql + ") USING utf8 LIKE '" + 
     69            return ("CONVERT(" + op1.sql + " USING utf8) LIKE '" + 
    7070                    start + likeexpr.lower() + end + "'") 
    7171        else: 
     
    9191    pass 
    9292 
    93 class MySQL_CHAR_Adapter(MySQL_String_Mixin, adapters.str_to_SQL92CHAR): 
     93class MySQL_CHAR_Adapter(MySQL_String_Mixin, adapters.str_to_SQL92VARCHAR): 
    9494    pass 
    9595 
     
    261261    default_adapters[str] = MySQL_CHAR_Adapter() 
    262262    default_adapters[unicode] = MySQL_CHAR_Adapter() 
     263     
     264    def ddl(self): 
     265        """Return the type for use in CREATE or ALTER statements.""" 
     266        return "CHAR(%s)" % self.bytes 
     267 
     268class CHAR411(CHAR): 
     269    synonyms = ['CHAR'] 
     270    default_adapters = CHAR.default_adapters.copy() 
     271    default_adapters[str] = MySQL_CHAR_Adapter411() 
     272    default_adapters[unicode] = MySQL_CHAR_Adapter411() 
     273 
    263274 
    264275class VARCHAR(dbtypes.SQL92VARCHAR): 
     
    269280    default_adapters[str] = MySQL_VARCHAR_Adapter() 
    270281    default_adapters[unicode] = MySQL_VARCHAR_Adapter() 
    271  
    272 class VARCHAR503(VARCHAR): 
     282     
     283    def ddl(self): 
     284        """Return the type for use in CREATE or ALTER statements.""" 
     285        return "VARCHAR(%s)" % self.bytes 
     286 
     287class VARCHAR411(VARCHAR): 
     288    synonyms = ['VARCHAR'] 
     289    default_adapters = VARCHAR.default_adapters.copy() 
     290    default_adapters[str] = MySQL_VARCHAR_Adapter411() 
     291    default_adapters[unicode] = MySQL_VARCHAR_Adapter411() 
     292 
     293class VARCHAR503(VARCHAR411): 
    273294    # "The maximum effective length of a VARCHAR in MySQL 5.0.3 and 
    274295    # later is determined by the maximum row size and the character 
     
    277298    max_bytes = 65535 
    278299    synonyms = ['VARCHAR'] 
    279      
    280     def ddl(self): 
    281         """Return the type for use in CREATE or ALTER statements.""" 
    282         return "VARCHAR(%s)" % self.bytes 
    283300 
    284301 
     
    289306    default_adapters[str] = MySQL_VARCHAR_Adapter() 
    290307    default_adapters[unicode] = MySQL_VARCHAR_Adapter() 
     308     
     309    def ddl(self): 
     310        """Return the type for use in CREATE or ALTER statements.""" 
     311        return "BINARY(%s)" % self.bytes 
     312 
     313class BINARY411(BINARY): 
     314    synonyms = ['BINARY'] 
     315    default_adapters = BINARY.default_adapters.copy() 
     316    default_adapters[str] = MySQL_VARCHAR_Adapter411() 
     317    default_adapters[unicode] = MySQL_VARCHAR_Adapter411() 
     318 
    291319 
    292320class VARBINARY(dbtypes.SQL92VARCHAR): 
     
    294322    bytes = 255 
    295323    max_bytes = 255 
    296  
    297 class VARBINARY503(VARBINARY): 
     324     
     325    def ddl(self): 
     326        """Return the type for use in CREATE or ALTER statements.""" 
     327        return "VARBINARY(%s)" % self.bytes 
     328 
     329class VARBINARY411(VARBINARY): 
     330    synonyms = ['VARBINARY'] 
     331    default_adapters = VARBINARY.default_adapters.copy() 
     332    default_adapters[str] = MySQL_VARCHAR_Adapter411() 
     333    default_adapters[unicode] = MySQL_VARCHAR_Adapter411() 
     334 
     335class VARBINARY503(VARBINARY411): 
    298336    # "The maximum effective length of a VARCHAR in MySQL 5.0.3 and 
    299337    # later is determined by the maximum row size and the character 
     
    302340    max_bytes = 65535 
    303341    synonyms = ['VARBINARY'] 
    304      
    305     def ddl(self): 
    306         """Return the type for use in CREATE or ALTER statements.""" 
    307         return "VARBINARY(%s)" % self.bytes 
     342 
    308343 
    309344class MySQL_TEXT(dbtypes.TEXT): 
     
    312347    default_adapters[unicode] = MySQL_VARCHAR_Adapter() 
    313348 
     349class MySQL_TEXT411(MySQL_TEXT): 
     350    default_adapters = MySQL_TEXT.default_adapters.copy() 
     351    default_adapters[str] = MySQL_VARCHAR_Adapter411() 
     352    default_adapters[unicode] = MySQL_VARCHAR_Adapter411() 
     353 
    314354class TINYBLOB(MySQL_TEXT): 
    315355    bytes = max_bytes = (2 ** 8) - 1 
     356     
     357    def ddl(self): 
     358        """Return the type for use in CREATE or ALTER statements.""" 
     359        return "TINYBLOB" 
     360class TINYBLOB411(MySQL_TEXT411): 
     361    bytes = max_bytes = (2 ** 8) - 1 
     362    synonyms = ['TINYBLOB'] 
     363     
     364    def ddl(self): 
     365        """Return the type for use in CREATE or ALTER statements.""" 
     366        return "TINYBLOB" 
    316367 
    317368class BLOB(MySQL_TEXT): 
    318369    bytes = max_bytes = (2 ** 16) - 1 
     370     
     371    def ddl(self): 
     372        """Return the type for use in CREATE or ALTER statements.""" 
     373        return "BLOB" 
     374class BLOB411(MySQL_TEXT411): 
     375    bytes = max_bytes = (2 ** 16) - 1 
     376    synonyms = ['BLOB'] 
     377     
     378    def ddl(self): 
     379        """Return the type for use in CREATE or ALTER statements.""" 
     380        return "BLOB" 
    319381 
    320382class MEDIUMBLOB(MySQL_TEXT): 
    321383    bytes = max_bytes = (2 ** 24) - 1 
     384     
     385    def ddl(self): 
     386        """Return the type for use in CREATE or ALTER statements.""" 
     387        return "MEDIUMBLOB" 
     388class MEDIUMBLOB411(MySQL_TEXT411): 
     389    bytes = max_bytes = (2 ** 24) - 1 
     390    synonyms = ['MEDIUMBLOB'] 
     391     
     392    def ddl(self): 
     393        """Return the type for use in CREATE or ALTER statements.""" 
     394        return "MEDIUMBLOB" 
    322395 
    323396class LONGBLOB(MySQL_TEXT): 
    324397    bytes = max_bytes = (2 ** 32) - 1 
     398     
     399    def ddl(self): 
     400        """Return the type for use in CREATE or ALTER statements.""" 
     401        return "LONGBLOB" 
     402class LONGBLOB411(MySQL_TEXT411): 
     403    bytes = max_bytes = (2 ** 32) - 1 
     404    synonyms = ['LONGBLOB'] 
     405     
     406    def ddl(self): 
     407        """Return the type for use in CREATE or ALTER statements.""" 
     408        return "LONGBLOB" 
    325409 
    326410 
    327411class TINYTEXT(MySQL_TEXT): 
    328412    bytes = max_bytes = (2 ** 8) - 1 
     413     
     414    def ddl(self): 
     415        """Return the type for use in CREATE or ALTER statements.""" 
     416        return "TINYTEXT" 
     417class TINYTEXT411(MySQL_TEXT411): 
     418    bytes = max_bytes = (2 ** 8) - 1 
     419    synonyms = ['TINYTEXT'] 
     420     
     421    def ddl(self): 
     422        """Return the type for use in CREATE or ALTER statements.""" 
     423        return "TINYTEXT" 
    329424 
    330425class TEXT(MySQL_TEXT): 
    331426    bytes = max_bytes = (2 ** 16) - 1 
     427     
     428    def ddl(self): 
     429        """Return the type for use in CREATE or ALTER statements.""" 
     430        return "TEXT" 
     431class TEXT411(MySQL_TEXT411): 
     432    bytes = max_bytes = (2 ** 16) - 1 
     433    synonyms = ['TEXT'] 
     434     
     435    def ddl(self): 
     436        """Return the type for use in CREATE or ALTER statements.""" 
     437        return "TEXT" 
    332438 
    333439class MEDIUMTEXT(MySQL_TEXT): 
    334440    bytes = max_bytes = (2 ** 24) - 1 
     441     
     442    def ddl(self): 
     443        """Return the type for use in CREATE or ALTER statements.""" 
     444        return "MEDIUMTEXT" 
     445class MEDIUMTEXT411(MySQL_TEXT411): 
     446    bytes = max_bytes = (2 ** 24) - 1 
     447    synonyms = ['MEDIUMTEXT'] 
     448     
     449    def ddl(self): 
     450        """Return the type for use in CREATE or ALTER statements.""" 
     451        return "MEDIUMTEXT" 
    335452 
    336453class LONGTEXT(MySQL_TEXT): 
    337454    bytes = max_bytes = (2 ** 32) - 1 
     455     
     456    def ddl(self): 
     457        """Return the type for use in CREATE or ALTER statements.""" 
     458        return "LONGTEXT" 
     459class LONGTEXT411(MySQL_TEXT411): 
     460    bytes = max_bytes = (2 ** 32) - 1 
     461    synonyms = ['LONGTEXT'] 
     462     
     463    def ddl(self): 
     464        """Return the type for use in CREATE or ALTER statements.""" 
     465        return "LONGTEXT" 
    338466 
    339467 
     
    378506        if self.version >= providers.Version("5.0.3"): 
    379507            self.known_types['numeric'] = [DECIMAL503] 
    380             self.known_types['varchar'] = [VARBINARY503, TINYBLOB503, BLOB503, 
    381                                            MEDIUMBLOB503, LONGBLOB503] 
     508            self.known_types['other'] = [CHAR411, VARCHAR503], 
    382509        if self.version >= providers.Version("5.0.5"): 
    383510            self.known_types['numeric'] = [DECIMAL505]