anchor.diff:                      _ ->
                           V
                   end,
  -                case lists:keyfind(A, 1, AttributeTypes) of
  -                    {A, AttrType} ->
  -                        [DBColumn ++ " = " ++ pack_typed_value(Value, AttrType)|Acc];
  -                    _ ->
  -                        [DBColumn ++ " = " ++ pack_value(Value)|Acc]
  -                end
  -        end, [], Record:attributes()),
  -    ["UPDATE ", TableName, " SET ", string:join(Updates, ", "),
  -        " WHERE ", IdColumn, " = ", pack_value(Id)].
  +                {[DBColumn|Attrs], [Value|Vals]}
  +        end, {[], []}, Record:attributes()),
  +    {Updates,_}=lists:mapfoldl(fun(E,Index)->{E++"=$"++integer_to_list(Index),1+Index} end,1,Attributes),
  +    {["UPDATE ", TableName, " SET ", string:join(Updates, ", "),
  +        " WHERE ", IdColumn, " = ", pack_value(Id)],Values}.
   
   build_select_query(Type, Conditions, Max, Skip, Sort, SortOrder) ->
       TableName = boss_record_lib:database_table(Type),
  
positive.code:                     false ->
                          V
                  end,
                  case lists:keyfind(A, 1, AttributeTypes) of
                      {A, AttrType} ->
                          {[DBColumn|Attrs], [pack_typed_value(Value, AttrType)|Vals]};
                      _ ->
                          {[DBColumn|Attrs], [pack_value(Value)|Vals]}
                  end
          end, {[], []}, Record:attributes()),
      ["INSERT INTO ", TableName, " (", 
          string:join(Attributes, ", "),
          ") values (",
          string:join(Values, ", "),
          ")",
          " RETURNING id"
      ].
  
  build_update_query(Record) ->
      {Type, TableName, IdColumn, Id} = boss_sql_lib:infer_type_from_id(Record:id()),
      AttributeColumns = Record:database_columns(),
      AttributeTypes = boss_record_lib:attribute_types(Type),
      Updates = lists:foldl(fun
              ({id, _}, Acc) -> Acc;
              ({A, V}, Acc) -> 
                  DBColumn = proplists:get_value(A, AttributeColumns),
                  Value = case {boss_sql_lib:is_foreign_key(Type, A), V =/= undefined} of
                      {true, true} ->
  
negative.code:         uuid -> Record:set(id, uuid:to_string(uuid:uuid4()));
          _ -> Record
  end.
  
  activate_record(Record, Metadata, Type) ->
      AttributeTypes = boss_record_lib:attribute_types(Type),
  