Skip to content

SQLite: JSON_UNQUOTE/JSON_EXTRACT fails in migrate_task_type_column #1028

@chubes4

Description

@chubes4

Bug

DataMachine\Core\Database\Jobs\Jobs::migrate_task_type_column() uses JSON_UNQUOTE(JSON_EXTRACT(...)) which fails on SQLite (WordPress Studio uses sqlite-database-integration).

Error

SQLSTATE[HY000]: General error: 1 no such function: JSON_UNQUOTE

Query:

UPDATE wp_datamachine_jobs
SET task_type = JSON_UNQUOTE(JSON_EXTRACT(engine_data, '$.task_type'))
WHERE source IN ('system', 'pipeline_system_task')
AND engine_data IS NOT NULL
AND JSON_EXTRACT(engine_data, '$.task_type') IS NOT NULL
AND task_type IS NULL

Context

Hit during wp plugin activate data-machine on a fresh WordPress Studio site (SQLite backend). The table creation succeeds but the migration query fails. Plugin still activates but the migration is skipped.

Stack

Jobs.php:409 → Jobs.php:160 → data-machine.php:553 → data-machine.php:507

Fix

SQLite supports json_extract() but not JSON_UNQUOTE(). Since json_extract() on SQLite already returns unquoted strings, the fix is to conditionally skip JSON_UNQUOTE when on SQLite, or use a compatible alternative.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions