I'm trying to add a column of type JSON to one of my tables. I'm using XAMPP with phpmyadmin. The server version is 10.1.31-MariaDB. The innodb version is 5.6.36-83.0
When i try to select the JSON type from the select-box in phpmyadmin, i do not see anything about JSON. Also, running this query results in a "syntax error":
ALTER TABLE my_table
ADD `some_column` json;
I've seen both in the manual, and in various tutorials, that mysql indeed does support JSON type.
Is it a version issue? To be honest, i'm very confused about the whole mysql versioning situation. I see on Wikipedia, that the latest stable release is 8.0.11, whereas mine seems to be something completely different(i dont know which is relevant: the "server" or the "innodb" version) I would assume that XAMPP uses the latest mysql version, but maybe i'm wrong.
Can someone shed some light on the issue? If it is actually a version thing, would it be possible to upgrade, while still using XAMPP?
It seems that this data type is only available from MariaDB version 10.2.7. You can use LONGTEXT instead, because according to the docs JSON is only an alias for LONGTEXT.
https://mariadb.com/kb/en/library/json-data-type/
Yes, it's a version issue, see https://mariadb.com/kb/en/library/mariadb-vs-mysql-compatibility/
You're using MariaDB 10.1, which is based on MySQL 5.6/5.7 (hence the innodb version). But the JSON data type was added in MySQL 8.0. It looks like as of this time MariaDB doesn't support the JSON data type.
The JSON data type as added in version 5.7 and is improved in 8. MariaDB does not have a JSON data type
Related
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
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/
I have developed my website with 10.3.8-MariaDB and when I deployed the website to the SiteGround server, JSON fields gave an error. JSON fields support MySQL >= 5.7, however, SiteGround's MYSQL version is 5.6 . Now, I want to run code
ALTER TABLE courses
ADD slug_en VARCHAR(255) AS (JSON_DECODE(slug, '$.en'));
it gives me an error. How can I select JSON values or run this code in MYSQL? Thanks in advance!
contact your server and request for updating mySQL version; MySql above versions supports json field
i have been working with the JSON COLUMN_CREATE and COLUMN_JSON options in mariaDB. how do i update just one JSON column without having to extract the entire JSON column?
i see that mysql now has a JSON_SET option. is this something that mariaDB will add?
when i first switched over from mysql to mariaDB the documentation seemed to elude to mariaDB being a "drop-in" replacement for mysql.
also, i thought i read initially that if mysql comes out with a new feature, mariaDB will match the feature.
"drop-in replacement" = "marketing". However, it is mostly true.
You have ventured into a very new feature (JSON) of Oracle MySQL, for which MariaDB has not (yet) caught up. I cannot say when (or even 'if') it will catch up in this.
Meanwhile, MariaDB has added a number of features that have not (yet) been adopted by Oracle.
In sqlalchemy, I use classical mapping and autoload=True. I want to query data which is jsontype from postgresql.
D:\Python27\lib\site-packages\sqlalchemy\dialects\postgresql\base.py:1706: SAWarning: Did not recognize type 'json' of column 'comm_media_alias'name, format_type, default, notnull, domains, enums, schema)
how to deal with this problem
The JSON type in PostgreSQL is a relatively new data type in PostgreSQL, and thus SQLAlchemy has only recently added functionality to properly detect it. At the time of this question, SQLAlchemy would not be able to detect the "JSON" column type, as doing so relied on functionality that it did not yet support.
SQLAlchemy 0.9 was released on December 30th, 2013. This version contains support for the PostgreSQL JSON data type, so I would recommend upgrading to this version and trying again.
If you can't upgrade (or the upgrade still isn't working for you), you can also change your column type to something else (like TEXT).
Another thing to note about this is that it is not an error: it is a warning. I'm not sure what SQLAlchemy will actually try to do when it is working with the column that is a JSON type, but it might end up working anyway.
I'm trying to connect to an Informix database with SQLAlchemy. All my tests seem to show the connection is working; however, whenever I try and perform a read of the database I get the error:
DatabaseError: (DatabaseError) SQLCODE -217 in PREPARE:
IX000: Column (current_role) not found in any table in the query (or SLV is undefined).
'select CURRENT_ROLE from systables' ()
Now the database that I am connecting to doesn't have CURRENT_ROLE, so how can I get round this?
My interactive traceback of the error is shown below in a gist:
https://gist.github.com/2157378
The offending line is:
File "build/bdist.linux-i686/egg/sqlalchemy/dialects/informix/base.py", line 593, in _get_default_schema_name
return connection.execute('select CURRENT_ROLE from systables').scalar()
Is there any workaround for this problem?
I am now led to believe this is a bug in SQLAlchemy (after talking to users in #sqlalchemy) and I have filed a bug report:
http://www.sqlalchemy.org/trac/ticket/2448
You've not identified which version of IBM Informix Dynamic Server (IDS) you are using or which platform you are using it on, so it is hard to help you.
It appears that SQLAlchemy expects a more recent version of Informix than you are using. Somewhat to my surprise, the niladic function CURRENT_ROLE appears to be available in IDS 11.70 (tested on 11.70.FC4 on RHEL 5 for x86/64). It was not recently added, so it will be in any 11.70 version, and possibly in some earlier versions (but not as early as the version you are using).
I'm not sure how much of a bug it is in SQLAlchemy. If the version of Informix that you're using is really old, there is limited virtue in them adding support for it. You can find out which version you're using by running:
SELECT DBINFO('version', 'full')
FROM 'informix'.systables
WHERE tabid = 1;
If that doesn't work, you are many years out of date with your server.
Addendum
Thinking about it a bit more...I wonder what SQLAlchemy is going to do with the role. It probably shouldn't be trying to analyze whether you have permission; it should try an operation and deal with failures. That will be quicker, especially in the common case where you actually do have permission.
There could be two issues:
SQLAlchemy should be aware that some (as yet indeterminate) list of old versions of IDS do not support CURRENT_ROLE.
SQLAlchemy should review why it needs to be aware of the current role.