mirror of
https://github.com/typeorm/typeorm.git
synced 2025-12-08 21:26:23 +00:00
chore: update prettier to v3 (#11702)
This commit is contained in:
parent
b1680a04ac
commit
ea7a99a3c3
@ -1,5 +1,3 @@
|
||||
{
|
||||
"arrowParens": "always",
|
||||
"semi": false,
|
||||
"trailingComma": "all"
|
||||
"semi": false
|
||||
}
|
||||
|
||||
12
package-lock.json
generated
12
package-lock.json
generated
@ -75,7 +75,7 @@
|
||||
"pg": "^8.16.3",
|
||||
"pg-query-stream": "^4.10.3",
|
||||
"pkg-pr-new": "^0.0.60",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier": "^3.6.2",
|
||||
"redis": "^5.8.2",
|
||||
"remap-istanbul": "^0.13.0",
|
||||
"sinon": "^21.0.0",
|
||||
@ -13256,16 +13256,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/prettier": {
|
||||
"version": "2.8.8",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz",
|
||||
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz",
|
||||
"integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"prettier": "bin-prettier.js"
|
||||
"prettier": "bin/prettier.cjs"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
"node": ">=14"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/prettier/prettier?sponsor=1"
|
||||
|
||||
@ -155,7 +155,7 @@
|
||||
"pg": "^8.16.3",
|
||||
"pg-query-stream": "^4.10.3",
|
||||
"pkg-pr-new": "^0.0.60",
|
||||
"prettier": "^2.8.8",
|
||||
"prettier": "^3.6.2",
|
||||
"redis": "^5.8.2",
|
||||
"remap-istanbul": "^0.13.0",
|
||||
"sinon": "^21.0.0",
|
||||
|
||||
@ -8,20 +8,26 @@ import { Image } from "./entity/Image"
|
||||
// NOTE: this example is not working yet, only concepts of how this feature must work described here
|
||||
|
||||
const PostEntity = new EntitySchema<Post>(
|
||||
require(__dirname +
|
||||
"/../../../../sample/sample24-schemas/schemas/post.json"),
|
||||
require(
|
||||
__dirname + "/../../../../sample/sample24-schemas/schemas/post.json",
|
||||
),
|
||||
)
|
||||
const PostDetailsEntity = new EntitySchema<PostDetails>(
|
||||
require(__dirname +
|
||||
"/../../../../sample/sample24-schemas/schemas/post-details.json"),
|
||||
require(
|
||||
__dirname +
|
||||
"/../../../../sample/sample24-schemas/schemas/post-details.json",
|
||||
),
|
||||
)
|
||||
const CategoryEntity = new EntitySchema<Category>(
|
||||
require(__dirname +
|
||||
"/../../../../sample/sample24-schemas/schemas/category.json"),
|
||||
require(
|
||||
__dirname +
|
||||
"/../../../../sample/sample24-schemas/schemas/category.json",
|
||||
),
|
||||
)
|
||||
const ImageEntity = new EntitySchema<Image>(
|
||||
require(__dirname +
|
||||
"/../../../../sample/sample24-schemas/schemas/image.json"),
|
||||
require(
|
||||
__dirname + "/../../../../sample/sample24-schemas/schemas/image.json",
|
||||
),
|
||||
)
|
||||
|
||||
const options: DataSourceOptions = {
|
||||
|
||||
@ -14,9 +14,8 @@ export class CommandUtils {
|
||||
): Promise<DataSource> {
|
||||
let dataSourceFileExports
|
||||
try {
|
||||
;[dataSourceFileExports] = await importOrRequireFile(
|
||||
dataSourceFilePath,
|
||||
)
|
||||
;[dataSourceFileExports] =
|
||||
await importOrRequireFile(dataSourceFilePath)
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
`Unable to open file: "${dataSourceFilePath}". ${err.message}`,
|
||||
|
||||
@ -9,9 +9,8 @@ export class VersionCommand implements yargs.CommandModule {
|
||||
describe = "Prints TypeORM version this project uses."
|
||||
|
||||
async handler() {
|
||||
const localNpmList = await VersionCommand.executeCommand(
|
||||
"npm list --depth=0",
|
||||
)
|
||||
const localNpmList =
|
||||
await VersionCommand.executeCommand("npm list --depth=0")
|
||||
const localMatches = localNpmList.match(/ typeorm@(.*)\n/)
|
||||
const localNpmVersion = (
|
||||
localMatches && localMatches[1] ? localMatches[1] : ""
|
||||
|
||||
@ -6,9 +6,9 @@ export type DeepPartial<T> =
|
||||
| (T extends Array<infer U>
|
||||
? DeepPartial<U>[]
|
||||
: T extends Map<infer K, infer V>
|
||||
? Map<DeepPartial<K>, DeepPartial<V>>
|
||||
: T extends Set<infer M>
|
||||
? Set<DeepPartial<M>>
|
||||
: T extends object
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: T)
|
||||
? Map<DeepPartial<K>, DeepPartial<V>>
|
||||
: T extends Set<infer M>
|
||||
? Set<DeepPartial<M>>
|
||||
: T extends object
|
||||
? { [K in keyof T]?: DeepPartial<T[K]> }
|
||||
: T)
|
||||
|
||||
@ -720,9 +720,10 @@ export class DataSource {
|
||||
const flattenedSubscribers = ObjectUtils.mixedListToArray(
|
||||
this.options.subscribers || [],
|
||||
)
|
||||
const subscribers = await connectionMetadataBuilder.buildSubscribers(
|
||||
flattenedSubscribers,
|
||||
)
|
||||
const subscribers =
|
||||
await connectionMetadataBuilder.buildSubscribers(
|
||||
flattenedSubscribers,
|
||||
)
|
||||
ObjectUtils.assign(this, { subscribers: subscribers })
|
||||
|
||||
// build entity metadatas
|
||||
@ -744,9 +745,8 @@ export class DataSource {
|
||||
const flattenedMigrations = ObjectUtils.mixedListToArray(
|
||||
this.options.migrations || [],
|
||||
)
|
||||
const migrations = await connectionMetadataBuilder.buildMigrations(
|
||||
flattenedMigrations,
|
||||
)
|
||||
const migrations =
|
||||
await connectionMetadataBuilder.buildMigrations(flattenedMigrations)
|
||||
ObjectUtils.assign(this, { migrations: migrations })
|
||||
|
||||
// validate all created entity metadatas to make sure user created entities are valid and correct
|
||||
|
||||
@ -81,9 +81,9 @@ export function ForeignKey<
|
||||
!Array.isArray(inverseSideOrColumnNamesOrOptions)
|
||||
? inverseSideOrColumnNamesOrOptions
|
||||
: ObjectUtils.isObject(referencedColumnNamesOrOptions) &&
|
||||
!Array.isArray(referencedColumnNamesOrOptions)
|
||||
? referencedColumnNamesOrOptions
|
||||
: maybeOptions
|
||||
!Array.isArray(referencedColumnNamesOrOptions)
|
||||
? referencedColumnNamesOrOptions
|
||||
: maybeOptions
|
||||
|
||||
return function (
|
||||
clsOrObject: Function | Object,
|
||||
|
||||
@ -4,5 +4,8 @@
|
||||
export class Query {
|
||||
readonly "@instanceof" = Symbol.for("Query")
|
||||
|
||||
constructor(public query: string, public parameters?: any[]) {}
|
||||
constructor(
|
||||
public query: string,
|
||||
public parameters?: any[],
|
||||
) {}
|
||||
}
|
||||
|
||||
@ -1886,9 +1886,8 @@ export class AuroraMysqlQueryRunner
|
||||
if (!isAnotherTransactionActive) await this.startTransaction()
|
||||
try {
|
||||
const selectViewDropsQuery = `SELECT concat('DROP VIEW IF EXISTS \`', table_schema, '\`.\`', table_name, '\`') AS \`query\` FROM \`INFORMATION_SCHEMA\`.\`VIEWS\` WHERE \`TABLE_SCHEMA\` = '${dbName}'`
|
||||
const dropViewQueries: ObjectLiteral[] = await this.query(
|
||||
selectViewDropsQuery,
|
||||
)
|
||||
const dropViewQueries: ObjectLiteral[] =
|
||||
await this.query(selectViewDropsQuery)
|
||||
await Promise.all(
|
||||
dropViewQueries.map((q) => this.query(q["query"])),
|
||||
)
|
||||
@ -1898,9 +1897,8 @@ export class AuroraMysqlQueryRunner
|
||||
const enableForeignKeysCheckQuery = `SET FOREIGN_KEY_CHECKS = 1;`
|
||||
|
||||
await this.query(disableForeignKeysCheckQuery)
|
||||
const dropQueries: ObjectLiteral[] = await this.query(
|
||||
dropTablesQuery,
|
||||
)
|
||||
const dropQueries: ObjectLiteral[] =
|
||||
await this.query(dropTablesQuery)
|
||||
await Promise.all(
|
||||
dropQueries.map((query) => this.query(query["query"])),
|
||||
)
|
||||
|
||||
@ -2837,17 +2837,15 @@ export class CockroachQueryRunner
|
||||
const selectViewDropsQuery =
|
||||
`SELECT 'DROP VIEW IF EXISTS "' || schemaname || '"."' || viewname || '" CASCADE;' as "query" ` +
|
||||
`FROM "pg_views" WHERE "schemaname" IN (${schemaNamesString})`
|
||||
const dropViewQueries: ObjectLiteral[] = await this.query(
|
||||
selectViewDropsQuery,
|
||||
)
|
||||
const dropViewQueries: ObjectLiteral[] =
|
||||
await this.query(selectViewDropsQuery)
|
||||
await Promise.all(
|
||||
dropViewQueries.map((q) => this.query(q["query"])),
|
||||
)
|
||||
|
||||
const selectDropsQuery = `SELECT 'DROP TABLE IF EXISTS "' || table_schema || '"."' || table_name || '" CASCADE;' as "query" FROM "information_schema"."tables" WHERE "table_schema" IN (${schemaNamesString})`
|
||||
const dropQueries: ObjectLiteral[] = await this.query(
|
||||
selectDropsQuery,
|
||||
)
|
||||
const dropQueries: ObjectLiteral[] =
|
||||
await this.query(selectDropsQuery)
|
||||
await Promise.all(dropQueries.map((q) => this.query(q["query"])))
|
||||
|
||||
const selectSequenceDropsQuery = `SELECT 'DROP SEQUENCE "' || sequence_schema || '"."' || sequence_name || '";' as "query" FROM "information_schema"."sequences" WHERE "sequence_schema" IN (${schemaNamesString})`
|
||||
|
||||
@ -210,9 +210,8 @@ export class CordovaQueryRunner extends AbstractSqliteQueryRunner {
|
||||
await this.query(`PRAGMA foreign_keys = OFF`)
|
||||
try {
|
||||
const selectViewDropsQuery = `SELECT 'DROP VIEW "' || name || '";' as query FROM "sqlite_master" WHERE "type" = 'view'`
|
||||
const dropViewQueries: ObjectLiteral[] = await this.query(
|
||||
selectViewDropsQuery,
|
||||
)
|
||||
const dropViewQueries: ObjectLiteral[] =
|
||||
await this.query(selectViewDropsQuery)
|
||||
|
||||
const selectTableDropsQuery = `SELECT 'DROP TABLE "' || name || '";' as query FROM "sqlite_master" WHERE "type" = 'table' AND "name" != 'sqlite_sequence'`
|
||||
const dropTableQueries: ObjectLiteral[] = await this.query(
|
||||
|
||||
@ -475,9 +475,8 @@ export declare interface AggregationCursorOptions
|
||||
* array types can be searched using their element type
|
||||
* @public
|
||||
*/
|
||||
export declare type AlternativeType<T> = T extends ReadonlyArray<infer U>
|
||||
? T | RegExpOrString<U>
|
||||
: RegExpOrString<T>
|
||||
export declare type AlternativeType<T> =
|
||||
T extends ReadonlyArray<infer U> ? T | RegExpOrString<U> : RegExpOrString<T>
|
||||
|
||||
/** @public */
|
||||
export declare type AnyBulkWriteOperation<TSchema extends Document = Document> =
|
||||
@ -505,9 +504,8 @@ export declare type AnyBulkWriteOperation<TSchema extends Document = Document> =
|
||||
export declare type AnyError = MongoError | Error
|
||||
|
||||
/** @public */
|
||||
export declare type ArrayElement<Type> = Type extends ReadonlyArray<infer Item>
|
||||
? Item
|
||||
: never
|
||||
export declare type ArrayElement<Type> =
|
||||
Type extends ReadonlyArray<infer Item> ? Item : never
|
||||
|
||||
/** @public */
|
||||
export declare type ArrayOperator<Type> = {
|
||||
@ -3177,8 +3175,8 @@ export declare type EnhancedOmit<TRecordOrUnion, KeyUnion> =
|
||||
string extends keyof TRecordOrUnion
|
||||
? TRecordOrUnion
|
||||
: TRecordOrUnion extends any
|
||||
? Pick<TRecordOrUnion, Exclude<keyof TRecordOrUnion, KeyUnion>>
|
||||
: never
|
||||
? Pick<TRecordOrUnion, Exclude<keyof TRecordOrUnion, KeyUnion>>
|
||||
: never
|
||||
|
||||
/** @public */
|
||||
export declare interface ErrorDescription extends Document {
|
||||
@ -3251,11 +3249,12 @@ export declare type Filter<TSchema> = {
|
||||
} & RootFilterOperators<WithId<TSchema>>
|
||||
|
||||
/** @public */
|
||||
export declare type FilterOperations<T> = T extends Record<string, any>
|
||||
? {
|
||||
[key in keyof T]?: FilterOperators<T[key]>
|
||||
}
|
||||
: FilterOperators<T>
|
||||
export declare type FilterOperations<T> =
|
||||
T extends Record<string, any>
|
||||
? {
|
||||
[key in keyof T]?: FilterOperators<T[key]>
|
||||
}
|
||||
: FilterOperators<T>
|
||||
|
||||
/** @public */
|
||||
export declare interface FilterOperators<TValue>
|
||||
@ -3591,9 +3590,8 @@ export declare interface FindOptions<TSchema extends Document = Document>
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export declare type Flatten<Type> = Type extends ReadonlyArray<infer Item>
|
||||
? Item
|
||||
: Type
|
||||
export declare type Flatten<Type> =
|
||||
Type extends ReadonlyArray<infer Item> ? Item : Type
|
||||
|
||||
/** @public */
|
||||
export declare type GenericListener = (...args: any[]) => void
|
||||
@ -4002,12 +4000,12 @@ export declare type InferIdType<TSchema> = TSchema extends {
|
||||
? never
|
||||
: IdType
|
||||
: TSchema extends {
|
||||
_id?: infer IdType
|
||||
}
|
||||
? unknown extends IdType
|
||||
? ObjectId
|
||||
: IdType
|
||||
: ObjectId
|
||||
_id?: infer IdType
|
||||
}
|
||||
? unknown extends IdType
|
||||
? ObjectId
|
||||
: IdType
|
||||
: ObjectId
|
||||
|
||||
/** @public */
|
||||
export declare interface InsertManyResult<TSchema = Document> {
|
||||
@ -4061,10 +4059,10 @@ export declare type IsAny<Type, ResultIfAny, ResultIfNotAny> =
|
||||
export declare type Join<T extends unknown[], D extends string> = T extends []
|
||||
? ""
|
||||
: T extends [string | number]
|
||||
? `${T[0]}`
|
||||
: T extends [string | number, ...infer R]
|
||||
? `${T[0]}${D}${Join<R, D>}`
|
||||
: string
|
||||
? `${T[0]}`
|
||||
: T extends [string | number, ...infer R]
|
||||
? `${T[0]}${D}${Join<R, D>}`
|
||||
: string
|
||||
|
||||
/* Excluded from this release type: kBeforeHandshake */
|
||||
|
||||
@ -5308,38 +5306,46 @@ export declare type NestedPaths<
|
||||
> = Depth["length"] extends 8
|
||||
? []
|
||||
: Type extends
|
||||
| string
|
||||
| number
|
||||
| bigint
|
||||
| boolean
|
||||
| Date
|
||||
| RegExp
|
||||
| Buffer
|
||||
| Uint8Array
|
||||
| ((...args: any[]) => any)
|
||||
| {
|
||||
_bsontype: string
|
||||
}
|
||||
? []
|
||||
: Type extends ReadonlyArray<infer ArrayType>
|
||||
? [] | [number, ...NestedPaths<ArrayType, [...Depth, 1]>]
|
||||
: Type extends Map<string, any>
|
||||
? [string]
|
||||
: Type extends object
|
||||
? {
|
||||
[Key in Extract<keyof Type, string>]: Type[Key] extends Type
|
||||
? [Key]
|
||||
: Type extends Type[Key]
|
||||
? [Key]
|
||||
: Type[Key] extends ReadonlyArray<infer ArrayType>
|
||||
? Type extends ArrayType
|
||||
? [Key]
|
||||
: ArrayType extends Type
|
||||
? [Key]
|
||||
: [Key, ...NestedPaths<Type[Key], [...Depth, 1]>] // child is not structured the same as the parent
|
||||
: [Key, ...NestedPaths<Type[Key], [...Depth, 1]>] | [Key]
|
||||
}[Extract<keyof Type, string>]
|
||||
: []
|
||||
| string
|
||||
| number
|
||||
| bigint
|
||||
| boolean
|
||||
| Date
|
||||
| RegExp
|
||||
| Buffer
|
||||
| Uint8Array
|
||||
| ((...args: any[]) => any)
|
||||
| {
|
||||
_bsontype: string
|
||||
}
|
||||
? []
|
||||
: Type extends ReadonlyArray<infer ArrayType>
|
||||
? [] | [number, ...NestedPaths<ArrayType, [...Depth, 1]>]
|
||||
: Type extends Map<string, any>
|
||||
? [string]
|
||||
: Type extends object
|
||||
? {
|
||||
[Key in Extract<keyof Type, string>]: Type[Key] extends Type
|
||||
? [Key]
|
||||
: Type extends Type[Key]
|
||||
? [Key]
|
||||
: Type[Key] extends ReadonlyArray<infer ArrayType>
|
||||
? Type extends ArrayType
|
||||
? [Key]
|
||||
: ArrayType extends Type
|
||||
? [Key]
|
||||
: [
|
||||
Key,
|
||||
...NestedPaths<Type[Key], [...Depth, 1]>,
|
||||
] // child is not structured the same as the parent
|
||||
:
|
||||
| [
|
||||
Key,
|
||||
...NestedPaths<Type[Key], [...Depth, 1]>,
|
||||
]
|
||||
| [Key]
|
||||
}[Extract<keyof Type, string>]
|
||||
: []
|
||||
|
||||
/**
|
||||
* @public
|
||||
@ -5524,22 +5530,22 @@ export declare type PropertyType<
|
||||
> = string extends Property
|
||||
? unknown
|
||||
: Property extends keyof Type
|
||||
? Type[Property]
|
||||
: Property extends `${number}`
|
||||
? Type extends ReadonlyArray<infer ArrayType>
|
||||
? ArrayType
|
||||
: unknown
|
||||
: Property extends `${infer Key}.${infer Rest}`
|
||||
? Key extends `${number}`
|
||||
? Type[Property]
|
||||
: Property extends `${number}`
|
||||
? Type extends ReadonlyArray<infer ArrayType>
|
||||
? PropertyType<ArrayType, Rest>
|
||||
? ArrayType
|
||||
: unknown
|
||||
: Key extends keyof Type
|
||||
? Type[Key] extends Map<string, infer MapType>
|
||||
? MapType
|
||||
: PropertyType<Type[Key], Rest>
|
||||
: unknown
|
||||
: unknown
|
||||
: Property extends `${infer Key}.${infer Rest}`
|
||||
? Key extends `${number}`
|
||||
? Type extends ReadonlyArray<infer ArrayType>
|
||||
? PropertyType<ArrayType, Rest>
|
||||
: unknown
|
||||
: Key extends keyof Type
|
||||
? Type[Key] extends Map<string, infer MapType>
|
||||
? MapType
|
||||
: PropertyType<Type[Key], Rest>
|
||||
: unknown
|
||||
: unknown
|
||||
|
||||
/** @public */
|
||||
export declare interface ProxyOptions {
|
||||
|
||||
@ -2274,9 +2274,8 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
|
||||
if (!isAnotherTransactionActive) await this.startTransaction()
|
||||
try {
|
||||
const selectViewDropsQuery = `SELECT concat('DROP VIEW IF EXISTS \`', table_schema, '\`.\`', table_name, '\`') AS \`query\` FROM \`INFORMATION_SCHEMA\`.\`VIEWS\` WHERE \`TABLE_SCHEMA\` = '${dbName}'`
|
||||
const dropViewQueries: ObjectLiteral[] = await this.query(
|
||||
selectViewDropsQuery,
|
||||
)
|
||||
const dropViewQueries: ObjectLiteral[] =
|
||||
await this.query(selectViewDropsQuery)
|
||||
await Promise.all(
|
||||
dropViewQueries.map((q) => this.query(q["query"])),
|
||||
)
|
||||
@ -2286,9 +2285,8 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
|
||||
const enableForeignKeysCheckQuery = `SET FOREIGN_KEY_CHECKS = 1;`
|
||||
|
||||
await this.query(disableForeignKeysCheckQuery)
|
||||
const dropQueries: ObjectLiteral[] = await this.query(
|
||||
dropTablesQuery,
|
||||
)
|
||||
const dropQueries: ObjectLiteral[] =
|
||||
await this.query(dropTablesQuery)
|
||||
await Promise.all(
|
||||
dropQueries.map((query) => this.query(query["query"])),
|
||||
)
|
||||
@ -3369,9 +3367,8 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
|
||||
}
|
||||
|
||||
async getVersion(): Promise<string> {
|
||||
const result: [{ "version()": string }] = await this.query(
|
||||
"SELECT version()",
|
||||
)
|
||||
const result: [{ "version()": string }] =
|
||||
await this.query("SELECT version()")
|
||||
|
||||
// MariaDB: https://mariadb.com/kb/en/version/
|
||||
// - "10.2.27-MariaDB-10.2.27+maria~jessie-log"
|
||||
|
||||
@ -2217,27 +2217,24 @@ export class OracleQueryRunner extends BaseQueryRunner implements QueryRunner {
|
||||
try {
|
||||
// drop views
|
||||
const dropViewsQuery = `SELECT 'DROP VIEW "' || VIEW_NAME || '"' AS "query" FROM "USER_VIEWS"`
|
||||
const dropViewQueries: ObjectLiteral[] = await this.query(
|
||||
dropViewsQuery,
|
||||
)
|
||||
const dropViewQueries: ObjectLiteral[] =
|
||||
await this.query(dropViewsQuery)
|
||||
await Promise.all(
|
||||
dropViewQueries.map((query) => this.query(query["query"])),
|
||||
)
|
||||
|
||||
// drop materialized views
|
||||
const dropMatViewsQuery = `SELECT 'DROP MATERIALIZED VIEW "' || MVIEW_NAME || '"' AS "query" FROM "USER_MVIEWS"`
|
||||
const dropMatViewQueries: ObjectLiteral[] = await this.query(
|
||||
dropMatViewsQuery,
|
||||
)
|
||||
const dropMatViewQueries: ObjectLiteral[] =
|
||||
await this.query(dropMatViewsQuery)
|
||||
await Promise.all(
|
||||
dropMatViewQueries.map((query) => this.query(query["query"])),
|
||||
)
|
||||
|
||||
// drop tables
|
||||
const dropTablesQuery = `SELECT 'DROP TABLE "' || TABLE_NAME || '" CASCADE CONSTRAINTS' AS "query" FROM "USER_TABLES"`
|
||||
const dropTableQueries: ObjectLiteral[] = await this.query(
|
||||
dropTablesQuery,
|
||||
)
|
||||
const dropTableQueries: ObjectLiteral[] =
|
||||
await this.query(dropTablesQuery)
|
||||
await Promise.all(
|
||||
dropTableQueries.map((query) => this.query(query["query"])),
|
||||
)
|
||||
|
||||
@ -3134,9 +3134,8 @@ export class PostgresQueryRunner
|
||||
const selectViewDropsQuery =
|
||||
`SELECT 'DROP VIEW IF EXISTS "' || schemaname || '"."' || viewname || '" CASCADE;' as "query" ` +
|
||||
`FROM "pg_views" WHERE "schemaname" IN (${schemaNamesString}) AND "viewname" NOT IN ('geography_columns', 'geometry_columns', 'raster_columns', 'raster_overviews')`
|
||||
const dropViewQueries: ObjectLiteral[] = await this.query(
|
||||
selectViewDropsQuery,
|
||||
)
|
||||
const dropViewQueries: ObjectLiteral[] =
|
||||
await this.query(selectViewDropsQuery)
|
||||
await Promise.all(
|
||||
dropViewQueries.map((q) => this.query(q["query"])),
|
||||
)
|
||||
@ -4197,9 +4196,8 @@ export class PostgresQueryRunner
|
||||
// see:
|
||||
// - https://github.com/typeorm/typeorm/pull/9319
|
||||
// - https://docs.aws.amazon.com/redshift/latest/dg/c_unsupported-postgresql-functions.html
|
||||
const result: [{ version: string }] = await this.query(
|
||||
`SELECT version()`,
|
||||
)
|
||||
const result: [{ version: string }] =
|
||||
await this.query(`SELECT version()`)
|
||||
|
||||
// Examples:
|
||||
// Postgres: "PostgreSQL 14.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20), 64-bit"
|
||||
|
||||
@ -284,9 +284,8 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
|
||||
this.driver.connection.logger.logQuery(query, parameters, this)
|
||||
try {
|
||||
const queryStartTime = Date.now()
|
||||
const [operation] = await this.driver.instanceDatabase.updateSchema(
|
||||
query,
|
||||
)
|
||||
const [operation] =
|
||||
await this.driver.instanceDatabase.updateSchema(query)
|
||||
await operation.promise()
|
||||
// log slow queries if maxQueryExecution time is set
|
||||
const maxQueryExecutionTime =
|
||||
@ -1447,9 +1446,8 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
|
||||
`SELECT concat('ALTER TABLE \`', TABLE_NAME, '\`', ' DROP CONSTRAINT \`', CONSTRAINT_NAME, '\`') AS \`query\` ` +
|
||||
`FROM \`INFORMATION_SCHEMA\`.\`TABLE_CONSTRAINTS\` ` +
|
||||
`WHERE \`TABLE_CATALOG\` = '' AND \`TABLE_SCHEMA\` = '' AND \`CONSTRAINT_TYPE\` = 'FOREIGN KEY'`
|
||||
const dropFKQueries: ObjectLiteral[] = await this.query(
|
||||
selectFKDropsQuery,
|
||||
)
|
||||
const dropFKQueries: ObjectLiteral[] =
|
||||
await this.query(selectFKDropsQuery)
|
||||
|
||||
// drop view queries
|
||||
// const selectViewDropsQuery = `SELECT concat('DROP VIEW \`', TABLE_NAME, '\`') AS \`query\` FROM \`INFORMATION_SCHEMA\`.\`VIEWS\``
|
||||
@ -1462,9 +1460,8 @@ export class SpannerQueryRunner extends BaseQueryRunner implements QueryRunner {
|
||||
`SELECT concat('DROP TABLE \`', TABLE_NAME, '\`') AS \`query\` ` +
|
||||
`FROM \`INFORMATION_SCHEMA\`.\`TABLES\` ` +
|
||||
`WHERE \`TABLE_CATALOG\` = '' AND \`TABLE_SCHEMA\` = '' AND \`TABLE_TYPE\` = 'BASE TABLE'`
|
||||
const dropTableQueries: ObjectLiteral[] = await this.query(
|
||||
dropTablesQuery,
|
||||
)
|
||||
const dropTableQueries: ObjectLiteral[] =
|
||||
await this.query(dropTablesQuery)
|
||||
|
||||
if (
|
||||
!dropIndexQueries.length &&
|
||||
|
||||
@ -1183,9 +1183,8 @@ export abstract class AbstractSqliteQueryRunner
|
||||
const selectViewDropsQuery = dbPath
|
||||
? `SELECT 'DROP VIEW "${dbPath}"."' || name || '";' as query FROM "${dbPath}"."sqlite_master" WHERE "type" = 'view'`
|
||||
: `SELECT 'DROP VIEW "' || name || '";' as query FROM "sqlite_master" WHERE "type" = 'view'`
|
||||
const dropViewQueries: ObjectLiteral[] = await this.query(
|
||||
selectViewDropsQuery,
|
||||
)
|
||||
const dropViewQueries: ObjectLiteral[] =
|
||||
await this.query(selectViewDropsQuery)
|
||||
await Promise.all(
|
||||
dropViewQueries.map((q) => this.query(q["query"])),
|
||||
)
|
||||
|
||||
@ -49,7 +49,11 @@ export class MssqlParameter {
|
||||
constructor(value: any, type: "geography")
|
||||
constructor(value: any, type: "geometry")
|
||||
constructor(value: any, type: "rowversion")
|
||||
constructor(public value: any, public type: string, ...params: number[]) {
|
||||
constructor(
|
||||
public value: any,
|
||||
public type: string,
|
||||
...params: number[]
|
||||
) {
|
||||
this.params = params || []
|
||||
}
|
||||
}
|
||||
|
||||
@ -2633,9 +2633,8 @@ export class SqlServerQueryRunner
|
||||
const allViewsSql = database
|
||||
? `SELECT * FROM "${database}"."INFORMATION_SCHEMA"."VIEWS"`
|
||||
: `SELECT * FROM "INFORMATION_SCHEMA"."VIEWS"`
|
||||
const allViewsResults: ObjectLiteral[] = await this.query(
|
||||
allViewsSql,
|
||||
)
|
||||
const allViewsResults: ObjectLiteral[] =
|
||||
await this.query(allViewsSql)
|
||||
|
||||
await Promise.all(
|
||||
allViewsResults.map((viewResult) => {
|
||||
@ -2648,9 +2647,8 @@ export class SqlServerQueryRunner
|
||||
const allTablesSql = database
|
||||
? `SELECT * FROM "${database}"."INFORMATION_SCHEMA"."TABLES" WHERE "TABLE_TYPE" = 'BASE TABLE'`
|
||||
: `SELECT * FROM "INFORMATION_SCHEMA"."TABLES" WHERE "TABLE_TYPE" = 'BASE TABLE'`
|
||||
const allTablesResults: ObjectLiteral[] = await this.query(
|
||||
allTablesSql,
|
||||
)
|
||||
const allTablesResults: ObjectLiteral[] =
|
||||
await this.query(allTablesSql)
|
||||
|
||||
if (allTablesResults.length > 0) {
|
||||
const tablesByCatalog: {
|
||||
@ -2835,9 +2833,8 @@ export class SqlServerQueryRunner
|
||||
`SELECT DISTINCT "name" ` +
|
||||
`FROM "master"."dbo"."sysdatabases" ` +
|
||||
`WHERE "name" NOT IN ('master', 'model', 'msdb')`
|
||||
const dbDatabases: { name: string }[] = await this.query(
|
||||
databasesSql,
|
||||
)
|
||||
const dbDatabases: { name: string }[] =
|
||||
await this.query(databasesSql)
|
||||
|
||||
const tablesSql = dbDatabases
|
||||
.map(({ name }) => {
|
||||
@ -2859,15 +2856,20 @@ export class SqlServerQueryRunner
|
||||
} else {
|
||||
const tableNamesByCatalog = tableNames
|
||||
.map((tableName) => this.driver.parseTableName(tableName))
|
||||
.reduce((c, { database, ...other }) => {
|
||||
database = database || currentDatabase
|
||||
c[database] = c[database] || []
|
||||
c[database].push({
|
||||
schema: other.schema || currentSchema,
|
||||
tableName: other.tableName,
|
||||
})
|
||||
return c
|
||||
}, {} as { [key: string]: { schema: string; tableName: string }[] })
|
||||
.reduce(
|
||||
(c, { database, ...other }) => {
|
||||
database = database || currentDatabase
|
||||
c[database] = c[database] || []
|
||||
c[database].push({
|
||||
schema: other.schema || currentSchema,
|
||||
tableName: other.tableName,
|
||||
})
|
||||
return c
|
||||
},
|
||||
{} as {
|
||||
[key: string]: { schema: string; tableName: string }[]
|
||||
},
|
||||
)
|
||||
|
||||
const tablesSql = Object.entries(tableNamesByCatalog)
|
||||
.map(([database, tables]) => {
|
||||
|
||||
@ -1353,7 +1353,7 @@ export class EntityManager {
|
||||
const values: QueryDeepPartialEntity<Entity> = propertyPath
|
||||
.split(".")
|
||||
.reduceRight(
|
||||
(value, key) => ({ [key]: value } as any),
|
||||
(value, key) => ({ [key]: value }) as any,
|
||||
() =>
|
||||
this.connection.driver.escape(column.databaseName) +
|
||||
" + " +
|
||||
@ -1390,7 +1390,7 @@ export class EntityManager {
|
||||
const values: QueryDeepPartialEntity<Entity> = propertyPath
|
||||
.split(".")
|
||||
.reduceRight(
|
||||
(value, key) => ({ [key]: value } as any),
|
||||
(value, key) => ({ [key]: value }) as any,
|
||||
() =>
|
||||
this.connection.driver.escape(column.databaseName) +
|
||||
" - " +
|
||||
|
||||
@ -3,29 +3,28 @@ import { ObjectId } from "../driver/mongodb/typings"
|
||||
/**
|
||||
* A single property handler for FindOptionsOrder.
|
||||
*/
|
||||
export type FindOptionsOrderProperty<Property> = Property extends Promise<
|
||||
infer I
|
||||
>
|
||||
? FindOptionsOrderProperty<NonNullable<I>>
|
||||
: Property extends Array<infer I>
|
||||
? FindOptionsOrderProperty<NonNullable<I>>
|
||||
: Property extends Function
|
||||
? never
|
||||
: Property extends string
|
||||
? FindOptionsOrderValue
|
||||
: Property extends number
|
||||
? FindOptionsOrderValue
|
||||
: Property extends boolean
|
||||
? FindOptionsOrderValue
|
||||
: Property extends Buffer
|
||||
? FindOptionsOrderValue
|
||||
: Property extends Date
|
||||
? FindOptionsOrderValue
|
||||
: Property extends ObjectId
|
||||
? FindOptionsOrderValue
|
||||
: Property extends object
|
||||
? FindOptionsOrder<Property> | FindOptionsOrderValue
|
||||
: FindOptionsOrderValue
|
||||
export type FindOptionsOrderProperty<Property> =
|
||||
Property extends Promise<infer I>
|
||||
? FindOptionsOrderProperty<NonNullable<I>>
|
||||
: Property extends Array<infer I>
|
||||
? FindOptionsOrderProperty<NonNullable<I>>
|
||||
: Property extends Function
|
||||
? never
|
||||
: Property extends string
|
||||
? FindOptionsOrderValue
|
||||
: Property extends number
|
||||
? FindOptionsOrderValue
|
||||
: Property extends boolean
|
||||
? FindOptionsOrderValue
|
||||
: Property extends Buffer
|
||||
? FindOptionsOrderValue
|
||||
: Property extends Date
|
||||
? FindOptionsOrderValue
|
||||
: Property extends ObjectId
|
||||
? FindOptionsOrderValue
|
||||
: Property extends object
|
||||
? FindOptionsOrder<Property> | FindOptionsOrderValue
|
||||
: FindOptionsOrderValue
|
||||
|
||||
/**
|
||||
* Order by find options.
|
||||
|
||||
@ -3,29 +3,28 @@ import { ObjectId } from "../driver/mongodb/typings"
|
||||
/**
|
||||
* A single property handler for FindOptionsRelations.
|
||||
*/
|
||||
export type FindOptionsRelationsProperty<Property> = Property extends Promise<
|
||||
infer I
|
||||
>
|
||||
? FindOptionsRelationsProperty<NonNullable<I>> | boolean
|
||||
: Property extends Array<infer I>
|
||||
? FindOptionsRelationsProperty<NonNullable<I>> | boolean
|
||||
: Property extends string
|
||||
? never
|
||||
: Property extends number
|
||||
? never
|
||||
: Property extends boolean
|
||||
? never
|
||||
: Property extends Function
|
||||
? never
|
||||
: Property extends Buffer
|
||||
? never
|
||||
: Property extends Date
|
||||
? never
|
||||
: Property extends ObjectId
|
||||
? never
|
||||
: Property extends object
|
||||
? FindOptionsRelations<Property> | boolean
|
||||
: boolean
|
||||
export type FindOptionsRelationsProperty<Property> =
|
||||
Property extends Promise<infer I>
|
||||
? FindOptionsRelationsProperty<NonNullable<I>> | boolean
|
||||
: Property extends Array<infer I>
|
||||
? FindOptionsRelationsProperty<NonNullable<I>> | boolean
|
||||
: Property extends string
|
||||
? never
|
||||
: Property extends number
|
||||
? never
|
||||
: Property extends boolean
|
||||
? never
|
||||
: Property extends Function
|
||||
? never
|
||||
: Property extends Buffer
|
||||
? never
|
||||
: Property extends Date
|
||||
? never
|
||||
: Property extends ObjectId
|
||||
? never
|
||||
: Property extends object
|
||||
? FindOptionsRelations<Property> | boolean
|
||||
: boolean
|
||||
|
||||
/**
|
||||
* Relations find options.
|
||||
|
||||
@ -3,29 +3,28 @@ import { ObjectId } from "../driver/mongodb/typings"
|
||||
/**
|
||||
* A single property handler for FindOptionsSelect.
|
||||
*/
|
||||
export type FindOptionsSelectProperty<Property> = Property extends Promise<
|
||||
infer I
|
||||
>
|
||||
? FindOptionsSelectProperty<I> | boolean
|
||||
: Property extends Array<infer I>
|
||||
? FindOptionsSelectProperty<I> | boolean
|
||||
: Property extends string
|
||||
? boolean
|
||||
: Property extends number
|
||||
? boolean
|
||||
: Property extends boolean
|
||||
? boolean
|
||||
: Property extends Function
|
||||
? never
|
||||
: Property extends Buffer
|
||||
? boolean
|
||||
: Property extends Date
|
||||
? boolean
|
||||
: Property extends ObjectId
|
||||
? boolean
|
||||
: Property extends object
|
||||
? FindOptionsSelect<Property> | boolean
|
||||
: boolean
|
||||
export type FindOptionsSelectProperty<Property> =
|
||||
Property extends Promise<infer I>
|
||||
? FindOptionsSelectProperty<I> | boolean
|
||||
: Property extends Array<infer I>
|
||||
? FindOptionsSelectProperty<I> | boolean
|
||||
: Property extends string
|
||||
? boolean
|
||||
: Property extends number
|
||||
? boolean
|
||||
: Property extends boolean
|
||||
? boolean
|
||||
: Property extends Function
|
||||
? never
|
||||
: Property extends Buffer
|
||||
? boolean
|
||||
: Property extends Date
|
||||
? boolean
|
||||
: Property extends ObjectId
|
||||
? boolean
|
||||
: Property extends object
|
||||
? FindOptionsSelect<Property> | boolean
|
||||
: boolean
|
||||
|
||||
/**
|
||||
* Select find options.
|
||||
|
||||
@ -12,33 +12,34 @@ import { EqualOperator } from "./EqualOperator"
|
||||
export type FindOptionsWhereProperty<
|
||||
PropertyToBeNarrowed,
|
||||
Property = PropertyToBeNarrowed,
|
||||
> = PropertyToBeNarrowed extends Promise<infer I>
|
||||
? FindOptionsWhereProperty<NonNullable<I>>
|
||||
: PropertyToBeNarrowed extends Array<infer I>
|
||||
? FindOptionsWhereProperty<NonNullable<I>>
|
||||
: PropertyToBeNarrowed extends Function
|
||||
? never
|
||||
: PropertyToBeNarrowed extends Buffer
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends Date
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends ObjectId
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends string
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends number
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends boolean
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends object
|
||||
?
|
||||
| FindOptionsWhere<Property>
|
||||
| FindOptionsWhere<Property>[]
|
||||
| EqualOperator<Property>
|
||||
| FindOperator<any>
|
||||
| boolean
|
||||
| Property
|
||||
: Property | FindOperator<Property>
|
||||
> =
|
||||
PropertyToBeNarrowed extends Promise<infer I>
|
||||
? FindOptionsWhereProperty<NonNullable<I>>
|
||||
: PropertyToBeNarrowed extends Array<infer I>
|
||||
? FindOptionsWhereProperty<NonNullable<I>>
|
||||
: PropertyToBeNarrowed extends Function
|
||||
? never
|
||||
: PropertyToBeNarrowed extends Buffer
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends Date
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends ObjectId
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends string
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends number
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends boolean
|
||||
? Property | FindOperator<Property>
|
||||
: PropertyToBeNarrowed extends object
|
||||
?
|
||||
| FindOptionsWhere<Property>
|
||||
| FindOptionsWhere<Property>[]
|
||||
| EqualOperator<Property>
|
||||
| FindOperator<any>
|
||||
| boolean
|
||||
| Property
|
||||
: Property | FindOperator<Property>
|
||||
|
||||
/**
|
||||
* Used for find operations.
|
||||
|
||||
@ -1197,9 +1197,9 @@ export class EntityMetadataBuilder {
|
||||
? m.targetName === foreignKeyType ||
|
||||
m.givenTableName === foreignKeyType
|
||||
: InstanceChecker.isEntitySchema(foreignKeyType)
|
||||
? m.target === foreignKeyType.options.name ||
|
||||
m.target === foreignKeyType.options.target
|
||||
: m.target === foreignKeyType,
|
||||
? m.target === foreignKeyType.options.name ||
|
||||
m.target === foreignKeyType.options.target
|
||||
: m.target === foreignKeyType,
|
||||
)
|
||||
|
||||
if (!referencedEntityMetadata) {
|
||||
|
||||
@ -249,15 +249,15 @@ export class JunctionEntityMetadataBuilder {
|
||||
this.connection.driver.options.type === "spanner"
|
||||
? "NO ACTION"
|
||||
: relation.inverseRelation
|
||||
? relation.inverseRelation.onDelete
|
||||
: "CASCADE",
|
||||
? relation.inverseRelation.onDelete
|
||||
: "CASCADE",
|
||||
onUpdate:
|
||||
this.connection.driver.options.type === "oracle" ||
|
||||
this.connection.driver.options.type === "spanner"
|
||||
? "NO ACTION"
|
||||
: relation.inverseRelation
|
||||
? relation.inverseRelation.onUpdate
|
||||
: "CASCADE",
|
||||
? relation.inverseRelation.onUpdate
|
||||
: "CASCADE",
|
||||
}),
|
||||
]
|
||||
: []
|
||||
|
||||
@ -955,15 +955,18 @@ export class EntityMetadata {
|
||||
columns: ColumnMetadata[],
|
||||
options?: { skipNulls?: boolean },
|
||||
): ObjectLiteral | undefined {
|
||||
return columns.reduce((map, column) => {
|
||||
const value = column.getEntityValueMap(entity, options)
|
||||
return columns.reduce(
|
||||
(map, column) => {
|
||||
const value = column.getEntityValueMap(entity, options)
|
||||
|
||||
// make sure that none of the values of the columns are not missing
|
||||
if (map === undefined || value === null || value === undefined)
|
||||
return undefined
|
||||
// make sure that none of the values of the columns are not missing
|
||||
if (map === undefined || value === null || value === undefined)
|
||||
return undefined
|
||||
|
||||
return OrmUtils.mergeDeep(map, value)
|
||||
}, {} as ObjectLiteral | undefined)
|
||||
return OrmUtils.mergeDeep(map, value)
|
||||
},
|
||||
{} as ObjectLiteral | undefined,
|
||||
)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
@ -153,9 +153,8 @@ export class MigrationExecutor {
|
||||
await this.createMigrationsTableIfNotExist(queryRunner)
|
||||
|
||||
// get all migrations that are executed and saved in the database
|
||||
const executedMigrations = await this.loadExecutedMigrations(
|
||||
queryRunner,
|
||||
)
|
||||
const executedMigrations =
|
||||
await this.loadExecutedMigrations(queryRunner)
|
||||
|
||||
// get all user's migrations in the source code
|
||||
const allMigrations = this.getMigrations()
|
||||
@ -201,9 +200,8 @@ export class MigrationExecutor {
|
||||
}
|
||||
|
||||
// get all migrations that are executed and saved in the database
|
||||
const executedMigrations = await this.loadExecutedMigrations(
|
||||
queryRunner,
|
||||
)
|
||||
const executedMigrations =
|
||||
await this.loadExecutedMigrations(queryRunner)
|
||||
|
||||
// get the time when last migration was executed
|
||||
const lastTimeExecutedMigration =
|
||||
@ -404,9 +402,8 @@ export class MigrationExecutor {
|
||||
}
|
||||
|
||||
// get all migrations that are executed and saved in the database
|
||||
const executedMigrations = await this.loadExecutedMigrations(
|
||||
queryRunner,
|
||||
)
|
||||
const executedMigrations =
|
||||
await this.loadExecutedMigrations(queryRunner)
|
||||
|
||||
// get the time when last migration was executed
|
||||
const lastTimeExecutedMigration =
|
||||
|
||||
@ -159,16 +159,22 @@ export class SubjectDatabaseEntityLoader {
|
||||
target: Function | string
|
||||
subjects: Subject[]
|
||||
}[] {
|
||||
return this.subjects.reduce((groups, operatedEntity) => {
|
||||
let group = groups.find(
|
||||
(group) => group.target === operatedEntity.metadata.target,
|
||||
)
|
||||
if (!group) {
|
||||
group = { target: operatedEntity.metadata.target, subjects: [] }
|
||||
groups.push(group)
|
||||
}
|
||||
group.subjects.push(operatedEntity)
|
||||
return groups
|
||||
}, [] as { target: Function | string; subjects: Subject[] }[])
|
||||
return this.subjects.reduce(
|
||||
(groups, operatedEntity) => {
|
||||
let group = groups.find(
|
||||
(group) => group.target === operatedEntity.metadata.target,
|
||||
)
|
||||
if (!group) {
|
||||
group = {
|
||||
target: operatedEntity.metadata.target,
|
||||
subjects: [],
|
||||
}
|
||||
groups.push(group)
|
||||
}
|
||||
group.subjects.push(operatedEntity)
|
||||
return groups
|
||||
},
|
||||
[] as { target: Function | string; subjects: Subject[] }[],
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,9 +130,9 @@ export class PlatformTools {
|
||||
return require("react-native-sqlite-storage")
|
||||
}
|
||||
} catch (err) {
|
||||
return require(path.resolve(
|
||||
process.cwd() + "/node_modules/" + name,
|
||||
))
|
||||
return require(
|
||||
path.resolve(process.cwd() + "/node_modules/" + name),
|
||||
)
|
||||
}
|
||||
|
||||
// If nothing above matched and we get here, the package was not listed within PlatformTools
|
||||
|
||||
@ -19,7 +19,7 @@ type _QueryDeepPartialEntity<T> = {
|
||||
| (T[P] extends Array<infer U>
|
||||
? Array<_QueryDeepPartialEntity<U>>
|
||||
: T[P] extends ReadonlyArray<infer U>
|
||||
? ReadonlyArray<_QueryDeepPartialEntity<U>>
|
||||
: _QueryDeepPartialEntity<T[P]>)
|
||||
? ReadonlyArray<_QueryDeepPartialEntity<U>>
|
||||
: _QueryDeepPartialEntity<T[P]>)
|
||||
| (() => string)
|
||||
}
|
||||
|
||||
@ -37,8 +37,8 @@ export class RelationIdLoader {
|
||||
const relatedEntities = Array.isArray(relatedEntityOrRelatedEntities)
|
||||
? relatedEntityOrRelatedEntities
|
||||
: relatedEntityOrRelatedEntities
|
||||
? [relatedEntityOrRelatedEntities]
|
||||
: undefined
|
||||
? [relatedEntityOrRelatedEntities]
|
||||
: undefined
|
||||
|
||||
// load relation ids depend of relation type
|
||||
if (relation.isManyToMany) {
|
||||
|
||||
@ -1871,9 +1871,8 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
}
|
||||
|
||||
this.expressionMap.queryEntity = true
|
||||
const entitiesAndRaw = await this.executeEntitiesAndRawResults(
|
||||
queryRunner,
|
||||
)
|
||||
const entitiesAndRaw =
|
||||
await this.executeEntitiesAndRawResults(queryRunner)
|
||||
this.expressionMap.queryEntity = false
|
||||
|
||||
let count: number | undefined = this.lazyCount(entitiesAndRaw)
|
||||
@ -1928,8 +1927,8 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
const maxResults = hasLimit
|
||||
? this.expressionMap.limit
|
||||
: hasTake
|
||||
? this.expressionMap.take
|
||||
: undefined
|
||||
? this.expressionMap.take
|
||||
: undefined
|
||||
|
||||
if (
|
||||
maxResults !== undefined &&
|
||||
@ -1958,8 +1957,8 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
const previousResults: number = hasOffset
|
||||
? this.expressionMap.offset!
|
||||
: hasSkip
|
||||
? this.expressionMap.skip!
|
||||
: 0
|
||||
? this.expressionMap.skip!
|
||||
: 0
|
||||
|
||||
return entitiesAndRaw.entities.length + previousResults
|
||||
}
|
||||
@ -3617,9 +3616,8 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
if (rawResults.length > 0) {
|
||||
// transform raw results into entities
|
||||
const rawRelationIdResults = await relationIdLoader.load(rawResults)
|
||||
const rawRelationCountResults = await relationCountLoader.load(
|
||||
rawResults,
|
||||
)
|
||||
const rawRelationCountResults =
|
||||
await relationCountLoader.load(rawResults)
|
||||
const transformer = new RawSqlResultsToEntityTransformer(
|
||||
this.expressionMap,
|
||||
this.connection.driver,
|
||||
@ -4211,8 +4209,8 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
nulls?.toLowerCase() === "first"
|
||||
? "NULLS FIRST"
|
||||
: nulls?.toLowerCase() === "last"
|
||||
? "NULLS LAST"
|
||||
: undefined
|
||||
? "NULLS LAST"
|
||||
: undefined
|
||||
|
||||
const aliasPath = `${alias}.${propertyPath}`
|
||||
// const selection = this.expressionMap.selects.find(
|
||||
@ -4487,7 +4485,8 @@ export class SelectQueryBuilder<Entity extends ObjectLiteral>
|
||||
.inverseRelation!.inverseJoinColumns.map(
|
||||
(column) => {
|
||||
return `${
|
||||
relation.inverseRelation!
|
||||
relation
|
||||
.inverseRelation!
|
||||
.joinTableName
|
||||
}.${
|
||||
column.propertyName
|
||||
|
||||
@ -75,16 +75,16 @@ export class DepGraph {
|
||||
delete this.nodes[node]
|
||||
delete this.outgoingEdges[node]
|
||||
delete this.incomingEdges[node]
|
||||
;[this.incomingEdges, this.outgoingEdges].forEach(function (
|
||||
edgeList,
|
||||
) {
|
||||
Object.keys(edgeList).forEach(function (key: any) {
|
||||
const idx = edgeList[key].indexOf(node)
|
||||
if (idx >= 0) {
|
||||
edgeList[key].splice(idx, 1)
|
||||
}
|
||||
})
|
||||
})
|
||||
;[this.incomingEdges, this.outgoingEdges].forEach(
|
||||
function (edgeList) {
|
||||
Object.keys(edgeList).forEach(function (key: any) {
|
||||
const idx = edgeList[key].indexOf(node)
|
||||
if (idx >= 0) {
|
||||
edgeList[key].splice(idx, 1)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -36,16 +36,19 @@ export class OrmUtils {
|
||||
array: T[],
|
||||
propertyCallback: (item: T) => R,
|
||||
): { id: R; items: T[] }[] {
|
||||
return array.reduce((groupedArray, value) => {
|
||||
const key = propertyCallback(value)
|
||||
let grouped = groupedArray.find((i) => i.id === key)
|
||||
if (!grouped) {
|
||||
grouped = { id: key, items: [] }
|
||||
groupedArray.push(grouped)
|
||||
}
|
||||
grouped.items.push(value)
|
||||
return groupedArray
|
||||
}, [] as Array<{ id: R; items: T[] }>)
|
||||
return array.reduce(
|
||||
(groupedArray, value) => {
|
||||
const key = propertyCallback(value)
|
||||
let grouped = groupedArray.find((i) => i.id === key)
|
||||
if (!grouped) {
|
||||
grouped = { id: key, items: [] }
|
||||
groupedArray.push(grouped)
|
||||
}
|
||||
grouped.items.push(value)
|
||||
return groupedArray
|
||||
},
|
||||
[] as Array<{ id: R; items: T[] }>,
|
||||
)
|
||||
}
|
||||
|
||||
public static uniq<T>(array: T[], criteria?: (item: T) => unknown): T[]
|
||||
|
||||
@ -207,9 +207,8 @@ describe("column > virtual columns", () => {
|
||||
}
|
||||
|
||||
// find one
|
||||
let foundCompany = await companyRepository.findOne(
|
||||
findOneOptions,
|
||||
)
|
||||
let foundCompany =
|
||||
await companyRepository.findOne(findOneOptions)
|
||||
expect(foundCompany!.totalEmployeesCount).to.equal(4)
|
||||
|
||||
let [foundTimesheet] = foundCompany!.employees.find(
|
||||
@ -218,9 +217,8 @@ describe("column > virtual columns", () => {
|
||||
expect(foundTimesheet.totalActivityHours).to.equal(9)
|
||||
|
||||
// find many
|
||||
const foundCompanies = await companyRepository.find(
|
||||
findOneOptions,
|
||||
)
|
||||
const foundCompanies =
|
||||
await companyRepository.find(findOneOptions)
|
||||
expect(foundCompanies).to.have.lengthOf(1)
|
||||
|
||||
foundCompany = foundCompanies[0]
|
||||
|
||||
@ -40,9 +40,8 @@ describe("MongoDriver", () => {
|
||||
const url =
|
||||
"mongodb://username:password@someHost1:27017,someHost2:27018/myDatabase?replicaSet=abc&tls=true"
|
||||
|
||||
const connectionUrl = await getConnectionUrlFromFakedMongoClient(
|
||||
url,
|
||||
)
|
||||
const connectionUrl =
|
||||
await getConnectionUrlFromFakedMongoClient(url)
|
||||
|
||||
expect(connectionUrl).to.eql(url)
|
||||
})
|
||||
@ -51,9 +50,8 @@ describe("MongoDriver", () => {
|
||||
const url =
|
||||
"mongodb://username:password@someHost1:27017/myDatabase?tls=true"
|
||||
|
||||
const connectionUrl = await getConnectionUrlFromFakedMongoClient(
|
||||
url,
|
||||
)
|
||||
const connectionUrl =
|
||||
await getConnectionUrlFromFakedMongoClient(url)
|
||||
|
||||
expect(connectionUrl).to.eql(url)
|
||||
})
|
||||
|
||||
@ -175,12 +175,10 @@ describe("multi-database > basic-functionality", () => {
|
||||
const queryRunner = connection.createQueryRunner()
|
||||
const tablePathCategory = `${attachCategoryHandle}.category`
|
||||
const tablePathPost = `${attachCategoryHandle}.post`
|
||||
const tableCategory = (await queryRunner.getTable(
|
||||
tablePathCategory,
|
||||
))!
|
||||
const tablePost = (await queryRunner.getTable(
|
||||
tablePathPost,
|
||||
))!
|
||||
const tableCategory =
|
||||
(await queryRunner.getTable(tablePathCategory))!
|
||||
const tablePost =
|
||||
(await queryRunner.getTable(tablePathPost))!
|
||||
await queryRunner.release()
|
||||
|
||||
expect(tableCategory.foreignKeys.length).to.eq(1)
|
||||
|
||||
@ -26,9 +26,8 @@ describe("multi-schema-and-database > custom-junction-database", () => {
|
||||
const queryRunner = connection.createQueryRunner()
|
||||
if (connection.driver.options.type === "mssql") {
|
||||
const postTable = await queryRunner.getTable("yoman..post")
|
||||
const categoryTable = await queryRunner.getTable(
|
||||
"yoman..category",
|
||||
)
|
||||
const categoryTable =
|
||||
await queryRunner.getTable("yoman..category")
|
||||
const junctionMetadata = connection.getManyToManyMetadata(
|
||||
Post,
|
||||
"categories",
|
||||
@ -47,9 +46,8 @@ describe("multi-schema-and-database > custom-junction-database", () => {
|
||||
} else {
|
||||
// mysql
|
||||
const postTable = await queryRunner.getTable("yoman.post")
|
||||
const categoryTable = await queryRunner.getTable(
|
||||
"yoman.category",
|
||||
)
|
||||
const categoryTable =
|
||||
await queryRunner.getTable("yoman.category")
|
||||
const junctionMetadata = connection.getManyToManyMetadata(
|
||||
Post,
|
||||
"categories",
|
||||
|
||||
@ -25,9 +25,8 @@ describe("multi-schema-and-database > custom-junction-schema", () => {
|
||||
connections.map(async (connection) => {
|
||||
const queryRunner = connection.createQueryRunner()
|
||||
const postTable = await queryRunner.getTable("yoman.post")
|
||||
const categoryTable = await queryRunner.getTable(
|
||||
"yoman.category",
|
||||
)
|
||||
const categoryTable =
|
||||
await queryRunner.getTable("yoman.category")
|
||||
const junctionMetadata = connection.getManyToManyMetadata(
|
||||
Post,
|
||||
"categories",
|
||||
|
||||
@ -24,9 +24,8 @@ describe("query runner > create and drop database", () => {
|
||||
const queryRunner = connection.createQueryRunner()
|
||||
|
||||
await queryRunner.createDatabase("myTestDatabase", true)
|
||||
let hasDatabase = await queryRunner.hasDatabase(
|
||||
"myTestDatabase",
|
||||
)
|
||||
let hasDatabase =
|
||||
await queryRunner.hasDatabase("myTestDatabase")
|
||||
hasDatabase.should.be.true
|
||||
|
||||
await queryRunner.dropDatabase("myTestDatabase")
|
||||
|
||||
@ -174,9 +174,8 @@ describe("query runner > drop foreign key", () => {
|
||||
)
|
||||
|
||||
// Verify all test foreign keys were dropped
|
||||
const finalTable = await queryRunner.getTable(
|
||||
"test_fk_table",
|
||||
)
|
||||
const finalTable =
|
||||
await queryRunner.getTable("test_fk_table")
|
||||
if (!finalTable) {
|
||||
throw new Error("Final test table not found")
|
||||
}
|
||||
|
||||
@ -154,9 +154,8 @@ describe("query runner > drop index", () => {
|
||||
)
|
||||
|
||||
// Verify all test indices were dropped
|
||||
const finalTable = await queryRunner.getTable(
|
||||
"test_index_table",
|
||||
)
|
||||
const finalTable =
|
||||
await queryRunner.getTable("test_index_table")
|
||||
if (!finalTable) {
|
||||
throw new Error("Final test table not found")
|
||||
}
|
||||
|
||||
@ -130,9 +130,8 @@ describe("query runner > drop unique constraint", () => {
|
||||
)
|
||||
|
||||
// Get the table with unique constraints
|
||||
const table = await queryRunner.getTable(
|
||||
"test_unique_table",
|
||||
)
|
||||
const table =
|
||||
await queryRunner.getTable("test_unique_table")
|
||||
if (!table) {
|
||||
throw new Error("Test table not found")
|
||||
}
|
||||
@ -156,9 +155,8 @@ describe("query runner > drop unique constraint", () => {
|
||||
)
|
||||
|
||||
// Verify all test unique constraints were dropped
|
||||
const finalTable = await queryRunner.getTable(
|
||||
"test_unique_table",
|
||||
)
|
||||
const finalTable =
|
||||
await queryRunner.getTable("test_unique_table")
|
||||
if (!finalTable) {
|
||||
throw new Error("Final test table not found")
|
||||
}
|
||||
|
||||
@ -256,9 +256,8 @@ describe("repository > basic methods", () => {
|
||||
|
||||
// and preload it
|
||||
const plainBlogWithId = { id: 1 }
|
||||
const preloadedBlog = await blogRepository.preload(
|
||||
plainBlogWithId,
|
||||
)
|
||||
const preloadedBlog =
|
||||
await blogRepository.preload(plainBlogWithId)
|
||||
preloadedBlog!.should.be.instanceOf(Blog)
|
||||
preloadedBlog!.id.should.be.equal(1)
|
||||
preloadedBlog!.title.should.be.equal("About people")
|
||||
@ -289,9 +288,8 @@ describe("repository > basic methods", () => {
|
||||
|
||||
// and preload it
|
||||
const plainBlogWithId = { id: 1, categories: [{ id: 1 }] }
|
||||
const preloadedBlog = await blogRepository.preload(
|
||||
plainBlogWithId,
|
||||
)
|
||||
const preloadedBlog =
|
||||
await blogRepository.preload(plainBlogWithId)
|
||||
preloadedBlog!.should.be.instanceOf(Blog)
|
||||
preloadedBlog!.id.should.be.equal(1)
|
||||
preloadedBlog!.title.should.be.equal("About people")
|
||||
@ -906,9 +904,8 @@ describe("repository > basic methods", () => {
|
||||
title: "changed title about people",
|
||||
categories: [{ id: 1 }, { id: 2, name: "insects" }],
|
||||
}
|
||||
const preloadedBlog = await blogRepository.preload(
|
||||
plainBlogWithId,
|
||||
)
|
||||
const preloadedBlog =
|
||||
await blogRepository.preload(plainBlogWithId)
|
||||
preloadedBlog!.should.be.instanceOf(Blog)
|
||||
preloadedBlog!.id.should.be.equal(1)
|
||||
preloadedBlog!.title.should.be.equal(
|
||||
|
||||
@ -37,9 +37,8 @@ describe("repository > clear method", () => {
|
||||
await connection.getRepository(Post).clear()
|
||||
|
||||
// check find method
|
||||
const loadedPostsAfterClear = await connection.manager.find(
|
||||
Post,
|
||||
)
|
||||
const loadedPostsAfterClear =
|
||||
await connection.manager.find(Post)
|
||||
loadedPostsAfterClear.should.be.instanceOf(Array)
|
||||
loadedPostsAfterClear.length.should.be.equal(0)
|
||||
}),
|
||||
@ -64,9 +63,8 @@ describe("repository > clear method", () => {
|
||||
await connection.manager.clear(Post)
|
||||
|
||||
// check find method
|
||||
const loadedPostsAfterClear = await connection.manager.find(
|
||||
Post,
|
||||
)
|
||||
const loadedPostsAfterClear =
|
||||
await connection.manager.find(Post)
|
||||
loadedPostsAfterClear.should.be.instanceOf(Array)
|
||||
loadedPostsAfterClear.length.should.be.equal(0)
|
||||
}),
|
||||
|
||||
@ -669,9 +669,8 @@ describe("repository > find methods", () => {
|
||||
savedUsers.length.should.be.equal(users.length) // check if they all are saved
|
||||
|
||||
const loadIds = [1, 2, 4]
|
||||
const loadedUsers = (await userRepository.findByIds(
|
||||
loadIds,
|
||||
))!
|
||||
const loadedUsers =
|
||||
(await userRepository.findByIds(loadIds))!
|
||||
|
||||
loadedUsers
|
||||
.sort((a, b) => a.id - b.id)
|
||||
|
||||
@ -110,9 +110,8 @@ describe("schema builder > change column", () => {
|
||||
await connection.synchronize()
|
||||
|
||||
const queryRunner = connection.createQueryRunner()
|
||||
const postVersionTable = await queryRunner.getTable(
|
||||
"post_version",
|
||||
)
|
||||
const postVersionTable =
|
||||
await queryRunner.getTable("post_version")
|
||||
await queryRunner.release()
|
||||
|
||||
postVersionTable!.foreignKeys.length.should.be.equal(1)
|
||||
@ -462,9 +461,8 @@ describe("schema builder > change column", () => {
|
||||
await connection.synchronize()
|
||||
|
||||
const queryRunner = connection.createQueryRunner()
|
||||
const postVersionTable = await queryRunner.getTable(
|
||||
"post_version",
|
||||
)
|
||||
const postVersionTable =
|
||||
await queryRunner.getTable("post_version")
|
||||
await queryRunner.release()
|
||||
|
||||
postVersionTable!.foreignKeys.length.should.be.equal(1)
|
||||
|
||||
@ -88,9 +88,8 @@ describe("view entity > general", () => {
|
||||
photo3.albumId = album2.id
|
||||
await connection.manager.save(photo3)
|
||||
|
||||
const postCategories = await connection.manager.find(
|
||||
PostCategory,
|
||||
)
|
||||
const postCategories =
|
||||
await connection.manager.find(PostCategory)
|
||||
postCategories.length.should.be.equal(2)
|
||||
|
||||
const postId1 =
|
||||
@ -105,9 +104,8 @@ describe("view entity > general", () => {
|
||||
postCategories[1].name.should.be.equal("About Boeing")
|
||||
postCategories[1].categoryName.should.be.equal("Airplanes")
|
||||
|
||||
const photoAlbumCategories = await connection.manager.find(
|
||||
PhotoAlbumCategory,
|
||||
)
|
||||
const photoAlbumCategories =
|
||||
await connection.manager.find(PhotoAlbumCategory)
|
||||
photoAlbumCategories.length.should.be.equal(2)
|
||||
|
||||
const photoId1 =
|
||||
|
||||
@ -53,9 +53,8 @@ describe("view entity > mssql", () => {
|
||||
post2.categoryId = category2.id
|
||||
await connection.manager.save(post2)
|
||||
|
||||
const postCategories = await connection.manager.find(
|
||||
PostCategory,
|
||||
)
|
||||
const postCategories =
|
||||
await connection.manager.find(PostCategory)
|
||||
postCategories.length.should.be.equal(2)
|
||||
|
||||
postCategories[0].id.should.be.equal(1)
|
||||
|
||||
@ -53,9 +53,8 @@ describe("view entity > mysql", () => {
|
||||
post2.categoryId = category2.id
|
||||
await connection.manager.save(post2)
|
||||
|
||||
const postCategories = await connection.manager.find(
|
||||
PostCategory,
|
||||
)
|
||||
const postCategories =
|
||||
await connection.manager.find(PostCategory)
|
||||
postCategories.length.should.be.equal(2)
|
||||
|
||||
postCategories[0].id.should.be.equal(1)
|
||||
|
||||
@ -53,9 +53,8 @@ describe("view entity > oracle", () => {
|
||||
post2.categoryId = category2.id
|
||||
await connection.manager.save(post2)
|
||||
|
||||
const postCategories = await connection.manager.find(
|
||||
PostCategory,
|
||||
)
|
||||
const postCategories =
|
||||
await connection.manager.find(PostCategory)
|
||||
postCategories.length.should.be.equal(2)
|
||||
|
||||
postCategories[0].id.should.be.equal(1)
|
||||
|
||||
@ -47,17 +47,15 @@ describe("view entity > postgres", () => {
|
||||
post1.categoryId = category1.id
|
||||
await queryRunner.manager.save(post1)
|
||||
|
||||
const emptyResult = await queryRunner.manager.find(
|
||||
PostByCategory,
|
||||
)
|
||||
const emptyResult =
|
||||
await queryRunner.manager.find(PostByCategory)
|
||||
emptyResult.length.should.be.equal(0)
|
||||
|
||||
await queryRunner.query(
|
||||
"REFRESH MATERIALIZED VIEW post_by_category",
|
||||
)
|
||||
const resultWithData = await queryRunner.manager.find(
|
||||
PostByCategory,
|
||||
)
|
||||
const resultWithData =
|
||||
await queryRunner.manager.find(PostByCategory)
|
||||
resultWithData.length.should.be.equal(1)
|
||||
|
||||
expect(resultWithData[0].categoryName).to.eq(category1.name)
|
||||
@ -88,9 +86,8 @@ describe("view entity > postgres", () => {
|
||||
post2.categoryId = category2.id
|
||||
await connection.manager.save(post2)
|
||||
|
||||
const postCategories = await connection.manager.find(
|
||||
PostCategory,
|
||||
)
|
||||
const postCategories =
|
||||
await connection.manager.find(PostCategory)
|
||||
postCategories.length.should.be.equal(2)
|
||||
|
||||
postCategories[0].id.should.be.equal(1)
|
||||
|
||||
@ -53,9 +53,8 @@ describe("view entity > sqlite", () => {
|
||||
post2.categoryId = category2.id
|
||||
await connection.manager.save(post2)
|
||||
|
||||
const postCategories = await connection.manager.find(
|
||||
PostCategory,
|
||||
)
|
||||
const postCategories =
|
||||
await connection.manager.find(PostCategory)
|
||||
postCategories.length.should.be.equal(2)
|
||||
|
||||
postCategories[0].id.should.be.equal(1)
|
||||
|
||||
@ -13,7 +13,10 @@ export class AccountActivationToken extends Token {
|
||||
@JoinColumn()
|
||||
account: Account
|
||||
|
||||
constructor(public tokenSecret: string, public expiresOn: Date) {
|
||||
constructor(
|
||||
public tokenSecret: string,
|
||||
public expiresOn: Date,
|
||||
) {
|
||||
super()
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,9 +84,8 @@ describe("github issues > #2199 - Inserting value for @PrimaryGeneratedColumn()
|
||||
const successfulBarQuery = connection.manager.create(Bar, {
|
||||
description: "default id value",
|
||||
})
|
||||
const bar = await connection.manager.save(
|
||||
successfulBarQuery,
|
||||
)
|
||||
const bar =
|
||||
await connection.manager.save(successfulBarQuery)
|
||||
expect(bar.id).to.be.a("number")
|
||||
}),
|
||||
))
|
||||
|
||||
@ -42,9 +42,8 @@ describe("github issues > #3246 Saving an entity with a 1:1 cascading insert doe
|
||||
|
||||
const myCompanyRepository =
|
||||
connection.manager.getCustomRepository(BrokerRepository)
|
||||
const createdCompany = await myCompanyRepository.createBroker(
|
||||
company,
|
||||
)
|
||||
const createdCompany =
|
||||
await myCompanyRepository.createBroker(company)
|
||||
const myOrderRepository =
|
||||
connection.manager.getCustomRepository(OrderRepository)
|
||||
order.company = createdCompany
|
||||
|
||||
@ -40,9 +40,8 @@ describe("github issues > #7266 rename table typeorm_metadata name.", () => {
|
||||
|
||||
expect(hasCustomMetadataTableName).to.be.true
|
||||
|
||||
const hasDefaultMetadataTableName = await queryRunner.hasTable(
|
||||
"typeorm_metadata",
|
||||
)
|
||||
const hasDefaultMetadataTableName =
|
||||
await queryRunner.hasTable("typeorm_metadata")
|
||||
|
||||
expect(hasDefaultMetadataTableName).to.be.false
|
||||
|
||||
|
||||
@ -148,9 +148,8 @@ describe("github issues > #7558 Child entities' wrong discriminator value when e
|
||||
|
||||
// Save the tree...
|
||||
// We need to first save the parents step by step.
|
||||
const savedMulOperator = await operatorTreeRepo.save(
|
||||
mulOperator,
|
||||
)
|
||||
const savedMulOperator =
|
||||
await operatorTreeRepo.save(mulOperator)
|
||||
const plusOperator = nnaryOperatorRepo.create({
|
||||
parent: savedMulOperator,
|
||||
operator: "+",
|
||||
@ -158,9 +157,8 @@ describe("github issues > #7558 Child entities' wrong discriminator value when e
|
||||
num3.parent = savedMulOperator
|
||||
|
||||
await operatorTreeRepo.save(num3)
|
||||
const savedPlusOperator = await operatorTreeRepo.save(
|
||||
plusOperator,
|
||||
)
|
||||
const savedPlusOperator =
|
||||
await operatorTreeRepo.save(plusOperator)
|
||||
|
||||
num1.parent = savedPlusOperator
|
||||
num2.parent = savedPlusOperator
|
||||
|
||||
@ -39,9 +39,8 @@ describe("github issues > #8556 TreeRepository.findDescendants/Tree should retur
|
||||
name: "child",
|
||||
parent: root,
|
||||
} as Category)
|
||||
const descendantsIncludingParent = await repo.findDescendants(
|
||||
root,
|
||||
)
|
||||
const descendantsIncludingParent =
|
||||
await repo.findDescendants(root)
|
||||
expect(descendantsIncludingParent.length).to.be.equal(2)
|
||||
const descendantTree = await repo.findDescendantsTree(root)
|
||||
expect(descendantTree.children.length).to.be.equal(1)
|
||||
|
||||
@ -58,9 +58,8 @@ describe("github issues > #9534 materialized-path", () => {
|
||||
},
|
||||
])
|
||||
|
||||
const a11Parent = await categoryRepository.findAncestors(
|
||||
a11,
|
||||
)
|
||||
const a11Parent =
|
||||
await categoryRepository.findAncestors(a11)
|
||||
a11Parent.length.should.be.equal(2)
|
||||
a11Parent.should.deep.include({
|
||||
id: 1,
|
||||
@ -75,9 +74,8 @@ describe("github issues > #9534 materialized-path", () => {
|
||||
parentUid: "a1",
|
||||
})
|
||||
|
||||
const a1Children = await categoryRepository.findDescendants(
|
||||
a1,
|
||||
)
|
||||
const a1Children =
|
||||
await categoryRepository.findDescendants(a1)
|
||||
a1Children.length.should.be.equal(4)
|
||||
a1Children.should.deep.include({
|
||||
id: 1,
|
||||
|
||||
@ -44,7 +44,7 @@ describe("github issues > #9988 RelationIdLoader reuses the same queryplanner wi
|
||||
relationLoadStrategy: "query",
|
||||
where: { id },
|
||||
relations: { categories: true },
|
||||
} as FindManyOptions<Product>)
|
||||
}) as FindManyOptions<Product>
|
||||
|
||||
// Create a custom repository that uses a query builder without query planner
|
||||
// For both methods, relationLoadStrategy is set to "query", where the bug lies.
|
||||
|
||||
@ -31,9 +31,8 @@ describe("other issues > hydration performance", () => {
|
||||
|
||||
// select them using raw sql
|
||||
// console.time("select using raw sql");
|
||||
const loadedRawPosts = await connection.manager.query(
|
||||
"SELECT * FROM post",
|
||||
)
|
||||
const loadedRawPosts =
|
||||
await connection.manager.query("SELECT * FROM post")
|
||||
loadedRawPosts.length.should.be.equal(100000)
|
||||
// console.timeEnd("select using raw sql");
|
||||
|
||||
|
||||
@ -29,9 +29,8 @@ describe("ConnectionOptionsReader", () => {
|
||||
root: __dirname,
|
||||
configName: "configs/class-entities",
|
||||
})
|
||||
const options: DataSourceOptions = await connectionOptionsReader.get(
|
||||
"test-conn",
|
||||
)
|
||||
const options: DataSourceOptions =
|
||||
await connectionOptionsReader.get("test-conn")
|
||||
expect(options.entities).to.be.an.instanceOf(Array)
|
||||
const entities: EntititesList = options.entities as EntititesList
|
||||
expect(entities.length).to.equal(1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user