New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a native JSON data type support in MySQL #21110
Conversation
1ed5819
to
44d7786
Compare
|
+1 |
@@ -2,32 +2,7 @@ module ActiveRecord | |||
module ConnectionAdapters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this whole file and use Type::Json
where we used OID::Json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OID::Json
is a base class of OID::Jsonb
.
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql/oid/jsonb.rb#L5
Do I need to change to class Jsonb < Type::Json
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, looks good.
Awesome! Just remove the OID class and we can merge it. |
c99c25d
to
ca1e4d3
Compare
Removed |
As of MySQL 5.7.8, MySQL supports a native JSON data type. Example: create_table :json_data_type do |t| t.json :settings end
ca1e4d3
to
89d5d1c
Compare
Add a native JSON data type support in MySQL
Several changes were made in #21110 which I am strongly opposed to. (this is what I get for going on vacation.) No type should be introduced into the generic `ActiveRecord::Type` namespace, and *certainly* should not be registered into the registry unconstrained unless it is supported by *all* adapters (which basically means that it was specified in the ANSI SQL standard). I do not think `# :nodoc:` ing the type is sufficient, as it still makes the code of Rails itself very unclear as to what the role of that class is. While I would argue that this shouldn't even be a super class, and that MySql and PG's JSON types are only superficially duplicated (they might look the same but will change for different reasons in the future). However, I don't feel strongly enough about it as a point of contention (and the biggest cost of harming the blameability has already occured), so I simply moved the superclass into a namespace where its role is absolutely clear. After this change, `attribute :foo, :json` will once again work with MySQL and PG, but not with Sqlite3 or any third party adapters. Unresolved questions -------------------- The types that and adapter publishes (at least those are unique to that adapter, and not adding additional behavior like `MysqlString` should probably be part of the adapter's public API. Should we standardize the namespace for these, and document them?
Thanks for adding this support!! Is this feature only available in the 5.x versions? |
Yes |
@sgrif are there any plans to add JSON support in 4.x branch? If not, would there be any interest in a PR that does that? |
No. Like stated in our maintenance policy, new features are no applied to
|
As of MySQL 5.7.8, MySQL supports a native JSON data type.
http://dev.mysql.com/doc/refman/5.7/en/json.html
Example: