flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.39k stars 834 forks source link

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

Closed luceos closed 1 week ago

luceos commented 1 week ago

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

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