
How does a linter know your column doesn't exist
You write a query that SELECTs ghost_status from the orders table. Your code compiles. Your tests pass. But ghost_status was never created in any migration. In production, that query crashes. Valk Guard catches this at PR time - with no database connection. This post walks through exactly how. Not hand-waving. The actual code path, from source file to finding. The setup Here's a Go file using Goqu to build a query: func ListBrokenUserOrderStatus(ctx context.Context) error { _, _, err := goqu.From("users"). LeftJoin( goqu.T("orders"), goqu.On(goqu.I("orders.user_id").Eq(goqu.I("users.id"))), ). Select("users.id", "users.email", "orders.ghost_status"). Where(goqu.I("orders.missing_flag").Eq("pending")). ToSQL() return err } And here's the migration that created the orders table: CREATE TABLE orders ( id SERIAL PRIMARY KEY, user_id INTEGER NOT NULL REFERENCES users(id), total NUMERIC(10,2) NOT NULL, status TEXT NOT NULL DEFAULT 'pending', created_at TIMESTAMP DEFAULT now() ); Notice: the
Continue reading on Dev.to
Opens in a new tab




