{"record":{"id":"88fb7542690aff9e","repo":"clockworklabs/SpacetimeDB","slug":"index-indexlabel-on-table-tablelabel-mus","errorCode":null,"errorMessage":"Index '${indexLabel}' on table '${tableLabel}' must define a non-empty 'accessor'","messagePattern":"Index '(.+?)' on table '(.+?)' must define a non-empty 'accessor'","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/lib/table.ts","lineNumber":442,"sourceCode":"        colId: colIds.get(name)!,\n        value: writer.getBuffer(),\n      });\n    }\n\n    // If this column is shaped like ScheduleAtAlgebraicType, mark it as the schedule‑at column\n    const algebraicType = builder.typeBuilder.algebraicType;\n    if (ScheduleAt.isScheduleAt(algebraicType)) {\n      scheduleAtCol = colIds.get(name)!;\n    }\n  }\n\n  // convert explicit multi‑column indexes coming from options.indexes\n  for (const indexOpts of userIndexes ?? []) {\n    const accessor = indexOpts.accessor;\n    if (typeof accessor !== 'string' || accessor.length === 0) {\n      const tableLabel = name ?? '<unnamed>';\n      const indexLabel = indexOpts.name ?? '<unnamed>';\n      throw new TypeError(\n        `Index '${indexLabel}' on table '${tableLabel}' must define a non-empty 'accessor'`\n      );\n    }\n    let algorithm: RawIndexAlgorithm;\n    switch (indexOpts.algorithm) {\n      case 'btree':\n        algorithm = {\n          tag: 'BTree',\n          value: indexOpts.columns.map(c => colIds.get(c)!),\n        };\n        break;\n      case 'hash':\n        algorithm = {\n          tag: 'Hash',\n          value: indexOpts.columns.map(c => colIds.get(c)!),\n        };\n        break;\n      case 'direct':","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-typescript/src/lib/table.ts#L424-L460","documentation":"When materializing a view, the host compiles the view's SQL with SubscriptionPlan::compile — the same compiler used for client subscriptions. If the plan reports parameters (has_params, i.e. '?' placeholders in the query), the host bails: views are materialized server-side at publish time, so there is no client to bind parameter values.","triggerScenarios":"Publishing a module or schema whose view definition contains '?' placeholders, e.g. CREATE VIEW v AS SELECT * FROM t WHERE t.x > ? — SubscriptionPlan::compile succeeds but sets has_params=true.","commonSituations":"Copying a parameterized subscription query into a view definition; assuming views behave like prepared statements; porting SQL from a client that binds filters dynamically.","solutions":["Inline concrete literals into the view query instead of '?' placeholders.","If the filter must vary, materialize per-case views with different literals, or move the logic into a reducer that writes a regular table.","For client-side parameterized reads, use a subscription against the underlying table rather than a view."],"exampleFix":"-- before\nCREATE VIEW active_users AS SELECT * FROM users WHERE level > ?;\n\n-- after\nCREATE VIEW active_users AS SELECT * FROM users WHERE level > 5;","handlingStrategy":"validation","validationCode":"fn view_has_params(sql: &str) -> bool {\n    let mut quoted = false;\n    for c in sql.chars() {\n        match c {\n            '\\'' => quoted = !quoted,\n            '?' if !quoted => return true,\n            _ => {}\n        }\n    }\n    false\n}\nassert!(!view_has_params(&view_sql), \"views cannot use ? parameters\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat view definitions as fully concrete SQL: no placeholders, no client-bound values.","Put variable filters in subscriptions or reducers, never in CREATE VIEW statements.","Lint migration files for 'CREATE VIEW' blocks containing '?' before publishing."],"tags":["spacetimedb","sql","views","subscriptions","schema"],"backgroundTag":"parameterized-query-unsupported","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}