fix(show): resolve wisp_dependencies target via split columns too
Round 3 fixed only the `dependencies` count branch, but SHOW CREATE TABLE confirms BOTH dependency tables define depends_on_id as GENERATED ALWAYS AS (COALESCE(depends_on_issue_id, depends_on_wisp_id, depends_on_external)) STORED. The wisp_dependencies count branch still referenced the generated column, so the embedded (gms_pure_go) CI job kept failing CountDependents with "column depends_on_id could not be found in any table in scope". Resolve the target via the physical split columns for the wisp_dependencies count branches too (CountDependents, CountDependentsByStatus; dolt + embeddeddolt). No count query now references the generated depends_on_id; the slice/iter paths keep using it (they project real columns, so the analyzer retains the base columns). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
452f757b04
commit
3e036880f0
2 changed files with 30 additions and 29 deletions
|
|
@ -10,13 +10,16 @@ import (
|
|||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// depTargetExpr resolves a `dependencies` row's target id from the split
|
||||
// physical columns instead of the STORED generated `depends_on_id` column.
|
||||
// Count queries (which project no real columns) must use this: referencing the
|
||||
// generated column in a count(*) WHERE clause can trip a "column depends_on_id
|
||||
// could not be found in any table in scope" analyzer error in the pure-Go GMS
|
||||
// engine. Only the `dependencies` table is split; `wisp_dependencies` keeps a
|
||||
// physical `depends_on_id`.
|
||||
// depTargetExpr resolves a dependency row's target id from the split physical
|
||||
// columns instead of the STORED generated `depends_on_id` column. Both
|
||||
// `dependencies` and `wisp_dependencies` define depends_on_id as
|
||||
// GENERATED ALWAYS AS (COALESCE(depends_on_issue_id, depends_on_wisp_id,
|
||||
// depends_on_external)). Count queries must filter on the base columns: inside
|
||||
// a count(*) (which projects no real columns) the pure-Go GMS analyzer can
|
||||
// prune the base columns the generated column derives from and then fail with
|
||||
// "column depends_on_id could not be found in any table in scope". The slice
|
||||
// path projects real columns, so it can use depends_on_id directly. This
|
||||
// matches issueops.DepTargetExpr on main.
|
||||
const depTargetExpr = "COALESCE(depends_on_issue_id, depends_on_wisp_id, depends_on_external)"
|
||||
|
||||
// CountIssues returns the number of issues matching query and filter.
|
||||
|
|
@ -44,12 +47,9 @@ func (s *DoltStore) CountIssues(ctx context.Context, query string, filter types.
|
|||
// a dependent may be a permanent issue (edge in `dependencies`) or a wisp
|
||||
// (edge in `wisp_dependencies`, routed there by WispTableRouting on the source).
|
||||
//
|
||||
// The `dependencies` target is resolved via the split physical columns
|
||||
// (depTargetExpr) rather than the STORED generated `depends_on_id`: inside a
|
||||
// count(*) (no real columns projected) the pure-Go GMS analyzer can prune the
|
||||
// base columns the generated column depends on and fail with "column
|
||||
// depends_on_id could not be found in any table in scope". wisp_dependencies
|
||||
// keeps a physical depends_on_id, so it is queried directly.
|
||||
// Both tables' targets are resolved via depTargetExpr (the split physical
|
||||
// columns) rather than the STORED generated depends_on_id, which a count(*)
|
||||
// can fail to resolve under the pure-Go GMS analyzer.
|
||||
func (s *DoltStore) CountDependents(ctx context.Context, issueID string) (int64, error) {
|
||||
var n int64
|
||||
err := s.withReadTx(ctx, func(tx *sql.Tx) error {
|
||||
|
|
@ -59,7 +59,7 @@ func (s *DoltStore) CountDependents(ctx context.Context, issueID string) (int64,
|
|||
return err
|
||||
}
|
||||
if err := tx.QueryRowContext(ctx,
|
||||
`SELECT count(*) FROM wisp_dependencies WHERE depends_on_id = ?`, issueID).Scan(&wisp); err != nil {
|
||||
`SELECT count(*) FROM wisp_dependencies WHERE `+depTargetExpr+` = ?`, issueID).Scan(&wisp); err != nil {
|
||||
return err
|
||||
}
|
||||
n = perm + wisp
|
||||
|
|
@ -138,7 +138,7 @@ func (s *DoltStore) CountDependentsByStatus(ctx context.Context, issueID string,
|
|||
if err := tx.QueryRowContext(ctx,
|
||||
`SELECT count(*) FROM wisp_dependencies d
|
||||
JOIN wisps w ON w.id = d.issue_id
|
||||
WHERE d.depends_on_id = ? AND w.status = ?`,
|
||||
WHERE COALESCE(d.depends_on_issue_id, d.depends_on_wisp_id, d.depends_on_external) = ? AND w.status = ?`,
|
||||
issueID, string(status)).Scan(&wisp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,13 +12,16 @@ import (
|
|||
"github.com/steveyegge/beads/internal/types"
|
||||
)
|
||||
|
||||
// depTargetExpr resolves a `dependencies` row's target id from the split
|
||||
// physical columns instead of the STORED generated `depends_on_id` column.
|
||||
// Count queries (which project no real columns) must use this: referencing the
|
||||
// generated column in a count(*) WHERE clause can trip a "column depends_on_id
|
||||
// could not be found in any table in scope" analyzer error in the pure-Go GMS
|
||||
// engine. Only the `dependencies` table is split; `wisp_dependencies` keeps a
|
||||
// physical `depends_on_id`.
|
||||
// depTargetExpr resolves a dependency row's target id from the split physical
|
||||
// columns instead of the STORED generated `depends_on_id` column. Both
|
||||
// `dependencies` and `wisp_dependencies` define depends_on_id as
|
||||
// GENERATED ALWAYS AS (COALESCE(depends_on_issue_id, depends_on_wisp_id,
|
||||
// depends_on_external)). Count queries must filter on the base columns: inside
|
||||
// a count(*) (which projects no real columns) the pure-Go GMS analyzer can
|
||||
// prune the base columns the generated column derives from and then fail with
|
||||
// "column depends_on_id could not be found in any table in scope". The slice
|
||||
// path projects real columns, so it can use depends_on_id directly. This
|
||||
// matches issueops.DepTargetExpr on main.
|
||||
const depTargetExpr = "COALESCE(depends_on_issue_id, depends_on_wisp_id, depends_on_external)"
|
||||
|
||||
func (s *EmbeddedDoltStore) CountIssues(ctx context.Context, query string, filter types.IssueFilter) (int64, error) {
|
||||
|
|
@ -44,11 +47,9 @@ func (s *EmbeddedDoltStore) CountIssues(ctx context.Context, query string, filte
|
|||
// `dependencies`) or a wisp (edge in `wisp_dependencies`). Counted in separate
|
||||
// top-level queries and summed in Go.
|
||||
//
|
||||
// The `dependencies` target is resolved via the split physical columns
|
||||
// (depTargetExpr) rather than the STORED generated `depends_on_id`: inside a
|
||||
// count(*) the pure-Go GMS analyzer can prune the base columns the generated
|
||||
// column depends on and fail with "column depends_on_id could not be found in
|
||||
// any table in scope". wisp_dependencies keeps a physical depends_on_id.
|
||||
// Both tables' targets are resolved via depTargetExpr (the split physical
|
||||
// columns) rather than the STORED generated depends_on_id, which a count(*)
|
||||
// can fail to resolve under the pure-Go GMS analyzer.
|
||||
func (s *EmbeddedDoltStore) CountDependents(ctx context.Context, issueID string) (int64, error) {
|
||||
var n int64
|
||||
err := s.withConn(ctx, false, func(tx *sql.Tx) error {
|
||||
|
|
@ -58,7 +59,7 @@ func (s *EmbeddedDoltStore) CountDependents(ctx context.Context, issueID string)
|
|||
return err
|
||||
}
|
||||
if err := tx.QueryRowContext(ctx,
|
||||
`SELECT count(*) FROM wisp_dependencies WHERE depends_on_id = ?`, issueID).Scan(&wisp); err != nil {
|
||||
`SELECT count(*) FROM wisp_dependencies WHERE `+depTargetExpr+` = ?`, issueID).Scan(&wisp); err != nil {
|
||||
return err
|
||||
}
|
||||
n = perm + wisp
|
||||
|
|
@ -133,7 +134,7 @@ func (s *EmbeddedDoltStore) CountDependentsByStatus(ctx context.Context, issueID
|
|||
if err := tx.QueryRowContext(ctx,
|
||||
`SELECT count(*) FROM wisp_dependencies d
|
||||
JOIN wisps w ON w.id = d.issue_id
|
||||
WHERE d.depends_on_id = ? AND w.status = ?`,
|
||||
WHERE COALESCE(d.depends_on_issue_id, d.depends_on_wisp_id, d.depends_on_external) = ? AND w.status = ?`,
|
||||
issueID, string(status)).Scan(&wisp); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue