make one more test pass
This commit is contained in:
parent
74ace5f7a6
commit
24fe4cf48c
@ -145,22 +145,21 @@ export function modelCustomizationPhase(
|
||||
namingStrategy = new NamingStrategy();
|
||||
}
|
||||
let retVal = setRelationId(generationOptions, dbModel);
|
||||
// TODO:
|
||||
retVal = applyNamingStrategy(namingStrategy, retVal);
|
||||
retVal = addImportsAndGenerationOptions(retVal, generationOptions);
|
||||
// retVal = removeColumnDefaultProperties(retVal, defaultValues);
|
||||
retVal = removeColumnDefaultProperties(retVal, defaultValues);
|
||||
return retVal;
|
||||
}
|
||||
function removeColumnDefaultProperties(
|
||||
dbModel: EntityInfo[],
|
||||
dbModel: Entity[],
|
||||
defaultValues: DataTypeDefaults
|
||||
) {
|
||||
if (!defaultValues) {
|
||||
return dbModel;
|
||||
}
|
||||
dbModel.forEach(entity => {
|
||||
entity.Columns.forEach(column => {
|
||||
const defVal = defaultValues[column.options.type as any];
|
||||
entity.columns.forEach(column => {
|
||||
const defVal = defaultValues[column.tscType as any];
|
||||
if (defVal) {
|
||||
if (
|
||||
column.options.length &&
|
||||
|
@ -83,14 +83,25 @@ export default abstract class AbstractDriver {
|
||||
let retVal = dbModel;
|
||||
const manyToManyEntities = retVal.filter(
|
||||
entity =>
|
||||
entity.columns.length ===
|
||||
entity.columns.filter(c => c.primary).length &&
|
||||
entity.relations.length === 2 &&
|
||||
entity.relations.every(
|
||||
v => v.relationOptions && v.relationType !== "ManyToMany"
|
||||
v => v.joinColumnOptions && v.relationType !== "ManyToMany"
|
||||
) &&
|
||||
entity.relations[0].relatedTable !==
|
||||
entity.relations[1].relatedTable
|
||||
entity.relations[1].relatedTable &&
|
||||
entity.columns.length ===
|
||||
entity.columns.filter(c => c.primary).length &&
|
||||
entity.columns
|
||||
.map(v => v.tscName)
|
||||
.filter(
|
||||
v =>
|
||||
!entity.relations[0]
|
||||
.joinColumnOptions!.map(x => x.name)
|
||||
.some(jc => jc === v) &&
|
||||
!entity.relations[1]
|
||||
.joinColumnOptions!.map(x => x.name)
|
||||
.some(jc => jc === v)
|
||||
).length === 0
|
||||
);
|
||||
manyToManyEntities.forEach(junctionEntity => {
|
||||
const firstEntity = dbModel.find(
|
||||
|
@ -1,8 +1,14 @@
|
||||
import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn, Index } from "typeorm";
|
||||
import {
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
Entity,
|
||||
OneToOne,
|
||||
JoinColumn,
|
||||
Index
|
||||
} from "typeorm";
|
||||
|
||||
@Entity("EverythingEntity")
|
||||
export class EverythingEntity {
|
||||
//TODO: change to check column types per database engine
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@ -68,5 +74,4 @@ export class EverythingEntity {
|
||||
|
||||
// @UpdateDateColumn()
|
||||
// updatedDate: Date;
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
modelGenerationPhase
|
||||
} from "../../src/Engine";
|
||||
import * as GTU from "../utils/GeneralTestUtils";
|
||||
import EntityInfo from "../../src/oldModels/EntityInfo";
|
||||
import { Entity } from "../../src/models/Entity";
|
||||
import IConnectionOptions from "../../src/IConnectionOptions";
|
||||
|
||||
import fs = require("fs-extra");
|
||||
@ -17,7 +17,6 @@ import path = require("path");
|
||||
import chaiSubset = require("chai-subset");
|
||||
import chai = require("chai");
|
||||
import yn = require("yn");
|
||||
import { Entity } from "../../src/models/Entity";
|
||||
|
||||
require("dotenv").config();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user