Skip to content

[2.x] Cast as JSON not possible #4109

@luceos

Description

@luceos

Current Behavior

I receive this error when migrating:

  SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that
   corresponds to your MariaDB server version for the right syntax to use near 'JSON)' at line 1 (Connection: flarum,
   SQL: update `users` set `preferences_json` = CAST(CONVERT(`preferences` USING utf8mb4) AS JSON))

It originates from: framework/framework/core/migrations/2024_05_05_000001_convert_preferences_to_json_in_users.php

I tried investigating why CAST as JSON doesn't work, but it seems MariaDB does not support this at all? https://mariadb.com/kb/en/cast/

Steps to Reproduce

.

Expected Behavior

.

Screenshots

No response

Environment

  • Flarum version: 2.x
  • MariaDB, (from docker image mariadb:10)
# mysql --version
mysql  Ver 15.1 Distrib 10.8.3-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper
  • Hosting environment: dev
  • PHP version:
PHP 8.2.18 (cli) (built: Apr 24 2024 09:17:43) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.18, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.18, Copyright (c), by Zend Technologies

Output of php flarum info

Flarum core: 2.0-dev
PHP version: 8.2.18
MySQL version: 10.8.3-MariaDB-1:10.8.3+maria~jammy
Loaded extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, ctype, curl, dom, fileinfo, filter, hash, iconv, json, mbstring, SPL, session, PDO, pdo_sqlite, standard, posix, random, readline, Reflection, Phar, SimpleXML, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, apcu, apfd, bcmath, calendar, exif, gd, gettext, gmp, imap, intl, ldap, mysqli, pcntl, pdo_mysql, redis, sockets, sodium, sysvmsg, tidy, timezonedb, xsl, yaml, zip, Zend OPcache
+-------------------+----------+--------+
| Flarum Extension  |          |        |
+-------------------+----------+--------+
| ID                | Version  | Commit |
+-------------------+----------+--------+
| flarum-likes      | 0.0      |        |
| flarum-federation | dev-main |        |
+-------------------+----------+--------+
Base URL: http://flarum-v2.test
Installation path: /var/www
Queue driver: sync
Session driver: file
Mail driver: mail
Debug mode: ON

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions