带有参数 None 的外键:Sqlalchemy

Foreign Key with argument None : Sqlalchemy

所以,我在浏览代码库时发现了这个:

user_id_column = Column('user_id', None, ForeignKey('people.people_id'))

我可以清楚地理解这是一个外键列并引用了 people 模式中的 people_id 列。

只是想知道 None 的目的是什么? people_id 列中的数据类型为整数。

第二个参数是类型。来自 the docs:

If the type is None or is omitted, it will first default to the special type NullType. If and when this Column is made to refer to another column using ForeignKey and/or ForeignKeyConstraint, the type of the remote-referenced column will be copied to this column as well, at the moment that the foreign key is resolved against that remote Column object.

所以设置类型为None意味着它使用外键的类型。