anchor.diff:  escape_sql1([C|Rest], Acc) ->
       escape_sql1(Rest, [C|Acc]).
   
  -pack_typed_value(Val, date) ->
  -    pack_date(Val);
  -pack_typed_value(Val, timestamp) ->
  -    pack_now(Val);
  -pack_typed_value(Val, _) ->
  -    pack_value(Val).
  -
  -pack_date({Y, M, D}) ->
  -    io_lib:format("'~p-~p-~p'", [Y, M, D]).
  -
   pack_datetime({Date, {Y, M, S}}) when is_float(S) ->
       pack_datetime({Date, {Y, M, erlang:round(S)}});
   pack_datetime(DateTime) ->
  
positive.code:     Type = element(1, Record),
      TableName = boss_record_lib:database_table(Type),
      AttributeColumns = Record:database_columns(),
      AttributeTypes = boss_record_lib:attribute_types(Type),
      {Attributes, Values} = lists:foldl(fun
              ({_, undefined}, Acc) -> Acc;
              ({'id', 'id'}, Acc) -> Acc;
              ({'id', V}, {Attrs, Vals}) -> 
                  DBColumn = proplists:get_value('id', AttributeColumns),
                  {_, _, _, TableId} = boss_sql_lib:infer_type_from_id(V),
                  {[DBColumn|Attrs], [pack_value(TableId)|Vals]};
              ({A, V}, {Attrs, Vals}) ->
                  DBColumn = proplists:get_value(A, AttributeColumns),
                  Value = case boss_sql_lib:is_foreign_key(Type, A) of
  
negative.code:         id ->
              Record1 = maybe_populate_id_value(Record),
              Type = element(1, Record1),
              {Query,Params} = build_insert_query(Record1),
              Res = pgsql:equery(Conn, Query, Params),
              case Res of
                  {ok, _, _, [{Id}]} ->
                      {ok, Record1:set(id, lists:concat([Type, "-", id_value_to_string(Id)]))};
                  {error, Reason} -> {error, Reason}
              end;
          Defined when is_list(Defined) ->
              {Query,Params} = build_update_query(Record),
              Res = pgsql:equery(Conn, Query, Params),
              case Res of
                  {ok, _} -> {ok, Record};
                  {error, Reason} -> {error, Reason}
              end
      end.
  
  push(Conn, Depth) ->
      case Depth of 0 -> pgsql:squery(Conn, "BEGIN"); _ -> ok end,
  