           AND casttarget = secondary::regtype
         ;
     EXCEPTION WHEN no_data_found THEN
+      IF c_loose THEN
+        RETURN NULL;
+      END IF;
       RAISE 'cast from "%" to "%" does not exist', object_name, secondary
         USING ERRCODE = 'undefined_object'
       ;
+      IF c_loose THEN
+        RETURN NULL;
+      END IF;
     END;
     secondary = NULL;
 

  , object_name text
  , secondary text DEFAULT NULL
  , object_group_name _object_reference.object_group.object_group_name%TYPE DEFAULT NULL
$args$
  , 'int LANGUAGE sql'
  , $$SELECT object_reference.object__getsert( lower($1)::cat_tools.object_type, $2, $3, $4 )$$
  , 'Return a object_id for an object. Allows specifying a object group name to add the object to. See also object__getsert_w_group_id().'
  , 'object_reference__usage'
);

     * can have that regprocedure doesn't support.
     */
    -- TODO: allow this to parse object_name directly
    BEGIN
      v_objid := cat_tools.regprocedure(object_name, secondary);
    EXCEPTION WHEN undefined_function THEN
      IF c_loose THEN
        RETURN NULL;
      END IF;
      RAISE;
    END;
    secondary = NULL;

  -- Columns
  WHEN 'pg_catalog.pg_attribute'::regclass THEN
    v_objid := object_name::regclass;
    BEGIN
      -- Will throw error if column isn't valid
      v_subid := (cat_tools.pg_attribute__get(v_objid, secondary)).attnum;
    EXCEPTION WHEN undefined_column THEN
      IF c_loose THEN
        RETURN NULL;
      END IF;
      RAISE;
    END;
    secondary = NULL;

  -- Defaults
