{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/25594","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/25594/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/25594/comments","events_url":"https://api.github.com/repos/rails/rails/issues/25594/events","html_url":"https://github.com/rails/rails/issues/25594","id":163160088,"number":25594,"title":"Postgres JSONB column is returned as string instead of hash in Rails 5 RC2","user":{"login":"drewhamlett","id":1056587,"avatar_url":"https://avatars.githubusercontent.com/u/1056587?v=3","gravatar_id":"","url":"https://api.github.com/users/drewhamlett","html_url":"https://github.com/drewhamlett","followers_url":"https://api.github.com/users/drewhamlett/followers","following_url":"https://api.github.com/users/drewhamlett/following{/other_user}","gists_url":"https://api.github.com/users/drewhamlett/gists{/gist_id}","starred_url":"https://api.github.com/users/drewhamlett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drewhamlett/subscriptions","organizations_url":"https://api.github.com/users/drewhamlett/orgs","repos_url":"https://api.github.com/users/drewhamlett/repos","events_url":"https://api.github.com/users/drewhamlett/events{/privacy}","received_events_url":"https://api.github.com/users/drewhamlett/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails/rails/labels/activerecord","name":"activerecord","color":"0b02e1"},{"url":"https://api.github.com/repos/rails/rails/labels/PostgreSQL","name":"PostgreSQL","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-06-30T13:03:01Z","updated_at":"2016-10-16T15:21:13Z","closed_at":"2016-07-01T12:08:36Z","body":"### Steps to reproduce\r\nRunning Rails 4.2.4.\r\nUpgraded to Rails 5 RC2\r\nDropped and recreated the database.\r\nAll tests that use JSONB column are failing because column is not being serialized into a hash anymore.  Coming back as a plain string.  I have been unable to find any information on the internet about this.  schema.rb file shows that the column is jsonb.\r\n\r\n## Edit\r\nI looked at this issue some more.  It seems that using quotes in the migration script allows the default value to be created in Postgres as a string.\r\n\r\nIn Rails 4 we had this.  Which allowed the column to be created in Postgres correctly without quotes.\r\n```rb\r\nclass CoolMigration < ActiveRecord::Migration\r\n  def change\r\n    add_column :businesses, :feature_flags, :jsonb, default: '{}'\r\n  end\r\nend\r\n```\r\nIf I run this same migration with Rails 5 it creates the default value in Postgres as \"{}\".  This causes Rails to serialize this out into a string.  If change the migration to \r\n\r\n```rb\r\nadd_column :businesses, :feature_flags, :jsonb, default: {}\r\n```\r\n\r\nEverything works fine\r\n\r\n### Expected behavior\r\nPostgres jsonb column should be serialized to hash\r\n\r\n### Actual behavior\r\nPostgres jsonb column comes back as a string\r\n\r\n### System configuration\r\n**Rails version**: 5.0.0.rc2\r\n\r\n**Ruby version**: 2.3.0\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/254053103","html_url":"https://github.com/rails/rails/issues/25594#issuecomment-254053103","issue_url":"https://api.github.com/repos/rails/rails/issues/25594","id":254053103,"user":{"login":"maclover7","id":3020626,"avatar_url":"https://avatars.githubusercontent.com/u/3020626?v=3","gravatar_id":"","url":"https://api.github.com/users/maclover7","html_url":"https://github.com/maclover7","followers_url":"https://api.github.com/users/maclover7/followers","following_url":"https://api.github.com/users/maclover7/following{/other_user}","gists_url":"https://api.github.com/users/maclover7/gists{/gist_id}","starred_url":"https://api.github.com/users/maclover7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maclover7/subscriptions","organizations_url":"https://api.github.com/users/maclover7/orgs","repos_url":"https://api.github.com/users/maclover7/repos","events_url":"https://api.github.com/users/maclover7/events{/privacy}","received_events_url":"https://api.github.com/users/maclover7/received_events","type":"User","site_admin":false},"created_at":"2016-10-16T15:21:13Z","updated_at":"2016-10-16T15:21:13Z","body":"@jerefrer Feel free to submit a PR updating the guide."}}
{"actor":{"display_login":"maclover7"}}