<commit_before>import { EntityInfo } from "../models/EntityInfo";
import { DatabaseModel } from "../models/DatabaseModel";
import * as TomgUtils from "../Utils";
import { RelationInfo } from "../models/RelationInfo";
import { ColumnInfo } from "../models/ColumnInfo";
import {
    WithWidthColumnType,
    WithPrecisionColumnType,
    WithLengthColumnType
} from "typeorm/driver/types/ColumnTypes";
import { AbstractNamingStrategy } from "../AbstractNamingStrategy";

export abstract class AbstractDriver {
    changeColumnNames(dbModel: DatabaseModel) {
        dbModel.entities.forEach(entity => {
            entity.Columns.forEach(column => {
                let newName = this.namingStrategy.columnName(column.tsName);
                entity.Indexes.forEach(index => {
                    index.columns
                        .filter(column2 => {
                            return column2.name == column.tsName;
                        })
                        .forEach(column2 => {
                            column2.name = newName;
                        });
                });
                dbModel.entities.forEach(entity2 => {
                    entity2.Columns.forEach(column2 => {
                        column2.relations
                            .filter(relation => {
                                return (
                                    relation.relatedTable ==
                                        entity.EntityName &&
                                    relation.relatedColumn == column.tsName
                                );
                            })
                            .map(v => {
                                v.relatedColumn = newName;
                            });
                        column2.relations
                            .filter(relation => {
                                return (
                                    relation.ownerTable == entity.EntityName &&
                                    relation.ownerColumn == column.tsName
                                );
                            })
                            .map(v => {
                                v.ownerColumn = newName;
                            });
                    });
                });

                column.tsName = newName;
            });
        });
    }
    changeEntityNames(dbModel: DatabaseModel) {
        dbModel.entities.forEach(entity => {
            let newName = this.namingStrategy.columnName(entity.EntityName);
            dbModel.entities.forEach(entity2 => {
                entity2.Columns.forEach(column => {
                    column.relations.forEach(relation => {
                        if (relation.ownerTable == entity.EntityName)
                            relation.ownerTable = newName;<commit_msg>fix namingStrategy for entity name<commit_after>import { EntityInfo } from "../models/EntityInfo";
import { DatabaseModel } from "../models/DatabaseModel";
import * as TomgUtils from "../Utils";
import { RelationInfo } from "../models/RelationInfo";
import { ColumnInfo } from "../models/ColumnInfo";
import {
    WithWidthColumnType,
    WithPrecisionColumnType,
    WithLengthColumnType
} from "typeorm/driver/types/ColumnTypes";
import { AbstractNamingStrategy } from "../AbstractNamingStrategy";

export abstract class AbstractDriver {
    changeColumnNames(dbModel: DatabaseModel) {
        dbModel.entities.forEach(entity => {
            entity.Columns.forEach(column => {
                let newName = this.namingStrategy.columnName(column.tsName);
                entity.Indexes.forEach(index => {
                    index.columns
                        .filter(column2 => {
                            return column2.name == column.tsName;
                        })
                        .forEach(column2 => {
                            column2.name = newName;
                        });
                });
                dbModel.entities.forEach(entity2 => {
                    entity2.Columns.forEach(column2 => {
                        column2.relations
                            .filter(relation => {
                                return (
                                    relation.relatedTable ==
                                        entity.EntityName &&
                                    relation.relatedColumn == column.tsName
                                );
                            })
                            .map(v => {
                                v.relatedColumn = newName;
                            });
                        column2.relations
                            .filter(relation => {
                                return (
                                    relation.ownerTable == entity.EntityName &&
                                    relation.ownerColumn == column.tsName
                                );
                            })
                            .map(v => {
                                v.ownerColumn = newName;
                            });
                    });
                });

                column.tsName = newName;
            });
        });
    }
    changeEntityNames(dbModel: DatabaseModel) {
        dbModel.entities.forEach(entity => {
            let newName = this.namingStrategy.entityName(entity.EntityName);
            dbModel.entities.forEach(entity2 => {
                entity2.Columns.forEach(column => {
                    column.relations.forEach(relation => {
                        if (relation.ownerTable == entity.EntityName)
                            relation.ownerTable = newName;
{'fraction_non_alphanumeric': 0.09131284419968022, 'fraction_numerical': 0.003908331852904601, 'mean_word_length': 1.03322499097147, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2463870', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1152, 'n_words': 181}