mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2026-03-13 08:00:02 +08:00
Add sets module support and make boolean support non-optional
This commit is contained in:
@@ -34,16 +34,20 @@ MySQL.connect().
|
||||
|
||||
from _mysql import string_literal, escape_sequence, escape_dict, escape, NULL
|
||||
from constants import FIELD_TYPE, FLAG
|
||||
from sets import *
|
||||
from sets import BaseSet
|
||||
from times import *
|
||||
import types
|
||||
import array
|
||||
|
||||
def Bool2Str(s, d): return str(int(s))
|
||||
|
||||
def Str2Set(s):
|
||||
values = s.split(',')
|
||||
return Set(*values)
|
||||
|
||||
def Set2Str(s, d):
|
||||
return string_literal(','.join(s), d)
|
||||
|
||||
def Thing2Str(s, d):
|
||||
"""Convert something into a string via str()."""
|
||||
return str(s)
|
||||
@@ -120,8 +124,10 @@ conversions = {
|
||||
types.StringType: Thing2Literal, # default
|
||||
types.UnicodeType: Unicode2Str,
|
||||
types.ObjectType: Instance2Str,
|
||||
types.BooleanType: Bool2Str,
|
||||
DateTimeType: DateTime2literal,
|
||||
DateTimeDeltaType: DateTimeDelta2literal,
|
||||
BaseSet: Set2Str,
|
||||
FIELD_TYPE.TINY: int,
|
||||
FIELD_TYPE.SHORT: int,
|
||||
FIELD_TYPE.LONG: long,
|
||||
@@ -158,9 +164,5 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
try:
|
||||
from types import BooleanType
|
||||
def Bool2Str(s, d): return str(int(s))
|
||||
conversions[BooleanType] = Bool2Str
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user