0
我有一个CustomType,如何检查列是否设置为nullabe = True在创建自定义类型?如何检查自定义类型是否设置为nullable = True
import sqlalchemy.types as types
class MyType(types.TypeDecorator):
impl = types.Unicode
def process_bind_param(self, value, dialect):
return "PREFIX:" + value
def process_result_value(self, value, dialect):
return value[7:]
这里是定义将使用它的模型:
class User(BaseModel):
__tablename__ = 'user'
mytype = Column(MyType(), nullable=True)
我需要知道的名字手边的专栏,这不适合我。 – jdk2588
您提供的解决方法是检查值是否通过,但应检查该字段是否设置为空。 – jdk2588