Skip to content

MySQL JSON Data Type #4727

Closed
Closed

Description

@nodecode

Activity

  1. added
    type: feature
    on Oct 25, 2015
  2. janmeier commented on Oct 26, 2015

    @janmeier
    Member

    Interesting definitely! :)

    It doesn't seem like 5.7 is supported on travis yet (I'd rather not have to fiddle around with a script that manually installs it), so thats the first hurdle

  3. camerondubas commented on Jan 29, 2016

    @camerondubas

    +1

  4. golya commented on Jan 30, 2016

    @golya

    +1

  5. gilo commented on Feb 12, 2016

    @gilo

    +1

  6. twilly86 commented on Mar 19, 2016

    @twilly86

    +1

  7. miralem commented on Mar 23, 2016

    @miralem

    +1

  8. tosone commented on Mar 25, 2016

    @tosone

    +1

  9. seanzx85 commented on Mar 30, 2016

    @seanzx85

    +1

  10. rromanw commented on Apr 7, 2016

    @rromanw

    +1

  11. saurabhverma2892 commented on Apr 18, 2016

    @saurabhverma2892

    +1

  12. ccg1415 commented on May 24, 2016

    @ccg1415

    +1

  13. Glavin001 commented on Jun 22, 2016

    @Glavin001

    Any progress on this? I would be interested in contributing, however I have yet to dive into Sequelize internals yet. Any pointers would be greatly appreciated! Thanks!

  14. janmeier commented on Jun 23, 2016

    @janmeier
    Member

    @Glavin001 Perhaps you can draw some inspiration from #4013, which added geometry support.

    Basically, you need to add some code to mysql/data-types, something like this https://github.com/sequelize/sequelize/blob/a89f0f818657fc289c97e7f433b3499d02e661b5/lib/dialects/postgres/data-types.js#L276-337. Parse handles converting data that comes from the DB to json, while stringify converts JSON to the format the db expects.

    If you have futher questions, ask them here, open the PR and we can discuss further, or join us on slack :)

  15. janmeier commented on Jun 23, 2016

    @janmeier
    Member

    One problem is that travis-ci doesn't support mysql 5.7 out of the box - But you could try using https://gist.github.com/BenMorel/d981f25ead0926a0cb6d to update the mysql version.

    If installing a new mysql version doesn't take too long, we might as well upgrade to the 14.04 image (which doesn't have mysql installed by default) - then we wouldn't have to manually upgrade gcc and clang https://github.com/sequelize/sequelize/blob/a89f0f818657fc289c97e7f433b3499d02e661b5/.travis.yml#L28-33

  16. 6 remaining items

  17. felixfbecker commented on Oct 25, 2016

    @felixfbecker
    Contributor

    Please don't +1 issues. It clutters the thread without adding value to the discussion and spams maintainers with notifications. Use GitHub reactions to upvote features.
    image

  18. insanehong commented on Nov 29, 2016

    @insanehong

    +1

  19. Rio517 commented on Nov 29, 2016

    @Rio517

    @insanehong Please read the comments above. Literally the last comment before yours reads:

    "Please don't +1 issues. It clutters the thread without adding value to the discussion and spams maintainers with notifications. Use GitHub reactions to upvote features."

  20. soulman-is-good commented on Feb 11, 2017

    @soulman-is-good

    @Rio517 @felixfbecker try adding reaction to an issue on mobile version. Maybe I blind or something but there is none.
    And just MHO but why not use github API for automation?
    https://developer.github.com/v3/issues/comments/

  21. seangrogg commented on Feb 22, 2017

    @seangrogg

    I decided to give it a whirl anyways and lo and behold using Sequelize.JSON as the datatype for a column works "well enough" in MySQL 5.7 - you're able to create the column with the appropriate data type, insert values, and update values.

    Two caveats:

    • I haven't tried but I would imagine you can't perform WHERE queries on them the same way you can in PostgreSQL
    • The results are currently returned as strings, so you'll have to JSON.parse to get the results back as a proper object/array

    While imperfect, it's more than useable for my use case. Cheers.

  22. toddsby commented on Mar 18, 2017

    @toddsby

    I needed arrays/objects from JSON datatypes for a project I'm working on.
    I found this: mysqljs/mysql#1267 (comment)
    Which lead me to implement it in a fork here: toddsby/sequelize@69f3297

    function parseJson( field, next ) {
      if ( field.type == 'JSON' ) {
        return ( JSON.parse( field.string() ) ); 
      }
      return next();
    }; 
    self.connection.query({ sql:self.sql, typeCast:parseJson }, function(err, results) {
    

    This won't give you full support for INSERT/UPDATE but works great for SELECT queries. You could extend this to support INSERT/UPDATE with queryFormat

  23. chrishutchinson commented on Apr 13, 2017

    @chrishutchinson

    Any progress on this lately?

    Edit: Just found #7106 🎉

  24. joeljuca commented on May 18, 2017

    @joeljuca

    +1! 🎉

  25. autaut03 commented on Jul 1, 2017

    @autaut03

    God two years passed and it still throws an error.

    Gonna switch to Laravel as soon as possible, I've never seen anything worse than JS and it's support....

  26. thujikun commented on Aug 18, 2017

    @thujikun

    Any progress?

  27. autaut03 commented on Aug 21, 2017

    @autaut03

    Why am I getting so much dislikes... I just told the truth and you're raging or what?

  28. Freezystem commented on Aug 21, 2017

    @Freezystem

    It's not the place to complain about "JS Support" or whatever that is suppose to mean. There is no such thing. This project is open source, if you want/need something done, you gotta do it yourself or help the others make it. Complaining is not helping. If you wanna switch to Laravel, cool for you, go on but this thread is not a social network, nobody cares of your tech choices.

  29. Shywim commented on Aug 21, 2017

    @Shywim

    I'd say I dislike the javascript ecosystem too, but coming here and saying this in a JS project repository is like screaming "HIT ME!", it is also irrelevant to this issue, and like any open source project you can:

    • Make the changes/additions yourself
    • Search for alternatives that do what you want
    • Patiently wait for someone to use their time to do something for free

    In any case, being respectful to other's work is a minimum, whether you appreciate it or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions