Expand description
SQL query constants and fragments
This module centralizes frequently-used SQL query strings and fragments to:
- Reduce code duplication
- Ensure consistency across the codebase
- Make query modifications easier to maintain
§Design Philosophy
- Column Lists: Reusable SELECT column specifications
- Base Queries: Complete SELECT statements with standard FROM clauses
- Existence Checks: Common existence validation patterns
Note: Dynamic WHERE clauses are still built inline for flexibility.
Constants§
- CHECK_
TASK_ EXISTS - Check if a task exists by ID
- CHECK_
TASK_ EXISTS_ FOR_ EVENT - Check if a task exists (also used by event validation)
- COUNT_
CHILDREN_ TOTAL - Count total children of a parent
- COUNT_
EVENTS_ FOR_ TASK - Count events for a specific task
- COUNT_
EVENTS_ TOTAL - Count total events
- COUNT_
INCOMPLETE_ CHILDREN - Count incomplete subtasks of a parent
- COUNT_
INCOMPLETE_ CHILDREN_ EXCLUDE - Count incomplete children excluding specific task
- COUNT_
INCOMPLETE_ TASKS_ EXCLUDE - Count incomplete tasks excluding specific task
- COUNT_
TASKS_ DOING - Count tasks with ‘doing’ status
- COUNT_
TASKS_ FTS - Count task FTS5 matches
- COUNT_
TASKS_ INCOMPLETE - Count incomplete tasks (todo or doing)
- COUNT_
TASKS_ TOTAL - Count total tasks
- EVENT_
COLUMNS - Standard column list for event queries
- SELECT_
EVENT_ BASE - Base SELECT query for events with dynamic WHERE clause building
- SELECT_
EVENT_ BY_ ID - SELECT event with WHERE id = ? condition
- SELECT_
EVENT_ FULL - Base SELECT query for events
- SELECT_
TASKS_ FTS_ BASE - Base query for task FTS5 search
- SELECT_
TASK_ FULL - Base SELECT query for tasks (with spec)
- SELECT_
TASK_ NAME - Get task name by ID
- SELECT_
TASK_ NAME_ PARENT - Get task name and parent_id by ID
- SELECT_
TASK_ NO_ SPEC - Base SELECT query for tasks (without spec, using NULL)
- SELECT_
TASK_ PARENT_ ID - Get parent_id for a task
- TASK_
COLUMNS - Standard column list for task queries (includes spec column)
- TASK_
COLUMNS_ NO_ SPEC - Task column list without spec (uses NULL placeholder)