Changeset 60
- Timestamp:
- 04/05/07 22:19:10
- Files:
-
- trunk/geniusql/adapters.py (modified) (18 diffs)
- trunk/geniusql/dbtypes.py (modified) (5 diffs)
- trunk/geniusql/providers/ado.py (modified) (4 diffs)
- trunk/geniusql/providers/msaccess.py (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/geniusql/adapters.py
r59 r60 12 12 majority of cases, a reasonable set of default adapters can be generated 13 13 by Geniusql. For example, a Column of pytype "datetime.date" can default 14 to a n SQL92DATE adapter (but an MSAccess_Date adapter if necessary), based14 to a DateAdapter (but an MSAccess_Date adapter if necessary), based 15 15 entirely on the Python type. 16 16 … … 355 355 356 356 357 class SQL99BOOLEAN(Adapter): 357 class bool_to_SQL92BIT(Adapter): 358 359 def push(self, value, dbtype): 360 if value is None: 361 return 'NULL' 362 if value: 363 return '1' 364 return '0' 365 366 def pull(self, value, dbtype): 367 return bool(int(value)) 368 369 370 class bool_to_SQL99BOOLEAN(Adapter): 358 371 359 372 def push(self, value, dbtype): … … 367 380 return bool(value) 368 381 369 # SQL92 types: INTEGER (INT), SMALLINT, NUMERIC, DECIMAL, REAL,370 # DOUBLE PRECISION (DOUBLE), BIT, BIT VARYING, DATE, TIME, TIMESTAMP,371 # CHARACTER (CHAR), CHARACTER VARYING (VARCHAR), INTERVAL372 373 class SQL92BIT(Adapter):374 def push(self, value, dbtype):375 if value is None:376 return 'NULL'377 if value:378 return '1'379 return '0'380 381 def pull(self, value, dbtype):382 return bool(int(value))383 384 382 385 383 # The great thing about these 3 date coercers is that you can use 386 384 # them with (VAR)CHAR columns just as well as with DATETIME, etc. 387 385 # and comparisons will still work! 388 class SQL92TIMESTAMP(Adapter):386 class datetime_to_SQL92TIMESTAMP(Adapter): 389 387 390 388 def push(self, value, dbtype): … … 404 402 405 403 406 class SQL92DATE(Adapter):404 class date_to_SQL92DATE(Adapter): 407 405 408 406 def push(self, value, dbtype): … … 423 421 424 422 425 class SQL92TIME(Adapter):423 class time_to_SQL92TIME(Adapter): 426 424 427 425 def push(self, value, dbtype): … … 437 435 438 436 439 class INTERVAL(Adapter):437 class timedelta_to_SQL92DECIMAL(Adapter): 440 438 """Adapter for storing datetime.timedelta values in whole seconds. 441 439 442 440 SQL-92 defines an INTERVAL type, but few commercial databases 443 441 implement it in a reasonable manner. This adapter stores the 444 value (days * 86400) + seconds in a NUMERICfield instead,442 value (days * 86400) + seconds in a DECIMAL field instead, 445 443 which should work with most databases. Note that a custom 446 444 binary_op method MUST be written for each DB which subclasses … … 463 461 464 462 465 class SQL92REAL(Adapter): 463 class float_to_SQL92REAL(Adapter): 464 """Adapter from Python float to SQL92-compliant REAL.""" 465 466 466 def push(self, value, dbtype): 467 467 if value is None: … … 473 473 return float(value) 474 474 475 class SQL92DOUBLE(Adapter): 476 def push(self, value, dbtype): 477 if value is None: 478 return 'NULL' 479 # Very important we use repr here so we get all 17 decimal digits. 480 return repr(value) 481 482 def pull(self, value, dbtype): 483 return float(value) 484 485 class SQL92SMALLINT(Adapter): 475 class float_to_SQL92DOUBLE(float_to_SQL92REAL): 476 """Adapter from Python float to SQL92-compliant DOUBLE.""" 477 pass 478 479 480 class int_to_SQL92INTEGER(Adapter): 481 486 482 def push(self, value, dbtype): 487 483 if value is None: … … 489 485 return str(value) 490 486 491 # SQL-92 SMALLINT should be 2 bytes 487 # SQL-92 INTEGER is usually 4 bytes 488 if maxint_bytes >= 4: 489 def pull(self, value, dbtype): 490 return int(value) 491 else: 492 def pull(self, value, dbtype): 493 return long(value) 494 495 class int_to_SQL92SMALLINT(Adapter): 496 497 def push(self, value, dbtype): 498 if value is None: 499 return 'NULL' 500 return str(value) 501 502 # SQL-92 SMALLINT is usually 2 bytes 492 503 if maxint_bytes >= 2: 493 504 def pull(self, value, dbtype): … … 497 508 return long(value) 498 509 499 class SQL92INTEGER(Adapter): 500 def push(self, value, dbtype): 501 if value is None: 502 return 'NULL' 503 return str(value) 504 505 # SQL-92 INTEGER should be 4 bytes 506 if maxint_bytes >= 4: 507 def pull(self, value, dbtype): 508 return int(value) 509 else: 510 def pull(self, value, dbtype): 511 return long(value) 512 513 514 class SQL92VARCHAR(Adapter): 510 511 512 class str_to_SQL92VARCHAR(Adapter): 515 513 516 514 # Default escapes for string values. … … 533 531 534 532 535 class UNICODE(SQL92VARCHAR):533 class unicode_to_SQL92VARCHAR(str_to_SQL92VARCHAR): 536 534 537 535 def pull(self, value, dbtype): … … 543 541 544 542 545 class Pickler(SQL92VARCHAR): 543 class Pickler(Adapter): 544 545 # Default escapes for string values. 546 escapes = [("'", "''"), ("\\", r"\\")] 546 547 547 548 def push(self, value, dbtype): … … 566 567 567 568 568 class Numeric_to_TEXT(Adapter):569 class numeric_to_TEXT(Adapter): 569 570 """Adapt a numeric Python type (int|long|float) to a TEXT dbtype.""" 570 571 … … 604 605 605 606 606 class Numeric_to_DECIMAL(Adapter):607 """Adapt a numeric Python type (int|long|float) to a DECIMAL dbtype."""607 class numeric_to_SQL92DECIMAL(Adapter): 608 """Adapt a numeric Python type (int|long|float) to SQL92DECIMAL.""" 608 609 609 610 def __init__(self, pytype): … … 623 624 624 625 if typerefs.decimal: 625 class DECIMAL(Adapter):626 class decimal_to_SQL92DECIMAL(Adapter): 626 627 def push(self, value, dbtype): 627 628 if value is None: … … 642 643 return value 643 644 644 class Decimal_to_TEXT(DECIMAL):645 class decimal_to_TEXT(decimal_to_SQL92DECIMAL): 645 646 def push(self, value, dbtype): 646 647 if value is None: … … 659 660 660 661 if typerefs.fixedpoint: 661 class FIXEDPOINT(Adapter):662 class fixedpoint_to_SQL92DECIMAL(Adapter): 662 663 def push(self, value, dbtype): 663 664 if value is None: … … 680 681 else: 681 682 return typerefs.fixedpoint.FixedPoint(value) 682 class FixedPoint_to_TEXT(FIXEDPOINT): 683 684 class fixedpoint_to_TEXT(fixedpoint_to_SQL92DECIMAL): 683 685 def push(self, value, dbtype): 684 686 if value is None: trunk/geniusql/dbtypes.py
r59 r60 1 # Any otherwise-unattributed quotes in this module are probably from: 2 # http://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt 3 1 4 import datetime 2 5 … … 98 101 99 102 100 class FrozenStringType(FrozenByteType):101 """DatabaseType for string types whose byte-length is not adjustable.102 103 A FrozenStringType does not imply that the type is a fixed-byte104 type like CHAR as opposed to a variable-byte type like VARCHAR105 (that difference is specified in the "variable" attribute).106 Instead, a Frozen* type implies that the type takes no size107 argument in DDL; for example, Microsoft Access' MEMO type108 is always 65535 bytes, and is not user-specifiable.109 """110 111 _initargs = FrozenByteType._initargs + ("variable", "encoding")112 113 # CHAR vs VARCHAR114 variable = True115 encoding = 'utf8'116 117 default_pytype = str118 default_adapters = {str: adapters.SQL92VARCHAR(),119 unicode: adapters.UNICODE(),120 float: adapters.Numeric_to_TEXT(float),121 int: adapters.Numeric_to_TEXT(int),122 long: adapters.Numeric_to_TEXT(long),123 datetime.timedelta: adapters.INTERVAL(),124 None: adapters.Pickler(),125 }126 if typerefs.decimal:127 if hasattr(typerefs.decimal, "Decimal"):128 default_adapters[typerefs.decimal.Decimal] = adapters.Decimal_to_TEXT()129 else:130 default_adapters[typerefs.decimal] = adapters.Decimal_to_TEXT()131 if typerefs.fixedpoint:132 default_adapters[typerefs.fixedpoint.FixedPoint] = adapters.FixedPoint_to_TEXT()133 134 135 class AdjustableStringType(AdjustableByteType):136 """DatabaseType for adjustable-byte string types."""137 138 _initargs = AdjustableByteType._initargs + ("variable", "encoding")139 140 # CHAR vs VARCHAR141 variable = True142 encoding = 'utf8'143 144 default_pytype = str145 default_adapters = {str: adapters.SQL92VARCHAR(),146 unicode: adapters.UNICODE(),147 float: adapters.Numeric_to_TEXT(float),148 int: adapters.Numeric_to_TEXT(int),149 long: adapters.Numeric_to_TEXT(long),150 datetime.timedelta: adapters.INTERVAL(),151 None: adapters.Pickler(),152 }153 if typerefs.decimal:154 if hasattr(typerefs.decimal, "Decimal"):155 default_adapters[typerefs.decimal.Decimal] = adapters.Decimal_to_TEXT()156 else:157 default_adapters[typerefs.decimal] = adapters.Decimal_to_TEXT()158 if typerefs.fixedpoint:159 default_adapters[typerefs.fixedpoint.FixedPoint] = adapters.FixedPoint_to_TEXT()160 161 162 class IntegerType(FrozenByteType):163 164 _initargs = FrozenByteType._initargs + ("signed", )165 166 default_pytype = int167 default_adapters = {int: adapters.SQL92INTEGER(),168 long: adapters.SQL92INTEGER(),169 }170 signed = True171 172 def range(self):173 """Return self.max - self.min."""174 return 2 ** (self.bytes * 8)175 176 def min(self):177 """Return the minimum value allowed."""178 if self.signed:179 return 0 - (self.range() / 2)180 else:181 return 0182 183 def max(self):184 """Return the maximum value allowed."""185 if self.signed:186 return (self.range() / 2) - 1187 else:188 return self.range() - 1189 190 191 103 class FrozenPrecisionType(DatabaseType): 192 104 """DatabaseType which specifies a frozen 'precision' attribute.""" … … 234 146 235 147 236 class InexactNumericType(FrozenPrecisionType): 148 class FixedRangeType(DatabaseType): 149 """DatabaseType which represents values within a fixed range.""" 150 _min = None 151 _max = None 152 153 _initargs = DatabaseType._initargs + ("_min", "_max") 154 155 def range(self): 156 """Return self.max - self.min.""" 157 return self._max - self._min 158 159 def min(self): 160 """Return the minimum value allowed.""" 161 return self._min 162 163 def max(self): 164 """Return the maximum value allowed.""" 165 return self._max 166 167 168 # SQL92 types: INTEGER (INT), SMALLINT, NUMERIC, DECIMAL, FLOAT, REAL, 169 # DOUBLE PRECISION (DOUBLE), BIT, BIT VARYING, DATE, TIME, TIMESTAMP, 170 # CHARACTER (CHAR), CHARACTER VARYING (VARCHAR), INTERVAL 171 172 class TEXT(FrozenByteType): 173 """DatabaseType for string types whose byte-length is not adjustable. 174 175 A FrozenStringType does not imply that the type is a fixed-byte 176 type like CHAR as opposed to a variable-byte type like VARCHAR 177 (that difference is specified in the "variable" attribute). 178 Instead, a Frozen* type implies that the type takes no size 179 argument in DDL; for example, Microsoft Access' MEMO type 180 is always 65535 bytes, and is not user-specifiable. 181 """ 182 183 _initargs = FrozenByteType._initargs + ("variable", "encoding") 184 185 # CHAR vs VARCHAR 186 variable = True 187 encoding = 'utf8' 188 189 default_pytype = str 190 default_adapters = {str: adapters.str_to_SQL92VARCHAR(), 191 unicode: adapters.unicode_to_SQL92VARCHAR(), 192 float: adapters.numeric_to_TEXT(float), 193 int: adapters.numeric_to_TEXT(int), 194 long: adapters.numeric_to_TEXT(long), 195 datetime.timedelta: adapters.timedelta_to_SQL92DECIMAL(), #?? 196 None: adapters.Pickler(), 197 } 198 if typerefs.decimal: 199 if hasattr(typerefs.decimal, "Decimal"): 200 default_adapters[typerefs.decimal.Decimal] = adapters.decimal_to_TEXT() 201 else: 202 default_adapters[typerefs.decimal] = adapters.decimal_to_TEXT() 203 if typerefs.fixedpoint: 204 default_adapters[typerefs.fixedpoint.FixedPoint] = adapters.fixedpoint_to_TEXT() 205 206 207 class SQL92VARCHAR(AdjustableByteType): 208 """DatabaseType for adjustable-byte string types.""" 209 210 _initargs = AdjustableByteType._initargs + ("variable", "encoding") 211 212 # CHAR vs VARCHAR 213 variable = True 214 encoding = 'utf8' 215 216 default_pytype = str 217 default_adapters = {str: adapters.str_to_SQL92VARCHAR(), 218 unicode: adapters.unicode_to_SQL92VARCHAR(), 219 float: adapters.numeric_to_TEXT(float), 220 int: adapters.numeric_to_TEXT(int), 221 long: adapters.numeric_to_TEXT(long), 222 datetime.timedelta: adapters.timedelta_to_SQL92DECIMAL(), #?? 223 None: adapters.Pickler(), 224 } 225 if typerefs.decimal: 226 if hasattr(typerefs.decimal, "Decimal"): 227 default_adapters[typerefs.decimal.Decimal] = adapters.decimal_to_TEXT() 228 else: 229 default_adapters[typerefs.decimal] = adapters.decimal_to_TEXT() 230 if typerefs.fixedpoint: 231 default_adapters[typerefs.fixedpoint.FixedPoint] = adapters.fixedpoint_to_TEXT() 232 233 234 class SQL92CHAR(SQL92VARCHAR): 235 variable = False 236 237 238 class SQL92INTEGER(FrozenByteType): 239 """A base class for DatabaseTypes which conform to SQL92 INTEGER. 240 241 "INTEGER specifies the data type exact numeric, with binary or 242 decimal precision and scale of 0. The choice of binary versus 243 decimal precision is implementation-defined, but shall be the 244 same as SMALLINT." 245 """ 246 247 _initargs = FrozenByteType._initargs + ("signed", ) 248 249 default_pytype = int 250 default_adapters = {int: adapters.int_to_SQL92INTEGER(), 251 long: adapters.int_to_SQL92INTEGER(), 252 } 253 signed = True 254 _bytes = max_bytes = 4 255 256 def range(self): 257 """Return self.max - self.min.""" 258 return 2 ** (self.bytes * 8) 259 260 def min(self): 261 """Return the minimum value allowed.""" 262 if self.signed: 263 return 0 - (self.range() / 2) 264 else: 265 return 0 266 267 def max(self): 268 """Return the maximum value allowed.""" 269 if self.signed: 270 return (self.range() / 2) - 1 271 else: 272 return self.range() - 1 273 274 275 class SQL92SMALLINT(SQL92INTEGER): 276 # The precision of SMALLINT shall be less than or 277 # equal to the precision of INTEGER. 278 _bytes = max_bytes = 2 279 280 281 # "FLOAT specifies the data type approximate numeric, with binary 282 # precision equal to or greater than the value of the specified 283 # <precision>. The maximum value of <precision> is implementation- 284 # defined. <precision> shall not be greater than this value." 285 286 class SQL92FLOAT(AdjustablePrecisionType): 287 """Base class for SQL 92 FLOAT types.""" 237 288 default_pytype = float 238 289 239 290 240 class ExactNumericType(DatabaseType): 241 242 _initargs = DatabaseType._initargs + ("precision", "max_precision", 243 "scale") 291 # "REAL specifies the data type approximate numeric, with implementation- 292 # defined precision." 293 # 294 # "DOUBLE PRECISION specifies the data type approximate numeric, 295 # with implementation-defined precision that is greater than the 296 # implementation-defined precision of REAL. 297 298 class SQL92REAL(FrozenPrecisionType): 299 """Base class for SQL 92 REAL types.""" 300 default_pytype = float 301 _precision = max_precision = 24 302 default_adapters = {float: adapters.float_to_SQL92REAL()} 303 304 class SQL92DOUBLE(SQL92REAL): 305 """Base class for SQL 92 DOUBLE PRECISION types.""" 306 _precision = max_precision = 53 307 default_adapters = {float: adapters.float_to_SQL92DOUBLE()} 308 309 310 # "NUMERIC specifies the data type exact numeric, with the decimal 311 # precision and scale specified by the <precision> and <scale>." 312 # 313 # "DECIMAL specifies the data type exact numeric, with the decimal 314 # scale specified by the <scale> and the implementation-defined 315 # decimal precision equal to or greater than the value of the 316 # specified <precision>." 317 # 318 # In terms of adaptation, there's not much difference between these. 319 # Plenty of databases make them synonyms anyway. 320 321 class SQL92DECIMAL(AdjustablePrecisionType): 322 323 _initargs = AdjustablePrecisionType._initargs + ("scale",) 324 325 scale = None 244 326 245 327 # For exact numeric types, 'precision' refers to decimal digits 246 precision = None 247 scale = None 248 249 # Max decimal precision for NUMERIC columns (= 1000 for PostgreSQL 8). 328 _precision = 18 250 329 max_precision = 1000 251 330 … … 260 339 default_pytype = float 261 340 262 default_adapters = {int: adapters. Numeric_to_DECIMAL(int),263 long: adapters. Numeric_to_DECIMAL(long),264 float: adapters. Numeric_to_DECIMAL(float),265 datetime.timedelta: adapters. INTERVAL(),341 default_adapters = {int: adapters.numeric_to_SQL92DECIMAL(int), 342 long: adapters.numeric_to_SQL92DECIMAL(long), 343 float: adapters.numeric_to_SQL92DECIMAL(float), 344 datetime.timedelta: adapters.timedelta_to_SQL92DECIMAL(), 266 345 } 267 346 if typerefs.fixedpoint: 268 default_adapters[typerefs.fixedpoint.FixedPoint] = adapters. FIXEDPOINT()347 default_adapters[typerefs.fixedpoint.FixedPoint] = adapters.fixedpoint_to_SQL92DECIMAL() 269 348 if typerefs.decimal: 270 349 if hasattr(typerefs.decimal, "Decimal"): 271 default_adapters[typerefs.decimal.Decimal] = adapters. DECIMAL()272 else: 273 default_adapters[typerefs.decimal] = adapters. DECIMAL()350 default_adapters[typerefs.decimal.Decimal] = adapters.decimal_to_SQL92DECIMAL() 351 else: 352 default_adapters[typerefs.decimal] = adapters.decimal_to_SQL92DECIMAL() 274 353 275 354 def range(self): … … 297 376 298 377 299 class FixedRangeType(DatabaseType): 300 """DatabaseType which represents values within a fixed range.""" 301 _min = None 302 _max = None 303 304 _initargs = DatabaseType._initargs + ("_min", "_max") 305 306 def range(self): 307 """Return self.max - self.min.""" 308 return self._max - self._min 309 310 def min(self): 311 """Return the minimum value allowed.""" 312 return self._min 313 314 def max(self): 315 """Return the maximum value allowed.""" 316 return self._max 317 318 class DateTimeType(FixedRangeType): 378 class SQL92TIMESTAMP(FixedRangeType): 319 379 default_pytype = datetime.datetime 320 default_adapters = {datetime.datetime: adapters. SQL92TIMESTAMP()}321 322 class DateType(FixedRangeType):380 default_adapters = {datetime.datetime: adapters.datetime_to_SQL92TIMESTAMP()} 381 382 class SQL92DATE(FixedRangeType): 323 383 default_pytype = datetime.date 324 default_adapters = {datetime.date: adapters. SQL92DATE()}325 326 class TimeType(DatabaseType):384 default_adapters = {datetime.date: adapters.date_to_SQL92DATE()} 385 386 class SQL92TIME(DatabaseType): 327 387 default_pytype = datetime.time 328 default_adapters = {datetime.time: adapters.SQL92TIME()} 329 330 331 class BooleanType(DatabaseType): 332 """DatabaseType which uses boolean values (True, False, Null).""" 333 default_pytype = bool 334 default_adapters = {bool: adapters.SQL99BOOLEAN()} 335 336 class BitType(DatabaseType): 388 default_adapters = {datetime.time: adapters.time_to_SQL92TIME()} 389 390 class SQL92BIT(DatabaseType): 337 391 """DatabaseType which uses boolean values (0, 1, Null).""" 338 392 default_pytype = bool 339 default_adapters = {bool: adapters.SQL92BIT()} 340 341 393 default_adapters = {bool: adapters.bool_to_SQL92BIT()} 394 395 396 397 # SQL99 types: CLOB, BLOB, BOOLEAN, ARRAY, ROW 398 399 class SQL99BOOLEAN(DatabaseType): 400 """DatabaseType which uses boolean values (True, False, Null).""" 401 # ANSI SQL:1999 says something like: 402 # "The data type boolean comprises the distinct truth values 403 # true and false. Unless prohibited by a NOT NULL constraint, 404 # the boolean data type also supports the unknown truth value as 405 # the null value. This specification does not make a distinction 406 # between the null value of the boolean data type and the unknown 407 # truth value that is the result of an SQL <predicate>, <search 408 # condition>, or <boolean value expression>; they may be used 409 # interchangeably to mean exactly the same thing." 410 default_pytype = bool 411 default_adapters = {bool: adapters.bool_to_SQL99BOOLEAN()} 412 trunk/geniusql/providers/ado.py
r59 r60 82 82 83 83 84 class COM_timedelta(adapters. INTERVAL):84 class COM_timedelta(adapters.timedelta_to_SQL92DECIMAL): 85 85 86 86 def pull(self, value, dbtype): … … 122 122 123 123 124 class COM_time(adapters. SQL92TIME):124 class COM_time(adapters.time_to_SQL92TIME): 125 125 def pull(self, value, dbtype): 126 126 t = timedelta_from_com(value) … … 132 132 133 133 134 class COM_datetime(adapters. SQL92TIMESTAMP):134 class COM_datetime(adapters.datetime_to_SQL92TIMESTAMP): 135 135 136 136 epoch = datetime.datetime(1899, 12, 30) … … 186 186 187 187 188 class COM_date(adapters. SQL92DATE):188 class COM_date(adapters.date_to_SQL92DATE): 189 189 190 190 epoch = datetime.datetime(1899, 12, 30) trunk/geniusql/providers/msaccess.py
r59 r60 90 90 91 91 92 class CURRENCY_float(adapters. SQL92DOUBLE):92 class CURRENCY_float(adapters.float_to_SQL92DOUBLE): 93 93 94 94 def pull(self, value, dbtype): … … 100 100 return float(value) 101 101 102 class CURRENCY_decimal(adapters. DECIMAL):102 class CURRENCY_decimal(adapters.decimal_to_SQL92DECIMAL): 103 103 104 104 def pull(self, value, dbtype): … … 114 114 return value 115 115 116 class CURRENCY_FixedPoint(adapters. FIXEDPOINT):116 class CURRENCY_FixedPoint(adapters.fixedpoint_to_SQL92DECIMAL): 117 117 118 118 def pull(self, value, dbtype): … … 151 151 "using %r in a case-sensitive way." % sqlop) 152 152 153 class MSAccess_VARCHAR_Adapter(adapters. SQL92VARCHAR):153 class MSAccess_VARCHAR_Adapter(adapters.str_to_SQL92VARCHAR): 154 154 escapes = [("'", "''")] 155 155 compare_op = _compare_strings 156 156 157 class MSAccess_UNICODE_Adapter(adapters. UNICODE):157 class MSAccess_UNICODE_Adapter(adapters.unicode_to_SQL92VARCHAR): 158 158 escapes = [("'", "''")] 159 159 compare_op = _compare_strings … … 180 180 # when you sort or group on a Memo field." 181 181 182 class TEXT(dbtypes. AdjustableStringType):183 184 _initargs = dbtypes. AdjustableStringType._initargs + ("with_compression",)182 class TEXT(dbtypes.SQL92VARCHAR): 183 184 _initargs = dbtypes.SQL92VARCHAR._initargs + ("with_compression",) 185 185 186 186 # Actually 255 chars, 2 bytes per char unless compressed … … 204 204 with_compression = False 205 205 206 default_adapters = dbtypes. AdjustableStringType.default_adapters.copy()206 default_adapters = dbtypes.SQL92VARCHAR.default_adapters.copy() 207 207 default_adapters.update({str: MSAccess_VARCHAR_Adapter(), 208 208 unicode: MSAccess_UNICODE_Adapter(), … … 218 218 219 219 220 class MEMO(dbtypes. FrozenStringType):220 class MEMO(dbtypes.TEXT): 221 221 # MEMO is 1 GB max when set programatically (only 64K when set 222 222 # in Access UI). But then, 1 GB is the limit for the whole DB. … … 227 227 encoding = 'ISO-8859-1' 228 228 229 default_adapters = dbtypes. FrozenStringType.default_adapters.copy()229 default_adapters = dbtypes.TEXT.default_adapters.copy() 230 230 default_adapters.update({str: MSAccess_VARCHAR_Adapter(), 231 231 unicode: MSAccess_UNICODE_Adapter(), … … 234 234 235 235 236 class TINYINT(dbtypes. IntegerType):236 class TINYINT(dbtypes.SQL92SMALLINT): 237 237 synonyms = ['INTEGER1', 'BYTE'] 238 238 bytes = max_bytes = 1 239 239 signed = False 240 240 241 class SMALLINT(dbtypes. IntegerType):241 class SMALLINT(dbtypes.SQL92SMALLINT): 242 242 synonyms = ['SHORT', 'INTEGER2'] 243 bytes = max_bytes = 2 244 245 class INTEGER(dbtypes.IntegerType): 243 244 class INTEGER(dbtypes.SQL92INTEGER): 246 245 synonyms = ['LONG', 'INT', 'INTEGER4'] 247 bytes = max_bytes = 4 248 249 class FLOAT(dbtypes.InexactNumericType): 246 247 248 class REAL(dbtypes.SQL92REAL): 249 synonyms = ['SINGLE', 'FLOAT4', 'IEEESINGLE'] 250 251 class FLOAT(dbtypes.SQL92DOUBLE): 250 252 synonyms = ['DOUBLE', 'FLOAT8', 'IEEEDOUBLE', 'NUMBER'] 251 precision = max_precision = 53 252 default_adapters = {float: adapters.SQL92DOUBLE()} 253 254 class REAL(dbtypes.InexactNumericType): 255 synonyms = ['SINGLE', 'FLOAT4', 'IEEESINGLE'] 256 precision = max_precision = 24 257 default_adapters = {float: adapters.SQL92REAL()} 258 implicit_conversions = [TINYINT, SMALLINT, INTEGER, FLOAT] 259 260 261 class DECIMAL(dbtypes.ExactNumericType): 253 254 255 class DECIMAL(dbtypes.SQL92DECIMAL): 262 256 synonyms = ['NUMERIC', 'DEC'] 263 257 264 258 # "...precision, the default is 18 and the maximum allowed value is 28. 265 259 # For the scale, the default is 0 and the maximum allowed value is 28." 266 precision = 18260 _precision = 18 267 261 max_precision = 28 268 262 scale = 0 269 ##270 ## # Hm. Docs say 28, but I can't seem to get more than 12 working.271 ## numeric_max_precision = 12272 ## numeric_max_bytes = 6273 263 274 264 … … 296 286 297 287 298 class YESNO(dbtypes. BooleanType):288 class YESNO(dbtypes.SQL99BOOLEAN): 299 289 # "The BOOLEAN data types are logical types that result in either True 300 290 # or False values. They use 1 byte of memory for storage, and their … … 318 308 319 309 320 class DATETIME(dbtypes. DateTimeType):310 class DATETIME(dbtypes.SQL92TIMESTAMP): 321 311 # "The DATETIME data type is used to store date, time, and combination 322 312 # date/time values for the years ranging from 100 to 9999.
