-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix typeorm vite bundle using a patch * remove comments * fix patch
- Loading branch information
Showing
4 changed files
with
252 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
diff --git a/browser/data-source/DataSource.js b/browser/data-source/DataSource.js | ||
index ac597a62857e6f05d1a7496ae9c49cdf6403c599..8a0530d03f0d51bca4c36bdb7e1a629683d4ab2f 100644 | ||
--- a/browser/data-source/DataSource.js | ||
+++ b/browser/data-source/DataSource.js | ||
@@ -13,6 +13,9 @@ import { ObjectUtils } from "../util/ObjectUtils"; | ||
import { RelationIdLoader } from "../query-builder/RelationIdLoader"; | ||
import { DriverUtils } from "../driver/DriverUtils"; | ||
import { InstanceChecker } from "../util/InstanceChecker"; | ||
+import { registerQueryBuilders } from "../query-builder"; | ||
+ | ||
+registerQueryBuilders() | ||
/** | ||
* DataSource is a pre-defined connection configuration to a specific database. | ||
* You can have multiple data sources connected (with multiple connections in it), | ||
diff --git a/browser/query-builder/QueryBuilder.js b/browser/query-builder/QueryBuilder.js | ||
index 3fdc1a9b88b663c100562c073a2371b64c248b4a..f45f2db8c65f7aaf05ffb9e7c7e7d3da73a5e253 100644 | ||
--- a/browser/query-builder/QueryBuilder.js | ||
+++ b/browser/query-builder/QueryBuilder.js | ||
@@ -23,6 +23,7 @@ import { escapeRegExp } from "../util/escapeRegExp"; | ||
* Allows to build complex sql queries in a fashion way and execute those queries. | ||
*/ | ||
export class QueryBuilder { | ||
+ static queryBuilderRegistry = {} | ||
/** | ||
* QueryBuilder can be initialized from given Connection and QueryRunner objects or from given other QueryBuilder. | ||
*/ | ||
@@ -71,10 +72,9 @@ export class QueryBuilder { | ||
]; | ||
} | ||
// loading it dynamically because of circular issue | ||
- const SelectQueryBuilderCls = require("./SelectQueryBuilder").SelectQueryBuilder; | ||
if (InstanceChecker.isSelectQueryBuilder(this)) | ||
return this; | ||
- return new SelectQueryBuilderCls(this); | ||
+ return QueryBuilder.queryBuilderRegistry["SelectQueryBuilder"](this); | ||
} | ||
/** | ||
* Creates INSERT query. | ||
@@ -82,10 +82,9 @@ export class QueryBuilder { | ||
insert() { | ||
this.expressionMap.queryType = "insert"; | ||
// loading it dynamically because of circular issue | ||
- const InsertQueryBuilderCls = require("./InsertQueryBuilder").InsertQueryBuilder; | ||
if (InstanceChecker.isInsertQueryBuilder(this)) | ||
return this; | ||
- return new InsertQueryBuilderCls(this); | ||
+ return QueryBuilder.queryBuilderRegistry["InsertQueryBuilder"](this); | ||
} | ||
/** | ||
* Creates UPDATE query and applies given update values. | ||
@@ -105,10 +104,9 @@ export class QueryBuilder { | ||
this.expressionMap.queryType = "update"; | ||
this.expressionMap.valuesSet = updateSet; | ||
// loading it dynamically because of circular issue | ||
- const UpdateQueryBuilderCls = require("./UpdateQueryBuilder").UpdateQueryBuilder; | ||
if (InstanceChecker.isUpdateQueryBuilder(this)) | ||
return this; | ||
- return new UpdateQueryBuilderCls(this); | ||
+ return QueryBuilder.queryBuilderRegistry["UpdateQueryBuilder"](this); | ||
} | ||
/** | ||
* Creates DELETE query. | ||
@@ -116,26 +114,23 @@ export class QueryBuilder { | ||
delete() { | ||
this.expressionMap.queryType = "delete"; | ||
// loading it dynamically because of circular issue | ||
- const DeleteQueryBuilderCls = require("./DeleteQueryBuilder").DeleteQueryBuilder; | ||
if (InstanceChecker.isDeleteQueryBuilder(this)) | ||
return this; | ||
- return new DeleteQueryBuilderCls(this); | ||
+ return QueryBuilder.queryBuilderRegistry["DeleteQueryBuilder"](this); | ||
} | ||
softDelete() { | ||
this.expressionMap.queryType = "soft-delete"; | ||
// loading it dynamically because of circular issue | ||
- const SoftDeleteQueryBuilderCls = require("./SoftDeleteQueryBuilder").SoftDeleteQueryBuilder; | ||
if (InstanceChecker.isSoftDeleteQueryBuilder(this)) | ||
return this; | ||
- return new SoftDeleteQueryBuilderCls(this); | ||
+ return QueryBuilder.queryBuilderRegistry["SoftDeleteQueryBuilder"](this); | ||
} | ||
restore() { | ||
this.expressionMap.queryType = "restore"; | ||
// loading it dynamically because of circular issue | ||
- const SoftDeleteQueryBuilderCls = require("./SoftDeleteQueryBuilder").SoftDeleteQueryBuilder; | ||
if (InstanceChecker.isSoftDeleteQueryBuilder(this)) | ||
return this; | ||
- return new SoftDeleteQueryBuilderCls(this); | ||
+ return QueryBuilder.queryBuilderRegistry["SoftDeleteQueryBuilder"](this); | ||
} | ||
/** | ||
* Sets entity's relation with which this query builder gonna work. | ||
@@ -152,10 +147,9 @@ export class QueryBuilder { | ||
this.expressionMap.setMainAlias(mainAlias); | ||
} | ||
// loading it dynamically because of circular issue | ||
- const RelationQueryBuilderCls = require("./RelationQueryBuilder").RelationQueryBuilder; | ||
if (InstanceChecker.isRelationQueryBuilder(this)) | ||
return this; | ||
- return new RelationQueryBuilderCls(this); | ||
+ return QueryBuilder.queryBuilderRegistry["RelationQueryBuilder"](this); | ||
} | ||
/** | ||
* Checks if given relation or relations exist in the entity. | ||
@@ -1120,6 +1114,9 @@ export class QueryBuilder { | ||
hasCommonTableExpressions() { | ||
return this.expressionMap.commonTableExpressions.length > 0; | ||
} | ||
+ static registerQueryBuilderClass(name, factory) { | ||
+ QueryBuilder.queryBuilderRegistry[name] = factory | ||
+ } | ||
} | ||
|
||
//# sourceMappingURL=QueryBuilder.js.map | ||
diff --git a/browser/query-builder/index.js b/browser/query-builder/index.js | ||
new file mode 100644 | ||
index 0000000000000000000000000000000000000000..794b3a665ac2b64a8ec42e64bca6b27b34d5cd5f | ||
--- /dev/null | ||
+++ b/browser/query-builder/index.js | ||
@@ -0,0 +1,34 @@ | ||
+import { DeleteQueryBuilder } from "./DeleteQueryBuilder" | ||
+import { InsertQueryBuilder } from "./InsertQueryBuilder" | ||
+import { QueryBuilder } from "./QueryBuilder" | ||
+import { RelationQueryBuilder } from "./RelationQueryBuilder" | ||
+import { SelectQueryBuilder } from "./SelectQueryBuilder" | ||
+import { SoftDeleteQueryBuilder } from "./SoftDeleteQueryBuilder" | ||
+import { UpdateQueryBuilder } from "./UpdateQueryBuilder" | ||
+ | ||
+export function registerQueryBuilders() { | ||
+ QueryBuilder.registerQueryBuilderClass( | ||
+ "DeleteQueryBuilder", | ||
+ (qb) => new DeleteQueryBuilder(qb), | ||
+ ) | ||
+ QueryBuilder.registerQueryBuilderClass( | ||
+ "InsertQueryBuilder", | ||
+ (qb) => new InsertQueryBuilder(qb), | ||
+ ) | ||
+ QueryBuilder.registerQueryBuilderClass( | ||
+ "RelationQueryBuilder", | ||
+ (qb) => new RelationQueryBuilder(qb), | ||
+ ) | ||
+ QueryBuilder.registerQueryBuilderClass( | ||
+ "SelectQueryBuilder", | ||
+ (qb) => new SelectQueryBuilder(qb), | ||
+ ) | ||
+ QueryBuilder.registerQueryBuilderClass( | ||
+ "SoftDeleteQueryBuilder", | ||
+ (qb) => new SoftDeleteQueryBuilder(qb), | ||
+ ) | ||
+ QueryBuilder.registerQueryBuilderClass( | ||
+ "UpdateQueryBuilder", | ||
+ (qb) => new UpdateQueryBuilder(qb), | ||
+ ) | ||
+} | ||
\ No newline at end of file | ||
diff --git a/data-source/DataSource.js b/data-source/DataSource.js | ||
index 1aedd237abde0c8f75d8852b5c49c43b82a216c2..5bb28b8f2d04eca0e39c0d4512eece22e4fcedd7 100644 | ||
--- a/data-source/DataSource.js | ||
+++ b/data-source/DataSource.js | ||
@@ -16,6 +16,7 @@ const ObjectUtils_1 = require("../util/ObjectUtils"); | ||
const RelationIdLoader_1 = require("../query-builder/RelationIdLoader"); | ||
const DriverUtils_1 = require("../driver/DriverUtils"); | ||
const InstanceChecker_1 = require("../util/InstanceChecker"); | ||
+ | ||
/** | ||
* DataSource is a pre-defined connection configuration to a specific database. | ||
* You can have multiple data sources connected (with multiple connections in it), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters