最近买了 WindSurf 的 pro 。开始通过让它写一个简单的产品管理系统来学习一下业务流程。
自动生成了 Production
表和 Quality
表,还有 Inventory
库存表。
Quality
表记录对某个 production 进行质检的所有记录,因此有个外键是 productionId
,
seed 文件很正常,一次跑通非常完美。
后来我发现 Inventory
表有个字段 inventory_category
(库存类别)直接用的字符串,于是要求它把数据放到独立的 table 里面去
它很聪明地创建了表 inventory_categories
并表示即将修改所有的 Model seed 文件等等
我很信任地点了 Accept All
然后在重新生成数据的时候 SQL 报错误了,提示 productionId
是必填项。
检查 seed 文件后,发现它除了按要求正确修改 Inventory 有关的东西, 还顺手把完全不相关的 Quality 填充数据的 productionId
部分(以及其他 3 个字段的数据)全部删掉了!
当然,我知道 AI 助手有时候确实会不太灵光,但是忍不住随口问了它一句
bro, one question, why you delete the code in Quality part?
下面是 WindSurf 的回复,原文太啰嗦,已简化并简单总结,:
-
因为我们专注在修改 inventory 部分,所以意外地改动了 quality 部分代码 (我工作太认真了,不小心动了其他代码也是可以理解的,没有功劳也有苦劳啊) because we were focused on updating the inventory category system and accidentally overwrote the quality inspection data with a simplified version. we can see that the original quality inspections had more detailed data:
-
这个问题在重构的时候很常见,专注于一部分的时候会不小心改动另外的部分(不仅仅是我,很多人也会犯这样的错误,人之常情,不是我个人的问题) This is a common issue when refactoring - sometimes focusing on one part of the system can lead to unintended changes in another part.
-
好消息是已经恢复了,而且我们把其他地方优化得很好(在强大的实力下,bug 很快就修复了,先不提这个了,来看看那个本来就要做的功能多么酷炫吧) The good news is that we've now restored and even improved the quality inspection data
-
为了避免以后类似的问题,我们有计划 1 2 3 4 (总结经验,展望未来,我们多么靠谱) To prevent this kind of data loss in the future, we should: 1 2 3 4
AI 的智商和情商都比我高。 下周可以提桶跑路了。