Land #9912, Fix type validation in the notes add operation
commit
a1027d56c9
|
@ -1056,7 +1056,7 @@ class Db
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if types && types.size != 1
|
if types.nil? || types.size != 1
|
||||||
print_error("Exactly one type is required")
|
print_error("Exactly one type is required")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1078,12 +1078,12 @@ class Db
|
||||||
end
|
end
|
||||||
|
|
||||||
if mode == :update
|
if mode == :update
|
||||||
if types && types.size != 1
|
if !types.nil? && types.size != 1
|
||||||
print_error("Exactly one type is required")
|
print_error("Exactly one type is required")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if !types && !data
|
if types.nil? && data.nil?
|
||||||
print_error("Update requires data or type")
|
print_error("Update requires data or type")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1119,12 +1119,12 @@ class Db
|
||||||
if mode == :update
|
if mode == :update
|
||||||
begin
|
begin
|
||||||
update_opts = {id: note.id}
|
update_opts = {id: note.id}
|
||||||
if types
|
unless types.nil?
|
||||||
note.ntype = types.first
|
note.ntype = types.first
|
||||||
update_opts[:ntype] = types.first
|
update_opts[:ntype] = types.first
|
||||||
end
|
end
|
||||||
|
|
||||||
if data
|
unless data.nil?
|
||||||
note.data = data
|
note.data = data
|
||||||
update_opts[:data] = data
|
update_opts[:data] = data
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue