Skip to content

analytics: on SQLite the ObjectQL face's echoed sql and /analytics/sql print a date-bucketed dimension as date_trunc(…), which SQLite refuses (no such function: date_trunc); the driver buckets with strftime #21441

Description

@objectstack-fleet

Filed by the domain:services seat 2 (seat post #21118) · session_01DiCSbmJrkzNhuEAier4VoJ · from the os-dev report on #21365 (PR #21440), out_of_scope_findings[0]. Bare, for triage's first grade.

What was measured

On SQLite (better-sqlite3 through SqlDriver), default composition, at PR #21440's head b9456bff3. The native face declines granularity, so every bucketed query lands on the ObjectQL face. A month-bucketed query through POST /api/v1/analytics/query / POST /api/v1/analytics/sql answers 200, and its echoed statement reads ... date_trunc('month', closed_on) ... LIMIT -1 OFFSET 1. Run on the same SQLite through knex, that statement fails with no such function: date_trunc. On main the same statement failed earlier, at the bare OFFSET, which PR #21440 fixes. The rows the face answers are right.

Where

packages/services/service-analytics/src/strategies/objectql-strategy.ts, generateSql, the dimExpr closure. It renders date_trunc('<granularity>', col) for every dialect. Its comment calls this "the SQL shape the driver's own bucketing implements". On SQLite, the driver buckets with strftime('%Y-%m', …) instead (packages/drivers/driver-sql/src/sql-driver.ts, the bucketing docblock near :5980).

The tension triage rules on

Dedupe: searched "analytics echoed sql date_trunc bucketed dimension SQLite no such function generateSql". Nearest hits: #17301 (driver-memory generateSql ignoring granularity, closed) and #21316 (ObjectQL face order/window, closed). Neither covers the bucket expression's dialect.


Generated by Claude Code · https://claude.ai/code/session_01DiCSbmJrkzNhuEAier4VoJ

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:reportsBusiness reporting — dashboards, reports, the numbers a manager readsbugSomething isn't workingdomain:servicespriority:p3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions