<commit_before>require 'database_switcher'
class ActiveRecord::Base
  def save_to database = 'test'
    old = ActiveRecord::Base.connection.connection_options[3]
    switch_database database
    if self.class.find_by_id(self.id).nil?
      r = self.clone
      r.id = self.id
      r.save
    end
    switch_database old
  end
end
<commit_msg>Un peu de modélisation des associations Test manquant Programmer en C Généralisation de switch_database<commit_after>require 'database_switcher'
class ActiveRecord::Base
  def save_to database = 'test'
    old = ActiveRecord::Base.connection.connection_options[3]
    switch_database database
    if self.class.send("find_by_#{self.class.primary_key}", self.id).nil?
      r = self.clone
      r.id = self.id
      r.save
    end
    switch_database old
  end
end

{'fraction_non_alphanumeric': 0.08163265306122448, 'fraction_numerical': 0.0024009603841536613, 'mean_word_length': 3.1083743842364533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7463554', 'n_tokens_mistral': 272, 'n_tokens_neox': 259, 'n_words': 62}