anchor.diff:        ColumnDqls
       ), ",")
     ],
  -  emysql:prepare(insert_stmt, list_to_binary(Dql)),
  -  case execute(Dql, lists:append(ColumnValues, ColumnValues), State) of
  +  prepare(insert, Sql),
  +  case execute(insert, lists:append(ColumnValues, ColumnValues), State) of
       #ok_packet{insert_id = InsertId} ->
         % XXX TODO darle una vuelta mas de rosca
         % para el manejo general de cuando te devuelve el primary key
  
positive.code:     "SELECT * FROM ", escape(atom_to_list(DocName)),
      " WHERE ", string:join(Sqls, " AND ")
    ],
    Sql = case Limit of
      0 -> Sql1;
      _ -> [Sql1|[" LIMIT ", integer_to_list(Offset), ",", integer_to_list(Limit)]]
    end,
    case execute(Sql, Values, State) of
      #result_packet{rows = Rows, field_list = Fields} ->
        Docs = lists:foldl(
          fun(Row, DocList) ->
  
negative.code:     " WHERE ", escape(atom_to_list(sumo:field_name(sumo:get_id_field(DocName)))),
      "=? LIMIT 1"
    ],
    prepare(delete, Sql),
    case execute(delete, [Id], State) of
      #ok_packet{affected_rows = NumRows} -> {ok, NumRows > 0, State};
      Error -> evaluate_execute_result(Error, State)
    end.
  
  delete_all(DocName, State) ->
    Sql = ["DELETE FROM ", escape(atom_to_list(DocName))],
    prepare(delete_all, Sql),
    case execute(delete_all, State) of
      #ok_packet{affected_rows = NumRows} -> {ok, NumRows, State};
      Error -> evaluate_execute_result(Error, State)
    end.
  