diff --git a/package-lock.json b/package-lock.json index 0bf8d84..ec3166a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,8 +70,7 @@ "@types/node": { "version": "8.0.53", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.53.tgz", - "integrity": "sha512-54Dm6NwYeiSQmRB1BLXKr5GELi0wFapR1npi8bnZhEcu84d/yQKqnwwXQ56hZ0RUbTG6L5nqDZaN3dgByQXQRQ==", - "dev": true + "integrity": "sha512-54Dm6NwYeiSQmRB1BLXKr5GELi0wFapR1npi8bnZhEcu84d/yQKqnwwXQ56hZ0RUbTG6L5nqDZaN3dgByQXQRQ==" }, "@types/oracledb": { "version": "1.11.34", @@ -530,56 +529,6 @@ "restore-cursor": "1.0.1" } }, - "cli-highlight": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/cli-highlight/-/cli-highlight-1.1.4.tgz", - "integrity": "sha1-5FWQwU+xjhOGXjiZ6CTFWSzCKSY=", - "requires": { - "chalk": "1.1.3", - "he": "1.1.1", - "highlight.js": "9.12.0", - "mz": "2.7.0", - "yargs": "4.8.1" - }, - "dependencies": { - "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", - "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wrap-ansi": "2.1.0" - } - }, - "window-size": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", - "integrity": "sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU=" - }, - "yargs": { - "version": "4.8.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", - "integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=", - "requires": { - "cliui": "3.2.0", - "decamelize": "1.2.0", - "get-caller-file": "1.0.2", - "lodash.assign": "4.2.0", - "os-locale": "1.4.0", - "read-pkg-up": "1.0.1", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "1.0.2", - "which-module": "1.0.0", - "window-size": "0.2.0", - "y18n": "3.2.1", - "yargs-parser": "2.4.1" - } - } - } - }, "cli-truncate": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-1.0.0.tgz", @@ -1058,6 +1007,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, "requires": { "path-exists": "2.1.0", "pinkie-promise": "2.0.1" @@ -1346,7 +1296,8 @@ "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=" + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true }, "highlight.js": { "version": "9.12.0", @@ -1582,7 +1533,8 @@ "is-utf8": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", - "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true }, "is-windows": { "version": "0.2.0", @@ -1821,6 +1773,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true, "requires": { "graceful-fs": "4.1.11", "parse-json": "2.2.0", @@ -1905,11 +1858,6 @@ "integrity": "sha1-+6HEUkwZ7ppfgTa0YJ8BfPTe1pI=", "dev": true }, - "lodash.assign": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", - "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=" - }, "lodash.escape": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/lodash.escape/-/lodash.escape-3.2.0.tgz", @@ -2457,14 +2405,6 @@ "resolved": "https://registry.npmjs.org/oracledb/-/oracledb-2.0.15.tgz", "integrity": "sha1-9+IBtp+ngjUIFV6fNKumXVdCbx0=" }, - "os-locale": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", - "requires": { - "lcid": "1.0.0" - } - }, "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", @@ -2513,10 +2453,19 @@ "error-ex": "1.3.1" } }, + "parse5": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", + "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", + "requires": { + "@types/node": "8.0.53" + } + }, "path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, "requires": { "pinkie-promise": "2.0.1" } @@ -2553,6 +2502,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true, "requires": { "graceful-fs": "4.1.11", "pify": "2.3.0", @@ -2646,12 +2596,14 @@ "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", - "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=", + "dev": true }, "pinkie-promise": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "dev": true, "requires": { "pinkie": "2.0.4" } @@ -2787,6 +2739,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, "requires": { "load-json-file": "1.1.0", "normalize-package-data": "2.3.8", @@ -2797,6 +2750,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true, "requires": { "find-up": "1.1.2", "read-pkg": "1.1.0" @@ -3211,6 +3165,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, "requires": { "is-utf8": "0.2.1" } @@ -3409,13 +3364,14 @@ "dev": true }, "typeorm": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.1.3.tgz", - "integrity": "sha512-5c+TMBuVqzet2LHrf5ZfkVaa7U89Vr8mlbSxONUQT+l4f+pvFcBHcWNOYFRN9bfrw+kKBGzCavTBYHbm3bmHSQ==", + "version": "0.2.0-alpha.13", + "resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.2.0-alpha.13.tgz", + "integrity": "sha512-xYSqRU0UF/O3ofXTSktzqrtFVwSze9knH2bucVoE+iC9tROq3ndlu9brLxY50jBLskVJpIJT73dHhpdpmqzhPA==", "requires": { "app-root-path": "2.0.1", "chalk": "2.3.0", - "cli-highlight": "1.1.4", + "cli-highlight": "1.2.3", + "debug": "3.1.0", "dotenv": "4.0.0", "glob": "7.1.2", "js-yaml": "3.8.4", @@ -3426,6 +3382,11 @@ "yargs": "9.0.1" }, "dependencies": { + "ansi-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" + }, "ansi-styles": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", @@ -3434,6 +3395,11 @@ "color-convert": "1.9.1" } }, + "camelcase": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", + "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" + }, "chalk": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", @@ -3444,11 +3410,148 @@ "supports-color": "4.5.0" } }, + "cli-highlight": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/cli-highlight/-/cli-highlight-1.2.3.tgz", + "integrity": "sha512-cmc4Y2kJuEpT2KZd9pgWWskpDMMfJu2roIcY1Ya/aIItufF5FKsV/NtA6vvdhSUllR8KJfvQDNmIcskU+MKLDg==", + "requires": { + "chalk": "2.3.0", + "highlight.js": "9.12.0", + "mz": "2.7.0", + "parse5": "3.0.3", + "yargs": "10.0.3" + }, + "dependencies": { + "yargs": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-10.0.3.tgz", + "integrity": "sha512-DqBpQ8NAUX4GyPP/ijDGHsJya4tYqLQrjPr95HNsr1YwL3+daCfvBwg7+gIC6IdJhR2kATh3hb61vjzMWEtjdw==", + "requires": { + "cliui": "3.2.0", + "decamelize": "1.2.0", + "find-up": "2.1.0", + "get-caller-file": "1.0.2", + "os-locale": "2.1.0", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "2.1.1", + "which-module": "2.0.0", + "y18n": "3.2.1", + "yargs-parser": "8.1.0" + } + } + } + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wrap-ansi": "2.1.0" + }, + "dependencies": { + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + } + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "execa": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", + "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "requires": { + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" + } + }, + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "requires": { + "locate-path": "2.0.0" + } + }, "has-flag": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "npm-run-path": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", + "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "requires": { + "path-key": "2.0.1" + } + }, + "os-locale": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", + "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", + "requires": { + "execa": "0.7.0", + "lcid": "1.0.0", + "mem": "1.1.0" + } + }, + "path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "2.0.0", + "strip-ansi": "4.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "strip-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", + "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "requires": { + "ansi-regex": "3.0.0" + } + } + } + }, "supports-color": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", @@ -3456,6 +3559,19 @@ "requires": { "has-flag": "2.0.0" } + }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, + "yargs-parser": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-8.1.0.tgz", + "integrity": "sha512-yP+6QqN8BmrgW2ggLtTbdrOyBNSI7zBa4IykmiV5R1wl1JWNxQvWhMfMdmzIYtKU7oP3OOInY/tl2ov3BDjnJQ==", + "requires": { + "camelcase": "4.1.0" + } } } }, @@ -3705,11 +3821,6 @@ "isexe": "2.0.0" } }, - "which-module": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", - "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=" - }, "widest-line": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-1.0.0.tgz", @@ -3979,22 +4090,6 @@ } } }, - "yargs-parser": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz", - "integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=", - "requires": { - "camelcase": "3.0.0", - "lodash.assign": "4.2.0" - }, - "dependencies": { - "camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" - } - } - }, "yn": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz", diff --git a/package.json b/package.json index 2dffad6..da0f0a4 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "oracledb": "^2.0.15", "pg": "^6.4.2", "reflect-metadata": "^0.1.10", - "typeorm": "^0.1.3", + "typeorm": "^0.2.0-alpha.13", "typescript": "^2.6.1", "yargs": "^9.0.1", "yn": "^2.0.0" diff --git a/test/integration/examples/sample2-one-to-one/entity/Post.ts b/test/integration/examples/sample2-one-to-one/entity/Post.ts index 7a8efe0..cec9818 100644 --- a/test/integration/examples/sample2-one-to-one/entity/Post.ts +++ b/test/integration/examples/sample2-one-to-one/entity/Post.ts @@ -1,10 +1,10 @@ -import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn,Index} from "typeorm"; -import {PostDetails} from "./PostDetails"; -import {PostCategory} from "./PostCategory"; -import {PostAuthor} from "./PostAuthor"; -import {PostInformation} from "./PostInformation"; -import {PostImage} from "./PostImage"; -import {PostMetadata} from "./PostMetadata"; +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn, Index } from "typeorm"; +import { PostDetails } from "./PostDetails"; +import { PostCategory } from "./PostCategory"; +import { PostAuthor } from "./PostAuthor"; +import { PostInformation } from "./PostInformation"; +import { PostImage } from "./PostImage"; +import { PostMetadata } from "./PostMetadata"; @Entity("Post") export class Post { @@ -20,9 +20,8 @@ export class Post { // post has relation with category, however inverse relation is not set (category does not have relation with post set) @OneToOne(type => PostCategory, { - cascadeInsert: true, - cascadeUpdate: true, - cascadeRemove: true + cascade: true, + onDelete: 'CASCADE' }) @JoinColumn() @Index({ unique: true }) @@ -31,7 +30,7 @@ export class Post { // post has relation with details. cascade inserts here means if new PostDetails instance will be set to this // relation it will be inserted automatically to the db when you save this Post entity @OneToOne(type => PostDetails, details => details.post, { - cascadeInsert: true + cascade: true }) @JoinColumn() @Index({ unique: true }) @@ -40,7 +39,7 @@ export class Post { // post has relation with details. cascade update here means if new PostDetail instance will be set to this relation // it will be inserted automatically to the db when you save this Post entity @OneToOne(type => PostImage, image => image.post, { - cascadeUpdate: true + cascade: true, }) @JoinColumn() @Index({ unique: true }) @@ -49,17 +48,16 @@ export class Post { // post has relation with details. cascade update here means if new PostDetail instance will be set to this relation // it will be inserted automatically to the db when you save this Post entity @OneToOne(type => PostMetadata, metadata => metadata.post, { - cascadeRemove: true + onDelete: 'CASCADE' }) @JoinColumn() @Index({ unique: true }) - metadata: PostMetadata|null; + metadata: PostMetadata | null; // post has relation with details. full cascades here @OneToOne(type => PostInformation, information => information.post, { - cascadeInsert: true, - cascadeUpdate: true, - cascadeRemove: true + cascade: true, + onDelete: 'CASCADE' }) @JoinColumn() @Index({ unique: true }) diff --git a/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts b/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts index ca47932..917af60 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostDetails.ts @@ -1,5 +1,5 @@ -import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm"; -import {Post} from "./Post"; +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm"; +import { Post } from "./Post"; @Entity("PostDetails") export class PostDetails { @@ -15,11 +15,10 @@ export class PostDetails { @Column() metadata: string; - + @OneToOne(type => Post, post => post.details, { - cascadeInsert: true, - cascadeUpdate: true, - cascadeRemove: true + // cascade: true, + onDelete: 'CASCADE' }) post: Post; diff --git a/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts b/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts index 60229c4..0673ca4 100644 --- a/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts +++ b/test/integration/examples/sample2-one-to-one/entity/PostInformation.ts @@ -1,5 +1,5 @@ -import {PrimaryGeneratedColumn, Column, Entity, OneToOne,JoinColumn} from "typeorm"; -import {Post} from "./Post"; +import { PrimaryGeneratedColumn, Column, Entity, OneToOne, JoinColumn } from "typeorm"; +import { Post } from "./Post"; @Entity("PostInformation") export class PostInformation { @@ -9,10 +9,8 @@ export class PostInformation { @Column() text: string; - - @OneToOne(type => Post, post => post.information, { - cascadeUpdate: true, - }) + + @OneToOne(type => Post, post => post.information) post: Post; } \ No newline at end of file diff --git a/test/integration/examples/sample3-many-to-one/entity/Post.ts b/test/integration/examples/sample3-many-to-one/entity/Post.ts index 89a3aa5..36b60ea 100644 --- a/test/integration/examples/sample3-many-to-one/entity/Post.ts +++ b/test/integration/examples/sample3-many-to-one/entity/Post.ts @@ -1,10 +1,10 @@ import { PrimaryGeneratedColumn, Column, Entity, OneToOne, OneToMany, ManyToOne, JoinColumn } from "typeorm"; -import {PostDetails} from "./PostDetails"; -import {PostCategory} from "./PostCategory"; -import {PostAuthor} from "./PostAuthor"; -import {PostInformation} from "./PostInformation"; -import {PostImage} from "./PostImage"; -import {PostMetadata} from "./PostMetadata"; +import { PostDetails } from "./PostDetails"; +import { PostCategory } from "./PostCategory"; +import { PostAuthor } from "./PostAuthor"; +import { PostInformation } from "./PostInformation"; +import { PostImage } from "./PostImage"; +import { PostMetadata } from "./PostMetadata"; @Entity("Post") export class Post { @@ -20,38 +20,36 @@ export class Post { // post has relation with category, however inverse relation is not set (category does not have relation with post set) @ManyToOne(type => PostCategory, { - cascadeInsert: true, - cascadeUpdate: true, - cascadeRemove: true + cascade: true, + onDelete: 'CASCADE' }) category: PostCategory; // post has relation with details. cascade inserts here means if new PostDetails instance will be set to this // relation it will be inserted automatically to the db when you save this Post entity @ManyToOne(type => PostDetails, details => details.posts, { - cascadeInsert: true + cascade: true, }) details: PostDetails; // post has relation with details. cascade update here means if new PostDetail instance will be set to this relation // it will be inserted automatically to the db when you save this Post entity @ManyToOne(type => PostImage, image => image.posts, { - cascadeUpdate: true + cascade: true, }) image: PostImage; // post has relation with details. cascade update here means if new PostDetail instance will be set to this relation // it will be inserted automatically to the db when you save this Post entity @ManyToOne(type => PostMetadata, metadata => metadata.posts, { - cascadeRemove: true + cascade: true, }) - metadata: PostMetadata|null; + metadata: PostMetadata | null; // post has relation with details. full cascades here @ManyToOne(type => PostInformation, information => information.posts, { - cascadeInsert: true, - cascadeUpdate: true, - cascadeRemove: true + cascade: true, + onDelete: 'CASCADE' }) information: PostInformation; diff --git a/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts b/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts index 0f96397..4cf9d2c 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostDetails.ts @@ -1,5 +1,5 @@ import { PrimaryGeneratedColumn, Column, Entity, OneToOne, OneToMany, ManyToOne, JoinColumn } from "typeorm"; -import {Post} from "./Post"; +import { Post } from "./Post"; @Entity("PostDetails") export class PostDetails { @@ -21,11 +21,8 @@ export class PostDetails { nullable: true }) metadata: string; - - @OneToMany(type => Post, post => post.details, { - cascadeInsert: true, - cascadeUpdate: true - }) + + @OneToMany(type => Post, post => post.details) posts: Post[]; } \ No newline at end of file diff --git a/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts b/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts index a2b9b20..def7ca5 100644 --- a/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts +++ b/test/integration/examples/sample3-many-to-one/entity/PostInformation.ts @@ -1,5 +1,5 @@ import { PrimaryGeneratedColumn, Column, Entity, OneToOne, OneToMany, ManyToOne, JoinColumn } from "typeorm"; -import {Post} from "./Post"; +import { Post } from "./Post"; @Entity("PostInformation") export class PostInformation { @@ -9,10 +9,8 @@ export class PostInformation { @Column() text: string; - - @OneToMany(type => Post, post => post.information, { - cascadeUpdate: true, - }) + + @OneToMany(type => Post, post => post.information) posts: Post[]; } \ No newline at end of file diff --git a/test/utils/EntityFileToJson.ts b/test/utils/EntityFileToJson.ts index 0d09b92..9ea6b4f 100644 --- a/test/utils/EntityFileToJson.ts +++ b/test/utils/EntityFileToJson.ts @@ -21,6 +21,7 @@ export class EntityFileToJson { // if (!x.endsWith('[]')) { // x = x + '[]'// can't distinguish OneTwoMany from OneToOne without indexes // } + x=x.trim(); return x; }); } else { @@ -243,6 +244,7 @@ export class EntityFileToJson { // if (!x.endsWith('[]')) { // x = x + '[]'// can't distinguish OneTwoMany from OneToOne without indexes // } + x=x.trim(); return x; }); diff --git a/test/utils/GeneralTestUtils.ts b/test/utils/GeneralTestUtils.ts index 37afee5..65e5fdb 100644 --- a/test/utils/GeneralTestUtils.ts +++ b/test/utils/GeneralTestUtils.ts @@ -200,12 +200,13 @@ export async function createOracleDBModels(filesOrgPath: string, resultsPath: st let connOpt: ConnectionOptions = { database: String(process.env.ORACLE_Database), + sid: String(process.env.ORACLE_Database), host: String(process.env.ORACLE_Host), password: String(process.env.ORACLE_Password), type: 'oracle', username: String(process.env.ORACLE_Username), port: Number(process.env.ORACLE_Port), - dropSchema: true, + // dropSchema: true, synchronize: true, entities: [path.resolve(filesOrgPath, '*.js')], }