14873: Custom JSON attributes that default to [] or {} when nil.
[arvados.git] / services / api / app / models / node.rb
index 3d8b91b4b62df590edd2c1049a5ea69e17224bef..148dffc23074138af0d70008e2cc49dd8b344ca1 100644 (file)
@@ -8,8 +8,12 @@ class Node < ArvadosModel
   include HasUuid
   include KindAndEtag
   include CommonApiTemplate
-  serialize :info, Hash
-  serialize :properties, Hash
+
+  # Posgresql JSONB columns should NOT be declared as serialized, Rails 5
+  # already know how to properly treat them.
+  attribute :properties, :jsonbHash, default: {}
+  attribute :info, :jsonbHash, default: {}
+
   before_validation :ensure_ping_secret
   after_update :dns_server_update