3 ms·
For future reference, the ChatGPT’s mistake in the SQLAlchemy model: id = Column(String, primary_key=True, default=str(uuid.uuid4()), unique=True, nullable=F
by divbzero 2y ago
For future reference, the ChatGPT’s mistake in the SQLAlchemy model:
id = Column(String, primary_key=True, default=str(uuid.uuid4()), unique=True, nullable=False)
Can be fixed by making the default a function:
id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4()), unique=True, nullable=False)
Or, if you choose to use native UUID types in Python and SQL:
id = Column(Uuid, primary_key=True, default=uuid.uuid4, unique=True, nullable=False)