[ARVADOS] updated: 1.3.0-2370-g8ba91a555
Git user
git at public.arvados.org
Mon Mar 23 15:28:08 UTC 2020
Summary of changes:
services/api/app/controllers/application_controller.rb | 14 +++++++++++---
.../api/app/controllers/arvados/v1/users_controller.rb | 2 +-
.../test/functional/arvados/v1/users_controller_test.rb | 1 +
3 files changed, 13 insertions(+), 4 deletions(-)
via 8ba91a5558a9fbb743c726a7e38f7e7dcd7bf8ee (commit)
from d45255b6af1ce80d640ecdb21c0af7aa0b95370f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 8ba91a5558a9fbb743c726a7e38f7e7dcd7bf8ee
Author: Lucas Di Pentima <lucas at di-pentima.com.ar>
Date: Mon Mar 23 12:27:18 2020 -0300
16263: Adds nullify behavior to users's batch_update endpoint.
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at di-pentima.com.ar>
diff --git a/services/api/app/controllers/application_controller.rb b/services/api/app/controllers/application_controller.rb
index fbf177b01..7b82cdb61 100644
--- a/services/api/app/controllers/application_controller.rb
+++ b/services/api/app/controllers/application_controller.rb
@@ -486,12 +486,20 @@ class ApplicationController < ActionController::Base
# Go code may send empty values (ie: empty string instead of NULL) that
# should be translated to NULL on the database.
def set_nullable_attrs_to_null
- (resource_attrs.keys & nullable_attributes).each do |attr|
- val = resource_attrs[attr]
+ nullify_attrs(resource_attrs.to_hash).each do |k, v|
+ resource_attrs[k] = v
+ end
+ end
+
+ def nullify_attrs(a = {})
+ new_attrs = a.to_hash.symbolize_keys
+ (new_attrs.keys & nullable_attributes).each do |attr|
+ val = new_attrs[attr]
if (val.class == Integer && val == 0) || (val.class == String && val == "")
- resource_attrs[attr] = nil
+ new_attrs[attr] = nil
end
end
+ return new_attrs
end
def reload_object_before_update
diff --git a/services/api/app/controllers/arvados/v1/users_controller.rb b/services/api/app/controllers/arvados/v1/users_controller.rb
index 59c9f3948..289e82567 100644
--- a/services/api/app/controllers/arvados/v1/users_controller.rb
+++ b/services/api/app/controllers/arvados/v1/users_controller.rb
@@ -22,7 +22,7 @@ class Arvados::V1::UsersController < ApplicationController
rescue ActiveRecord::RecordNotUnique
retry
end
- u.update_attributes!(attrs)
+ u.update_attributes!(nullify_attrs(attrs))
@objects << u
end
@offset = 0
diff --git a/services/api/test/functional/arvados/v1/users_controller_test.rb b/services/api/test/functional/arvados/v1/users_controller_test.rb
index b38f0d52f..817a1c9ef 100644
--- a/services/api/test/functional/arvados/v1/users_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/users_controller_test.rb
@@ -1057,6 +1057,7 @@ class Arvados::V1::UsersControllerTest < ActionController::TestCase
newuuid => {
'first_name' => 'noot',
'email' => 'root at remot.example.com',
+ 'username' => '',
},
}})
assert_response(:success)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list