-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Server version:               10.5.4-MariaDB - mariadb.org binary distribution
-- Server OS:                    Win64
-- HeidiSQL Version:             11.0.0.6099
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

-- Dumping structure for table test.utferror
CREATE TABLE IF NOT EXISTS `utferror` (
  `txtField` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL,
  `bitField` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Dumping data for table test.utferror: ~0 rows (approximately)
/*!40000 ALTER TABLE `utferror` DISABLE KEYS */;
INSERT INTO `utferror` (`txtField`, `bitField`) VALUES
	('abc😁', b'0'),
	('😁def', b'1');
/*!40000 ALTER TABLE `utferror` ENABLE KEYS */;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;

SELECT JSON_ARRAYAGG(JSON_ARRAY(txtField)) FROM `utferror`; -- works fine

SELECT JSON_ARRAYAGG(JSON_ARRAY(txtField, bitField)) FROM `utferror`; -- enconding error

SELECT JSON_ARRAYAGG(JSON_ARRAY(txtField, CONVERT(bitField USING UTF8MB4))) FROM `utferror`; -- works