你应该为你的数据库添加调试视图。
You Should Add Debug Views to Your DB

原始链接: https://chrispenner.ca/posts/views-for-debugging

一份错误报告指出,用户Sophie在使用Unison Share(用于Unison代码贡献,类似于拉取请求)查看差异时遇到了错误,该错误发生在`@unison/cloud`项目中。最初定位到具体的贡献需要一个复杂的SQL查询,该查询连接了多个表(贡献、项目、用户、分支),并根据Sophie的用户名和项目名称进行过滤。虽然该查询功能正常,但它很长且繁琐,尤其是在重复使用时。 为了简化调试,作者创建了一个`debug_contributions`视图。该视图预先连接了所有必要的表,并包含易于理解的名称(如项目和分支名称)以及ID。现在,查找Sophie的贡献只需要对视图执行一个更简单的查询,使用清晰的标准,如用户名和项目简写。 虽然视图的计算列可能会略微影响性能,但作者优先考虑易用性,因为调试任务并不频繁。关键在于,创建这些调试视图可以节省时间和精力,因为它封装了复杂的连接,并提供了易于访问、信息丰富的的数据。

相关文章

原文

This one will be quick.

Imagine this, you get a report from your bug tracker:

Sophie got an error when viewing the diff after her most recent push to her contribution to the @unison/cloud project on Unison Share

(BTW, contributions are like pull requests, but for Unison code)

Okay, this is great, we have something to start with, let's go look up that contribution and see if any of the data there is suspicious.

Uhhh, okay, I know the error is related to one of Sophie's contributions, but how do I actually find it?

I know Sophie's username from the bug report, that helps, but I don't know which project she was working on, or what the contribution ID is, which branches are involved, etc. Okay no problem, our data is relational, so I can dive in and figure it out with a query:

here. Every sale helps me justify more time writing blog posts like this one and helps me to continue writing educational functional programming content. Cheers!

联系我们 contact @ memedata.com