Skip to content

MySQL 5.7 JSON type support #3547

Closed
Closed

Description

@sqlalchemy-bot

Migrated issue, originally created by Mathieu Rodic

MySQL came up with an implementation of the JSON type : https://dev.mysql.com/doc/refman/5.7/en/json.html

It would be nice to have it available in sqlalchemy.dialects.mysql, in the same way its PostgreSQL counterpart can be imported from sqlalchemy.dialects.postgresql.

I wouldn't mind working on the implementation, if given the required elements (some exceptions are poorly documented, e.g.: sqlalchemy.exc.CompileError: (in table 'entities', column 'data'): Compiler <sqlalchemy.dialects.mysql.base.MySQLTypeCompiler object at 0x7f1fcd4a0d10> can't render element of type <class '__main__.JSON'> ).

Activity

  1. sqlalchemy-bot commented on Oct 2, 2015

    @sqlalchemy-bot
    CollaboratorAuthor

    Michael Bayer (@zzzeek) wrote:

    1.1 is tentative here but sure, the implementation is quite simple just imitate what you see at https://bitbucket.org/zzzeek/sqlalchemy/src/ac08920284935e7e7519ce77ba369703390155dc/lib/sqlalchemy/dialects/postgresql/json.py?at=master&fileviewer=file-view-default. However the PR must have tests in test/dialect/mysql/test_types.py, at least database round trip tests.

  2. sqlalchemy-bot commented on Oct 2, 2015

    @sqlalchemy-bot
    CollaboratorAuthor

    Changes by Michael Bayer (@zzzeek):

    • set milestone to "1.1"
  3. sqlalchemy-bot commented on Oct 5, 2015

    @sqlalchemy-bot
    CollaboratorAuthor

    Mathieu Rodic wrote:

    Woking on it ([see fork)(https://github.com/mathieurodic/sqlalchemy)):

    • will make a first push tomorrow, for now only the simplest access works (i.e., reading/writing/querying the whole field).
    • will work on the [] operator implementation, which can be tricky as MySQL implements it as a function.
  4. sqlalchemy-bot commented on Dec 1, 2015

    @sqlalchemy-bot
    CollaboratorAuthor

    Stephen Rauch (@stephenrauch) wrote:

    What is the status of this?

  5. sqlalchemy-bot commented on Dec 9, 2015

    @sqlalchemy-bot
    CollaboratorAuthor

    Stephen Rauch (@stephenrauch) wrote:

    Just pushed some code in support of this ticket.

    zzzeek/sqlalchemy#221

  6. sqlalchemy-bot commented on Dec 9, 2015

    @sqlalchemy-bot
    CollaboratorAuthor

    Michael Bayer (@zzzeek) wrote:

    that is impressive. i'll have to take a detailed look at it thanks!

  7. sqlalchemy-bot commented on Dec 28, 2015

    @sqlalchemy-bot
    CollaboratorAuthor

    Changes by Michael Bayer (@zzzeek):

    • added labels: high priority
  8. sqlalchemy-bot commented on Jan 6, 2016

    @sqlalchemy-bot
    CollaboratorAuthor

    Michael Bayer (@zzzeek) wrote:

    • Added :class:.mysql.JSON for MySQL 5.7. The JSON type provides
      persistence of JSON values in MySQL as well as basic operator support
      of "getitem" and "getpath", making use of the JSON_EXTRACT
      function in order to refer to individual paths in a JSON structure.
      fixes MySQL 5.7 JSON type support #3547
    • Added a new type to core :class:.types.JSON. This is the
      base of the PostgreSQL :class:.postgresql.JSON type as well as that
      of the new :class:.mysql.JSON type, so that a PG/MySQL-agnostic
      JSON column may be used. The type features basic index and path
      searching support.
      fixes base JSON type + unification across pg/mysql #3619
    • reorganization of migration docs etc. to try to refer both to
      the fixes to JSON that helps Postgresql while at the same time
      indicating these are new features of the new base JSON type.
    • a rework of the Array/Indexable system some more, moving things
      that are specific to Array out of Indexable.
    • new operators for JSON indexing added to core so that these can
      be compiled by the PG and MySQL dialects individually
    • rename sqltypes.Array to sqltypes.ARRAY - as there is no generic
      Array implementation, this is an uppercase type for now, consistent
      with the new sqltypes.JSON type that is also not a generic implementation.
      There may need to be some convention change to handle the case of
      datatypes that aren't generic, rely upon DB-native implementations,
      but aren't necessarily all named the same thing.

    → a80bb4e

  9. sqlalchemy-bot commented on Jan 6, 2016

    @sqlalchemy-bot
    CollaboratorAuthor

    Changes by Michael Bayer (@zzzeek):

    • changed status to closed
  10. added this to the 1.1 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions