anchor.diff:    end.
   
   delete(DocName, Id, State) ->
  -  Sql = "DELETE FROM `" ++ atom_to_list(DocName)
  -    ++ "` WHERE `" ++ atom_to_list(sumo:field_name(sumo:get_id_field(DocName)))
  -    ++ "`=? LIMIT 1",
  +  Sql = [
  +    "DELETE FROM ", escape(atom_to_list(DocName)),
  +    " WHERE ", escape(atom_to_list(sumo:field_name(sumo:get_id_field(DocName)))),
  +    "=? LIMIT 1"
  +  ],
     case execute(Sql, [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 `" ++ atom_to_list(DocName) ++ "`",
  +  Sql = ["DELETE FROM ", escape(atom_to_list(DocName))],
     case execute(Sql, State) of
       #ok_packet{affected_rows = NumRows} -> {ok, NumRows, State};
       Error -> evaluate_execute_result(Error, State)
  
positive.code:   find_all(DocName, undefined, 0, 0, State).
  
  find_all(DocName, OrderField, Limit, Offset, State) ->
    Sql0 =
      ["SELECT * FROM `", atom_to_list(DocName), "` "],
    Sql1 =
      case OrderField of
        undefined ->
          Sql0;
        _ ->
          [Sql0, " ORDER BY `", atom_to_list(OrderField), "` "]
      end,
    Sql2 =
      case Limit of
  
negative.code:     fun(T) -> length(T) > 0 end,
      lists:map(fun create_index/1, Fields)
    ),
    Dql = [
      "CREATE TABLE IF NOT EXISTS ", escape(atom_to_list(Name)), " (",
      string:join(FieldsDql, ","), ",", string:join(Indexes, ","),
      ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8"
    ],
    case execute(Dql, State) of
      #ok_packet{} -> {ok, State};
      Error -> evaluate_execute_result(Error, State)
    end.
  
  create_column(#sumo_field{name=Name, type=integer, attrs=Attrs}) ->
    [escape(atom_to_list(Name)), " INT(11) ", create_column_options(Attrs)];
  
  create_column(#sumo_field{name=Name, type=float, attrs=Attrs}) ->
    [escape(atom_to_list(Name)), " FLOAT ", create_column_options(Attrs)];
  
  create_column(#sumo_field{name=Name, type=text, attrs=Attrs}) ->
    [escape(atom_to_list(Name)), " TEXT ", create_column_options(Attrs)];
  
  create_column(#sumo_field{name=Name, type=binary, attrs=Attrs}) ->
    [escape(atom_to_list(Name)), " BLOB ", create_column_options(Attrs)];
  
  create_column(#sumo_field{name=Name, type=string, attrs=Attrs}) ->
    [escape(atom_to_list(Name)), " VARCHAR ", create_column_options(Attrs)];
  
  create_column(#sumo_field{name=Name, type=date, attrs=Attrs}) ->
    [escape(atom_to_list(Name)), " DATE ", create_column_options(Attrs)];
  
  create_column(#sumo_field{name=Name, type=datetime, attrs=Attrs}) ->
    [escape(atom_to_list(Name)), " DATETIME ", create_column_options(Attrs)].
  
  create_column_options(Attrs) ->
    lists:filter(fun(T) -> is_list(T) end, lists:map(
  