anchor.diff:              ?Error("~p connection failed: ~p", [Op, Error]),
               Msg = list_to_binary(lists:flatten(io_lib:format("~p", [Error]))),
               {error, Msg};
  -        Conn ->
  -            Conn#ddConn{owner = get_name(DalSess, Conn#ddConn.owner)};
  +        #ddConn{} = SavedConn ->
  +            SavedConn#ddConn{owner = get_name(DalSess, SavedConn#ddConn.owner)};
           InvalidReturn ->
               ?Error("Invalid return on ~p connection ~p: The result:~n~p", [Op, Conn, InvalidReturn]),
  -            {error, <<"Invalid return saving the connection">>}
  +            {error, <<"Error saving the connection (Invalid value returned from DB)">>}
       end.
   
   -spec compare_connections(#ddConn{}, #ddConn{}) -> boolean().
  
positive.code:                 false ->
                      if
                          Owner =:= OldOwner -> %% Same owner update the connection.
                              check_save_conn(UserSess, DalSess, update, Conn);
                          true -> %% Different owner, create a copy.
                              add_connect_internal(UserSess, DalSess, Conn#ddConn{id = undefined})
                      end
  
negative.code: add_connect_internal(UserSess, DalSess, #ddConn{id = undefined, owner = Owner} = Conn) ->
      case UserSess:run_cmd(select, [ddConn, [{#ddConn{name='$1', owner='$2', id='$3', _='_'}
                                           , [{'=:=','$1',Conn#ddConn.name},{'=:=','$2',Owner}]
                                           , ['$_']}]]) of
          {[#ddConn{id = Id} = OldCon | _], true} ->
              %% User is updating is own connection no need for privileges
              NewCon = Conn#ddConn{id=Id},
              case compare_connections(OldCon, NewCon) of
                  true -> %% Connection not changed
                      Conn#ddConn{owner = get_name(DalSess, Conn#ddConn.owner)};
                  false ->
                      ?Info("replacing connection ~p, owner ~p", [NewCon, Owner]),
                      check_save_conn(UserSess, DalSess, update, {OldCon, NewCon})
              end;
          _ ->
              case UserSess:run_cmd(have_permission, [[manage_system, ?MANAGE_CONNS, ?CREATE_CONNS]]) of
                  true ->
  