<commit_before>//
//  yas_db_relation.cpp
//

#include "yas_db_attribute.h"
#include "yas_db_relation.h"
#include "yas_db_sql_utils.h"

using namespace yas;

namespace yas::db {
static std::string const target_key = "target";
static std::string const many_key = "many";
}

db::relation::relation(relation_args args, std::string source)
    : name(std::move(args.name)),
      source(std::move(source)),
      target(std::move(args.target)),
      many(args.many),
      table("rel_" + this->source + "_" + this->name) {
}

std::string db::relation::sql_for_create() const {
    std::string id_sql = db::attribute::id_attribute().sql();
    std::string src_pk_id_sql = db::attribute{{db::src_pk_id_field, db::attribute_type::integer}}.sql();
    std::string src_obj_id_sql = db::attribute{{db::src_obj_id_field, db::attribute_type::integer}}.sql();
    std::string tgt_obj_id_sql = db::attribute{{db::tgt_obj_id_field, db::attribute_type::integer}}.sql();
    std::string save_id_sql = db::attribute{{db::save_id_field, db::attribute_type::integer}}.sql();

    return db::create_table_sql(this->table, {std::move(id_sql), std::move(src_pk_id_sql), std::move(src_obj_id_sql),
                                              std::move(tgt_obj_id_sql), std::move(save_id_sql)});
}

std::string db::relation::sql_for_insert() const {
    return db::insert_sql(this->table,
                          {db::src_pk_id_field, db::src_obj_id_field, db::tgt_obj_id_field, db::save_id_field});
}<commit_msg>update relation<commit_after>//
//  yas_db_relation.cpp
//

#include "yas_db_attribute.h"
#include "yas_db_relation.h"
#include "yas_db_sql_utils.h"

using namespace yas;

namespace yas::db {
static std::string const target_key = "target";
static std::string const many_key = "many";
}

db::relation::relation(relation_args args, std::string source)
    : name(std::move(args.name)),
      source(std::move(source)),
      target(std::move(args.target)),
      many(args.many),
      table("rel_" + this->source + "_" + this->name) {
    if (this->name.size() == 0) {
        throw std::invalid_argument("invalid name");
    }
}

std::string db::relation::sql_for_create() const {
    std::string id_sql = db::attribute::id_attribute().sql();
    std::string src_pk_id_sql = db::attribute{{db::src_pk_id_field, db::attribute_type::integer}}.sql();
    std::string src_obj_id_sql = db::attribute{{db::src_obj_id_field, db::attribute_type::integer}}.sql();
    std::string tgt_obj_id_sql = db::attribute{{db::tgt_obj_id_field, db::attribute_type::integer}}.sql();
    std::string save_id_sql = db::attribute{{db::save_id_field, db::attribute_type::integer}}.sql();

    return db::create_table_sql(this->table, {std::move(id_sql), std::move(src_pk_id_sql), std::move(src_obj_id_sql),
                                              std::move(tgt_obj_id_sql), std::move(save_id_sql)});
}

std::string db::relation::sql_for_insert() const {
    return db::insert_sql(this->table,
                          {db::src_pk_id_field, db::src_obj_id_field, db::tgt_obj_id_field, db::save_id_field});
}
{'fraction_non_alphanumeric': 0.17396949042518664, 'fraction_numerical': 0.0003245699448231094, 'mean_word_length': 4.804143126177024, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3587690', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1071, 'n_words': 151}