2

i try to build an function which returns a json.

I updated my mysql Workbench to 8.0.14 and tried the following code:

 SELECT JSON_OBJECT(
  'name_field', name_field,
  'address_field', address_field,
  'contact_age', contact_age
)
FROM contact;

But the following error appears:

Error Code: 1305. FUNCTION datalog.json_object does not exist

I thought that json_object is a standard mysql function, ins't it?

See here: JSON Object

4
  • Updating the Workbench app to 8 doesn't mean your MySQL server is at 8. What does SELECT VERSION(); output? Commented Jan 30, 2019 at 21:13
  • Hi Ceejayoz, select version(); gives me: "10.1.35-MariaDB " Commented Jan 31, 2019 at 6:55
  • Then you're not using MySQL 8.0. Commented Jan 31, 2019 at 14:31
  • Thank you so much. I downloaded mariadb and it works. You helped me a lot! Commented Feb 1, 2019 at 9:13

1 Answer 1

5

You're using MariaDB, not MySQL, and your version (MariaDB 10.1) is roughly comparable to MySQL 5.7, with some important differences. Your Workbench version is irrelevant - it's the server version that matters.

https://mariadb.com/kb/en/library/mariadb-vs-mysql-compatibility/

MariaDB 10.1 and above does not support MySQL 5.7's packed JSON objects. MariaDB follows the SQL standard and stores the JSON as a normal TEXT/BLOB. If you want to replicate JSON columns from MySQL to MariaDB, you should store JSON objects in MySQL in a TEXT column or use statement based replication. If you are using JSON columns and want to upgrade to MariaDB, you can either convert the JSON columns to TEXT or use mysqldump to copy these tables to MariaDB. In MySQL, JSON is compared according to json values. In MariaDB JSON strings are normal strings and compared as strings.

MariaDB 10.2.3 adds JSON_OBJECT support. https://mariadb.com/kb/en/library/json_object/

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much. I downloaded mariadb and it works. You helped me a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.