fib-orm 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/commands/ddlFrom.d.ts +1 -1
- package/lib/cli/commands/ddlFrom.js +1 -0
- package/lib/cli/commands/dumpModel.d.ts +1 -1
- package/lib/cli/commands/dumpModel.js +1 -0
- package/lib/cli/commands/escape.d.ts +1 -1
- package/lib/cli/commands/escape.js +1 -0
- package/lib/cli/commands/spinner.d.ts +1 -1
- package/lib/cli/commands/spinner.js +1 -0
- package/lib/cli/commands/upgrade.d.ts +1 -1
- package/lib/cli/commands/upgrade.js +1 -0
- package/lib/cli/helpers/ddl.d.ts +1 -1
- package/lib/cli/helpers/ddl.js +3 -3
- package/lib/cli/helpers/package.d.ts +0 -1
- package/lib/cli/helpers/package.js +4 -4
- package/lib/cli/index.js +1 -0
- package/lib/db-driver/Typo.d.ts +0 -1
- package/lib/db-driver/Typo.js +1 -0
- package/lib/db-driver/built-ins/base.class.d.ts +0 -5
- package/lib/db-driver/built-ins/base.class.js +1 -0
- package/lib/db-driver/built-ins/driver-dm.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-dm.js +1 -0
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-mongodb.js +1 -0
- package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-mysql.js +1 -0
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-postgresql.js +1 -0
- package/lib/db-driver/built-ins/driver-redis.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-redis.js +1 -0
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -1
- package/lib/db-driver/built-ins/driver-sqlite.js +1 -0
- package/lib/db-driver/index.js +1 -0
- package/lib/db-driver/utils.js +13 -13
- package/lib/knex/knex.js +1 -0
- package/lib/knex/sandbox.js +1 -0
- package/lib/orm/Adapters.js +3 -3
- package/lib/orm/AggregateFunctions.js +1 -0
- package/lib/orm/Associations/Extend.js +4 -4
- package/lib/orm/Associations/Many.d.ts +0 -1
- package/lib/orm/Associations/Many.js +6 -6
- package/lib/orm/Associations/One.js +4 -4
- package/lib/orm/Associations/_utils.d.ts +0 -1
- package/lib/orm/Associations/_utils.js +8 -7
- package/lib/orm/ChainFind.js +1 -0
- package/lib/orm/ChainInstance.js +1 -0
- package/lib/orm/Debug.js +4 -4
- package/lib/orm/Drivers/DB/base.d.ts +0 -1
- package/lib/orm/Drivers/DB/base.js +1 -0
- package/lib/orm/Drivers/DB/dm.d.ts +0 -2
- package/lib/orm/Drivers/DB/dm.js +1 -0
- package/lib/orm/Drivers/DB/mysql.d.ts +0 -2
- package/lib/orm/Drivers/DB/mysql.js +1 -0
- package/lib/orm/Drivers/DB/postgres.d.ts +0 -2
- package/lib/orm/Drivers/DB/postgres.js +1 -0
- package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -2
- package/lib/orm/Drivers/DB/sqlite3.js +1 -0
- package/lib/orm/Drivers/DML/_ddl-sql.js +1 -0
- package/lib/orm/Drivers/DML/_dml-helpers.js +6 -6
- package/lib/orm/Drivers/DML/_shared.js +5 -4
- package/lib/orm/Drivers/DML/_utils.js +7 -7
- package/lib/orm/Drivers/DML/constants.js +1 -0
- package/lib/orm/Drivers/DML/dm.js +1 -0
- package/lib/orm/Drivers/DML/index.js +1 -0
- package/lib/orm/Drivers/DML/mysql.js +1 -0
- package/lib/orm/Drivers/DML/postgres.d.ts +0 -1
- package/lib/orm/Drivers/DML/postgres.js +1 -0
- package/lib/orm/Drivers/DML/sqlite.js +1 -0
- package/lib/orm/Error.js +2 -1
- package/lib/orm/Helpers.js +22 -21
- package/lib/orm/Hook.js +1 -0
- package/lib/orm/Instance.js +1 -0
- package/lib/orm/LazyLoad.js +2 -2
- package/lib/orm/Model.d.ts +1 -2
- package/lib/orm/Model.js +7 -4
- package/lib/orm/ORM.js +1 -0
- package/lib/orm/Patch/fib-cache.d.ts +0 -1
- package/lib/orm/Patch/plugin.js +2 -1
- package/lib/orm/Property.js +2 -2
- package/lib/orm/Settings.js +3 -2
- package/lib/orm/Singleton.js +1 -0
- package/lib/orm/Typo/Adapter.js +1 -0
- package/lib/orm/Typo/DMLDriver.d.ts +0 -1
- package/lib/orm/Typo/DMLDriver.js +1 -0
- package/lib/orm/Typo/Db.d.ts +0 -3
- package/lib/orm/Typo/Db.js +1 -0
- package/lib/orm/Typo/Error.d.ts +0 -2
- package/lib/orm/Typo/Error.js +1 -0
- package/lib/orm/Typo/ORM.d.ts +0 -2
- package/lib/orm/Typo/ORM.js +1 -0
- package/lib/orm/Typo/Validators.d.ts +0 -1
- package/lib/orm/Typo/Validators.js +1 -0
- package/lib/orm/Typo/_common.d.ts +0 -1
- package/lib/orm/Typo/_common.js +1 -0
- package/lib/orm/Typo/assoc.js +1 -0
- package/lib/orm/Typo/hook.js +1 -0
- package/lib/orm/Typo/instance.d.ts +0 -1
- package/lib/orm/Typo/instance.js +1 -0
- package/lib/orm/Typo/model.d.ts +0 -2
- package/lib/orm/Typo/model.js +2 -1
- package/lib/orm/Typo/patch.js +1 -0
- package/lib/orm/Typo/property.js +1 -0
- package/lib/orm/Typo/query.js +1 -0
- package/lib/orm/Typo/settings.js +2 -1
- package/lib/orm/Typo/synchronous.js +1 -0
- package/lib/orm/Utilities.d.ts +1 -2
- package/lib/orm/Utilities.js +60 -60
- package/lib/orm/Validators.d.ts +0 -1
- package/lib/orm/Validators.js +4 -3
- package/lib/orm/Where/common.js +2 -2
- package/lib/orm/Where/filterDate.js +2 -2
- package/lib/orm/index.d.ts +0 -1
- package/lib/orm/index.js +7 -6
- package/lib/orm-core/callback.js +1 -0
- package/lib/orm-core/dialect.js +1 -0
- package/lib/orm-core/error.js +3 -3
- package/lib/orm-core/index.js +1 -0
- package/lib/orm-core/sync.js +1 -0
- package/lib/orm-core/utils.js +1 -0
- package/lib/orm-property/Property.js +1 -0
- package/lib/orm-property/Utils.js +2 -2
- package/lib/orm-property/customTypes.js +2 -2
- package/lib/orm-property/index.js +3 -2
- package/lib/orm-property/transformer.js +2 -2
- package/lib/orm-property/transformers/dm.js +1 -0
- package/lib/orm-property/transformers/index.js +1 -0
- package/lib/orm-property/transformers/mysql.d.ts +0 -1
- package/lib/orm-property/transformers/mysql.js +1 -0
- package/lib/orm-property/transformers/postgresql.js +1 -0
- package/lib/orm-property/transformers/sqlite.js +1 -0
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/dm.js +1 -0
- package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/index.js +1 -0
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/mysql.js +1 -0
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/postgresql.js +1 -0
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -1
- package/lib/sql-ddl-sync/Dialects/sqlite.js +1 -0
- package/lib/sql-ddl-sync/SQL.js +11 -11
- package/lib/sql-ddl-sync/Typo/Collection.js +1 -0
- package/lib/sql-ddl-sync/Typo/DbIndex.js +1 -0
- package/lib/sql-ddl-sync/Typo/Dialect.js +1 -0
- package/lib/sql-ddl-sync/Typo/Driver.js +1 -0
- package/lib/sql-ddl-sync/Typo/Query.js +1 -0
- package/lib/sql-ddl-sync/Typo/SQL.js +1 -0
- package/lib/sql-ddl-sync/Typo/_common.js +1 -0
- package/lib/sql-ddl-sync/Utils.d.ts +0 -1
- package/lib/sql-ddl-sync/Utils.js +14 -14
- package/lib/sql-ddl-sync/index.js +3 -2
- package/lib/sql-query/Comparators.js +1 -0
- package/lib/sql-query/Create.js +1 -0
- package/lib/sql-query/Dialects/dm.js +1 -0
- package/lib/sql-query/Dialects/index.js +1 -0
- package/lib/sql-query/Dialects/mssql.js +1 -0
- package/lib/sql-query/Dialects/mysql.js +1 -0
- package/lib/sql-query/Dialects/postgresql.js +1 -0
- package/lib/sql-query/Dialects/sqlite.js +1 -0
- package/lib/sql-query/Helpers.d.ts +0 -1
- package/lib/sql-query/Helpers.js +21 -20
- package/lib/sql-query/Insert.js +1 -0
- package/lib/sql-query/Query.d.ts +0 -1
- package/lib/sql-query/Query.js +1 -0
- package/lib/sql-query/Remove.js +1 -0
- package/lib/sql-query/Select.js +1 -0
- package/lib/sql-query/Set.js +2 -2
- package/lib/sql-query/Typo/Aggregation.js +1 -0
- package/lib/sql-query/Typo/Comparators.js +1 -0
- package/lib/sql-query/Typo/Dialect.js +1 -0
- package/lib/sql-query/Typo/Field.js +1 -0
- package/lib/sql-query/Typo/Helper.js +1 -0
- package/lib/sql-query/Typo/Query-ChainBuilder.js +1 -0
- package/lib/sql-query/Typo/Query.js +2 -1
- package/lib/sql-query/Typo/Sql.js +1 -0
- package/lib/sql-query/Typo/SubQuery.js +1 -0
- package/lib/sql-query/Typo/index.js +1 -0
- package/lib/sql-query/Update.js +1 -0
- package/lib/sql-query/Where.js +2 -2
- package/package.json +9 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.defineTransformer =
|
|
3
|
+
exports.defineTransformer = defineTransformer;
|
|
3
4
|
function defineTransformer(opts) {
|
|
4
5
|
const { rawToProperty, toStorageType, } = opts;
|
|
5
6
|
return {
|
|
@@ -7,4 +8,3 @@ function defineTransformer(opts) {
|
|
|
7
8
|
toStorageType,
|
|
8
9
|
};
|
|
9
10
|
}
|
|
10
|
-
exports.defineTransformer = defineTransformer;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.toRawType = exports.removeIndex = exports.removeIndexSync = exports.addIndex = exports.addIndexSync = exports.getCollectionIndexes = exports.getCollectionIndexesSync = exports.dropCollectionColumn = exports.dropCollectionColumnSync = exports.modifyCollectionColumn = exports.modifyCollectionColumnSync = exports.renameCollectionColumn = exports.renameCollectionColumnSync = exports.addCollectionColumn = exports.addCollectionColumnSync = exports.hasCollectionColumns = exports.hasCollectionColumnsSync = exports.dropCollection = exports.dropCollectionSync = exports.createCollection = exports.createCollectionSync = exports.getCollectionProperties = exports.getCollectionPropertiesSync = exports.getCollectionColumns = exports.getCollectionColumnsSync = exports.dropForeignKey = exports.dropForeignKeySync = exports.addForeignKey = exports.addForeignKeySync = exports.dropPrimaryKey = exports.dropPrimaryKeySync = exports.addPrimaryKey = exports.addPrimaryKeySync = exports.hasCollection = exports.hasCollectionSync = exports.convertIndexes = void 0;
|
|
3
4
|
const FxORMCore = require("../../orm-core/index");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.toRawType = exports.removeIndex = exports.removeIndexSync = exports.addIndex = exports.addIndexSync = exports.getCollectionIndexes = exports.getCollectionIndexesSync = exports.dropCollectionColumn = exports.dropCollectionColumnSync = exports.modifyCollectionColumn = exports.modifyCollectionColumnSync = exports.renameCollectionColumn = exports.renameCollectionColumnSync = exports.addCollectionColumn = exports.addCollectionColumnSync = exports.hasCollectionColumns = exports.hasCollectionColumnsSync = exports.dropCollection = exports.dropCollectionSync = exports.createCollection = exports.createCollectionSync = exports.getCollectionProperties = exports.getCollectionPropertiesSync = exports.getCollectionColumns = exports.getCollectionColumnsSync = exports.dropForeignKey = exports.dropForeignKeySync = exports.addForeignKey = exports.addForeignKeySync = exports.dropPrimaryKey = exports.dropPrimaryKeySync = exports.addPrimaryKey = exports.addPrimaryKeySync = exports.hasCollection = exports.hasCollectionSync = void 0;
|
|
3
4
|
const FxORMCore = require("../../orm-core/index");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.toRawType = exports.convertIndexes = exports.removeIndex = exports.removeIndexSync = exports.addIndex = exports.addIndexSync = exports.getCollectionIndexes = exports.getCollectionIndexesSync = exports.dropCollectionColumn = exports.dropCollectionColumnSync = exports.modifyCollectionColumn = exports.modifyCollectionColumnSync = exports.renameCollectionColumn = exports.renameCollectionColumnSync = exports.addCollectionColumn = exports.addCollectionColumnSync = exports.hasCollectionColumns = exports.hasCollectionColumnsSync = exports.getCollectionColumns = exports.getCollectionColumnsSync = exports.dropForeignKey = exports.dropForeignKeySync = exports.addForeignKey = exports.addForeignKeySync = exports.dropPrimaryKey = exports.dropPrimaryKeySync = exports.addPrimaryKey = exports.addPrimaryKeySync = exports.dropCollection = exports.dropCollectionSync = exports.createCollection = exports.createCollectionSync = exports.getCollectionProperties = exports.getCollectionPropertiesSync = exports.hasCollection = exports.hasCollectionSync = void 0;
|
|
3
4
|
const coroutine = require("coroutine");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
exports.toRawType = exports.supportsType = exports.processKeys = exports.removeIndex = exports.removeIndexSync = exports.addIndex = exports.addIndexSync = exports.getCollectionIndexes = exports.getCollectionIndexesSync = exports.dropCollectionColumn = exports.dropCollectionColumnSync = exports.modifyCollectionColumn = exports.modifyCollectionColumnSync = exports.renameCollectionColumn = exports.renameCollectionColumnSync = exports.addCollectionColumn = exports.addCollectionColumnSync = exports.hasCollectionColumns = exports.hasCollectionColumnsSync = exports.dropCollection = exports.dropCollectionSync = exports.createCollection = exports.createCollectionSync = exports.getCollectionProperties = exports.getCollectionPropertiesSync = exports.getCollectionColumns = exports.getCollectionColumnsSync = exports.dropForeignKey = exports.dropForeignKeySync = exports.addForeignKey = exports.addForeignKeySync = exports.dropPrimaryKey = exports.dropPrimaryKeySync = exports.addPrimaryKey = exports.addPrimaryKeySync = exports.hasCollection = exports.hasCollectionSync = void 0;
|
|
3
4
|
const FxORMCore = require("../../orm-core/index");
|
package/lib/sql-ddl-sync/SQL.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.
|
|
3
|
+
exports.CREATE_TABLE = CREATE_TABLE;
|
|
4
|
+
exports.ALTER_TABLE_COMMENT = ALTER_TABLE_COMMENT;
|
|
5
|
+
exports.DROP_TABLE = DROP_TABLE;
|
|
6
|
+
exports.CHECK_TABLE_HAS_COLUMN = CHECK_TABLE_HAS_COLUMN;
|
|
7
|
+
exports.ALTER_TABLE_ADD_COLUMN = ALTER_TABLE_ADD_COLUMN;
|
|
8
|
+
exports.ALTER_TABLE_RENAME_COLUMN = ALTER_TABLE_RENAME_COLUMN;
|
|
9
|
+
exports.ALTER_TABLE_MODIFY_COLUMN = ALTER_TABLE_MODIFY_COLUMN;
|
|
10
|
+
exports.ALTER_TABLE_DROP_COLUMN = ALTER_TABLE_DROP_COLUMN;
|
|
11
|
+
exports.CREATE_INDEX = CREATE_INDEX;
|
|
12
|
+
exports.DROP_INDEX = DROP_INDEX;
|
|
3
13
|
const Utils_1 = require("./Utils");
|
|
4
14
|
function CREATE_TABLE(options, db_type) {
|
|
5
15
|
let sql = "CREATE TABLE " + (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(options.name) + " (" + options.columns.join(", ");
|
|
@@ -14,7 +24,6 @@ function CREATE_TABLE(options, db_type) {
|
|
|
14
24
|
}
|
|
15
25
|
return sql;
|
|
16
26
|
}
|
|
17
|
-
exports.CREATE_TABLE = CREATE_TABLE;
|
|
18
27
|
;
|
|
19
28
|
function ALTER_TABLE_COMMENT(db_type, table, comment) {
|
|
20
29
|
switch (db_type) {
|
|
@@ -33,12 +42,10 @@ function ALTER_TABLE_COMMENT(db_type, table, comment) {
|
|
|
33
42
|
}
|
|
34
43
|
}
|
|
35
44
|
}
|
|
36
|
-
exports.ALTER_TABLE_COMMENT = ALTER_TABLE_COMMENT;
|
|
37
45
|
function DROP_TABLE(options, db_type) {
|
|
38
46
|
const sql = "DROP TABLE " + (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(options.name);
|
|
39
47
|
return sql;
|
|
40
48
|
}
|
|
41
|
-
exports.DROP_TABLE = DROP_TABLE;
|
|
42
49
|
;
|
|
43
50
|
function CHECK_TABLE_HAS_COLUMN(options, db_type) {
|
|
44
51
|
const eid = (0, Utils_1.getSqlQueryDialect)(db_type).escapeId;
|
|
@@ -52,7 +59,6 @@ function CHECK_TABLE_HAS_COLUMN(options, db_type) {
|
|
|
52
59
|
].filter(x => x).join('');
|
|
53
60
|
return sql;
|
|
54
61
|
}
|
|
55
|
-
exports.CHECK_TABLE_HAS_COLUMN = CHECK_TABLE_HAS_COLUMN;
|
|
56
62
|
;
|
|
57
63
|
function ALTER_TABLE_ADD_COLUMN(options, db_type) {
|
|
58
64
|
const sql = [
|
|
@@ -63,7 +69,6 @@ function ALTER_TABLE_ADD_COLUMN(options, db_type) {
|
|
|
63
69
|
].filter(x => x).join('');
|
|
64
70
|
return sql;
|
|
65
71
|
}
|
|
66
|
-
exports.ALTER_TABLE_ADD_COLUMN = ALTER_TABLE_ADD_COLUMN;
|
|
67
72
|
;
|
|
68
73
|
function ALTER_TABLE_RENAME_COLUMN(opts, db_type) {
|
|
69
74
|
const eid = (0, Utils_1.getSqlQueryDialect)(db_type).escapeId;
|
|
@@ -71,20 +76,17 @@ function ALTER_TABLE_RENAME_COLUMN(opts, db_type) {
|
|
|
71
76
|
" RENAME COLUMN " + eid(opts.oldColName) + " TO " + eid(opts.newColName);
|
|
72
77
|
return sql;
|
|
73
78
|
}
|
|
74
|
-
exports.ALTER_TABLE_RENAME_COLUMN = ALTER_TABLE_RENAME_COLUMN;
|
|
75
79
|
function ALTER_TABLE_MODIFY_COLUMN(options, db_type) {
|
|
76
80
|
const sql = "ALTER TABLE " + (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(options.name) +
|
|
77
81
|
" MODIFY " + options.column;
|
|
78
82
|
return sql;
|
|
79
83
|
}
|
|
80
|
-
exports.ALTER_TABLE_MODIFY_COLUMN = ALTER_TABLE_MODIFY_COLUMN;
|
|
81
84
|
;
|
|
82
85
|
function ALTER_TABLE_DROP_COLUMN(options, db_type) {
|
|
83
86
|
const sql = "ALTER TABLE " + (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(options.name) +
|
|
84
87
|
(db_type === 'dm' ? " DROP COLUMN " : " DROP ") + (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(options.column);
|
|
85
88
|
return sql;
|
|
86
89
|
}
|
|
87
|
-
exports.ALTER_TABLE_DROP_COLUMN = ALTER_TABLE_DROP_COLUMN;
|
|
88
90
|
;
|
|
89
91
|
function CREATE_INDEX(options, db_type) {
|
|
90
92
|
const sql = "CREATE" + (options.unique ? " UNIQUE" : "") + " INDEX " + (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(options.name) +
|
|
@@ -92,7 +94,6 @@ function CREATE_INDEX(options, db_type) {
|
|
|
92
94
|
" (" + options.columns.map(function (col) { return (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(col); }) + ")";
|
|
93
95
|
return sql;
|
|
94
96
|
}
|
|
95
|
-
exports.CREATE_INDEX = CREATE_INDEX;
|
|
96
97
|
;
|
|
97
98
|
function DROP_INDEX(options, db_type) {
|
|
98
99
|
const sql = db_type === 'dm'
|
|
@@ -101,7 +102,6 @@ function DROP_INDEX(options, db_type) {
|
|
|
101
102
|
" ON " + (0, Utils_1.getSqlQueryDialect)(db_type).escapeId(options.collection);
|
|
102
103
|
return sql;
|
|
103
104
|
}
|
|
104
|
-
exports.DROP_INDEX = DROP_INDEX;
|
|
105
105
|
;
|
|
106
106
|
// export function RENAME_TABLE (options, driver: FxOrmSqlDDLSync__Driver.Driver) {
|
|
107
107
|
// const sql = "ALTER TABLE " + options.oldCollectionName + " RENAME TO " + options.newCollectionName + " ;";
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/// <reference types="@fibjs/types" />
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
+
exports.logJson = logJson;
|
|
5
|
+
exports.addSqlQueryDialect = addSqlQueryDialect;
|
|
6
|
+
exports.getAllSqlQueryDialects = getAllSqlQueryDialects;
|
|
7
|
+
exports.getSqlQueryDialect = getSqlQueryDialect;
|
|
8
|
+
exports.arraify = arraify;
|
|
9
|
+
exports.getCollectionMapsTo_PropertyNameDict = getCollectionMapsTo_PropertyNameDict;
|
|
10
|
+
exports.filterPropertyDefaultValue = filterPropertyDefaultValue;
|
|
11
|
+
exports.filterSyncStrategy = filterSyncStrategy;
|
|
12
|
+
exports.filterSuppressColumnDrop = filterSuppressColumnDrop;
|
|
13
|
+
exports.psqlGetEnumTypeName = psqlGetEnumTypeName;
|
|
14
|
+
exports.psqlRepairEnumTypes = psqlRepairEnumTypes;
|
|
15
|
+
exports.extractCollectionIndexes = extractCollectionIndexes;
|
|
16
|
+
exports.normalizeDefinedProperty = normalizeDefinedProperty;
|
|
4
17
|
const coroutine = require("coroutine");
|
|
5
18
|
function logJson(group, detail) {
|
|
6
19
|
let json = null;
|
|
@@ -14,16 +27,13 @@ function logJson(group, detail) {
|
|
|
14
27
|
console.notice(json);
|
|
15
28
|
return json;
|
|
16
29
|
}
|
|
17
|
-
exports.logJson = logJson;
|
|
18
30
|
const sqlQueryDialects = require("../sql-query/Dialects");
|
|
19
31
|
function addSqlQueryDialect(type, Dialect) {
|
|
20
32
|
sqlQueryDialects[type] = Dialect;
|
|
21
33
|
}
|
|
22
|
-
exports.addSqlQueryDialect = addSqlQueryDialect;
|
|
23
34
|
function getAllSqlQueryDialects(type) {
|
|
24
35
|
return Object.assign(Object.assign({}, sqlQueryDialects), { psql: sqlQueryDialects['postgresql'] });
|
|
25
36
|
}
|
|
26
|
-
exports.getAllSqlQueryDialects = getAllSqlQueryDialects;
|
|
27
37
|
function getSqlQueryDialect(type) {
|
|
28
38
|
switch (type) {
|
|
29
39
|
default:
|
|
@@ -42,11 +52,9 @@ function getSqlQueryDialect(type) {
|
|
|
42
52
|
return sqlQueryDialects[type];
|
|
43
53
|
}
|
|
44
54
|
}
|
|
45
|
-
exports.getSqlQueryDialect = getSqlQueryDialect;
|
|
46
55
|
function arraify(item) {
|
|
47
56
|
return Array.isArray(item) ? item : [item];
|
|
48
57
|
}
|
|
49
|
-
exports.arraify = arraify;
|
|
50
58
|
function getCollectionMapsTo_PropertyNameDict(collection) {
|
|
51
59
|
const hash = {};
|
|
52
60
|
Object.keys(collection.properties).forEach(pname => {
|
|
@@ -56,7 +64,6 @@ function getCollectionMapsTo_PropertyNameDict(collection) {
|
|
|
56
64
|
});
|
|
57
65
|
return hash;
|
|
58
66
|
}
|
|
59
|
-
exports.getCollectionMapsTo_PropertyNameDict = getCollectionMapsTo_PropertyNameDict;
|
|
60
67
|
function filterPropertyDefaultValue(property, ctx) {
|
|
61
68
|
let _dftValue;
|
|
62
69
|
if (property.hasOwnProperty('defaultValue'))
|
|
@@ -67,7 +74,6 @@ function filterPropertyDefaultValue(property, ctx) {
|
|
|
67
74
|
_dftValue = property.defaultValue;
|
|
68
75
|
return _dftValue;
|
|
69
76
|
}
|
|
70
|
-
exports.filterPropertyDefaultValue = filterPropertyDefaultValue;
|
|
71
77
|
function filterSyncStrategy(strategy) {
|
|
72
78
|
switch (strategy) {
|
|
73
79
|
case 'hard':
|
|
@@ -80,17 +86,14 @@ function filterSyncStrategy(strategy) {
|
|
|
80
86
|
}
|
|
81
87
|
return strategy;
|
|
82
88
|
}
|
|
83
|
-
exports.filterSyncStrategy = filterSyncStrategy;
|
|
84
89
|
function filterSuppressColumnDrop(suppressColumnDrop, db_type) {
|
|
85
90
|
if (db_type === 'sqlite')
|
|
86
91
|
return true;
|
|
87
92
|
return !!suppressColumnDrop;
|
|
88
93
|
}
|
|
89
|
-
exports.filterSuppressColumnDrop = filterSuppressColumnDrop;
|
|
90
94
|
function psqlGetEnumTypeName(collection_name, column_name) {
|
|
91
95
|
return `${collection_name}_enum_${column_name.toLowerCase()}`;
|
|
92
96
|
}
|
|
93
|
-
exports.psqlGetEnumTypeName = psqlGetEnumTypeName;
|
|
94
97
|
function psqlRepairEnumTypes(columns, collection_name, dbdriver) {
|
|
95
98
|
const enumProperties = Object.values(columns).filter(col => col.type === 'enum');
|
|
96
99
|
if (!enumProperties.length)
|
|
@@ -107,7 +110,6 @@ function psqlRepairEnumTypes(columns, collection_name, dbdriver) {
|
|
|
107
110
|
dbdriver.execute(`CREATE TYPE ${type} AS ENUM (${values})`);
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
|
-
exports.psqlRepairEnumTypes = psqlRepairEnumTypes;
|
|
111
113
|
/**
|
|
112
114
|
* @description compute system's index name by dialect type
|
|
113
115
|
*
|
|
@@ -198,7 +200,6 @@ function extractCollectionIndexes(collection, property_key, property, driver_typ
|
|
|
198
200
|
}
|
|
199
201
|
return ret_indexes;
|
|
200
202
|
}
|
|
201
|
-
exports.extractCollectionIndexes = extractCollectionIndexes;
|
|
202
203
|
/** @internal this will change input */
|
|
203
204
|
function normalizeDefinedProperty(property, driver_type) {
|
|
204
205
|
if (driver_type === 'mysql') {
|
|
@@ -214,4 +215,3 @@ function normalizeDefinedProperty(property, driver_type) {
|
|
|
214
215
|
}
|
|
215
216
|
return property;
|
|
216
217
|
}
|
|
217
|
-
exports.normalizeDefinedProperty = normalizeDefinedProperty;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.Sync =
|
|
3
|
+
exports.Sync = void 0;
|
|
4
|
+
exports.dialect = dialect;
|
|
3
5
|
const FxORMCore = require("../orm-core/index");
|
|
4
6
|
const util = require("util");
|
|
5
7
|
const Utils_1 = require("./Utils");
|
|
@@ -22,7 +24,6 @@ function dialect(name) {
|
|
|
22
24
|
throw new Error(`no dialect with name '${name}'`);
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
|
-
exports.dialect = dialect;
|
|
26
27
|
function alterCollectionComment(collection, dbdriver) {
|
|
27
28
|
if (dbdriver.type === 'sqlite')
|
|
28
29
|
return;
|
package/lib/sql-query/Create.js
CHANGED
package/lib/sql-query/Helpers.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// Transforms:
|
|
2
3
|
// "name LIKE ? AND age > ?", ["John", 23]
|
|
3
4
|
// into:
|
|
4
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.ChainBuilderBase = exports.
|
|
6
|
+
exports.ChainBuilderBase = exports.DialectTypes = void 0;
|
|
7
|
+
exports.escapeQuery = escapeQuery;
|
|
8
|
+
exports.dateToString = dateToString;
|
|
9
|
+
exports.zeroPad = zeroPad;
|
|
10
|
+
exports.get_table_alias = get_table_alias;
|
|
11
|
+
exports.parseTableInputStr = parseTableInputStr;
|
|
12
|
+
exports.pickAliasFromFromDescriptor = pickAliasFromFromDescriptor;
|
|
13
|
+
exports.pickColumnAsFromSelectFieldsDescriptor = pickColumnAsFromSelectFieldsDescriptor;
|
|
14
|
+
exports.autoIncreatementTableIndex = autoIncreatementTableIndex;
|
|
15
|
+
exports.defaultTableAliasNameRule = defaultTableAliasNameRule;
|
|
16
|
+
exports.ucfirst = ucfirst;
|
|
17
|
+
exports.ensureNumber = ensureNumber;
|
|
18
|
+
exports.bufferToString = bufferToString;
|
|
19
|
+
exports.escapeValForKnex = escapeValForKnex;
|
|
20
|
+
exports.cutOffOrderDirectionFromColumnFirstStr = cutOffOrderDirectionFromColumnFirstStr;
|
|
21
|
+
exports.maybeKnexSubQuery = maybeKnexSubQuery;
|
|
22
|
+
exports.maybeKnexRaw = maybeKnexRaw;
|
|
23
|
+
exports.maybeKnexRawOrQueryBuilder = maybeKnexRawOrQueryBuilder;
|
|
24
|
+
exports.isWrapperdSubQuerySelect = isWrapperdSubQuerySelect;
|
|
25
|
+
exports.convertSqlFromTable = convertSqlFromTable;
|
|
6
26
|
// "name LIKE 'John' AND age > 23"
|
|
7
27
|
function escapeQuery(Dialect, query, args) {
|
|
8
28
|
let pos = 0;
|
|
@@ -15,7 +35,6 @@ function escapeQuery(Dialect, query, args) {
|
|
|
15
35
|
}
|
|
16
36
|
});
|
|
17
37
|
}
|
|
18
|
-
exports.escapeQuery = escapeQuery;
|
|
19
38
|
function dateToString(date, timeZone, opts) {
|
|
20
39
|
const dt = new Date(date);
|
|
21
40
|
if (timeZone != 'local') {
|
|
@@ -39,7 +58,6 @@ function dateToString(date, timeZone, opts) {
|
|
|
39
58
|
return year + '-' + month + '-' + day + 'T' + hour + ':' + minute + ':' + second + '.' + milli + 'Z';
|
|
40
59
|
}
|
|
41
60
|
}
|
|
42
|
-
exports.dateToString = dateToString;
|
|
43
61
|
function zeroPad(number, n = 2) {
|
|
44
62
|
number = "" + number;
|
|
45
63
|
while (number.length < n) {
|
|
@@ -47,7 +65,6 @@ function zeroPad(number, n = 2) {
|
|
|
47
65
|
}
|
|
48
66
|
return number;
|
|
49
67
|
}
|
|
50
|
-
exports.zeroPad = zeroPad;
|
|
51
68
|
function convertTimezone(tz) {
|
|
52
69
|
if (tz == "Z")
|
|
53
70
|
return 0;
|
|
@@ -65,7 +82,6 @@ function get_table_alias(sql, table) {
|
|
|
65
82
|
}
|
|
66
83
|
return typeof table === 'string' ? table : '';
|
|
67
84
|
}
|
|
68
|
-
exports.get_table_alias = get_table_alias;
|
|
69
85
|
;
|
|
70
86
|
// TODO: add test about it
|
|
71
87
|
function unwrapIdentifier(identifier = '', dialect) {
|
|
@@ -110,29 +126,23 @@ function parseTableInputStr(table_name, dialect) {
|
|
|
110
126
|
}
|
|
111
127
|
return ta_tuple;
|
|
112
128
|
}
|
|
113
|
-
exports.parseTableInputStr = parseTableInputStr;
|
|
114
129
|
function pickAliasFromFromDescriptor(fd) {
|
|
115
130
|
return fd.alias || fd.a;
|
|
116
131
|
}
|
|
117
|
-
exports.pickAliasFromFromDescriptor = pickAliasFromFromDescriptor;
|
|
118
132
|
function pickColumnAsFromSelectFieldsDescriptor(sitem) {
|
|
119
133
|
return sitem.as || sitem.a;
|
|
120
134
|
}
|
|
121
|
-
exports.pickColumnAsFromSelectFieldsDescriptor = pickColumnAsFromSelectFieldsDescriptor;
|
|
122
135
|
function autoIncreatementTableIndex(from) {
|
|
123
136
|
return from.length + 1;
|
|
124
137
|
}
|
|
125
|
-
exports.autoIncreatementTableIndex = autoIncreatementTableIndex;
|
|
126
138
|
function defaultTableAliasNameRule(idx) {
|
|
127
139
|
return `t${idx}`;
|
|
128
140
|
}
|
|
129
|
-
exports.defaultTableAliasNameRule = defaultTableAliasNameRule;
|
|
130
141
|
function ucfirst(str = '') {
|
|
131
142
|
if (str.length <= 1)
|
|
132
143
|
return str.toUpperCase();
|
|
133
144
|
return str[0].toUpperCase() + str.slice(1);
|
|
134
145
|
}
|
|
135
|
-
exports.ucfirst = ucfirst;
|
|
136
146
|
function ensureNumber(num) {
|
|
137
147
|
if (typeof num !== 'number') {
|
|
138
148
|
num = parseInt(num);
|
|
@@ -141,7 +151,6 @@ function ensureNumber(num) {
|
|
|
141
151
|
return 0;
|
|
142
152
|
return num;
|
|
143
153
|
}
|
|
144
|
-
exports.ensureNumber = ensureNumber;
|
|
145
154
|
function bufferToString(buffer, dialect) {
|
|
146
155
|
switch (dialect) {
|
|
147
156
|
case 'dm':
|
|
@@ -156,7 +165,6 @@ function bufferToString(buffer, dialect) {
|
|
|
156
165
|
return "'\\x" + buffer.toString('hex') + "'";
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
|
-
exports.bufferToString = bufferToString;
|
|
160
168
|
exports.DialectTypes = ['mysql', 'sqlite', 'mssql', 'postgresql', 'dm'];
|
|
161
169
|
function escapeValForKnex(val, Dialect, opts) {
|
|
162
170
|
// no escape for `knex.raw(...)`, `knex.ref(...)` and subquery
|
|
@@ -193,7 +201,6 @@ function escapeValForKnex(val, Dialect, opts) {
|
|
|
193
201
|
return val = null;
|
|
194
202
|
return Dialect.escapeVal(val, opts.timezone);
|
|
195
203
|
}
|
|
196
|
-
exports.escapeValForKnex = escapeValForKnex;
|
|
197
204
|
function cutOffOrderDirectionFromColumnFirstStr(col_name) {
|
|
198
205
|
const result = {
|
|
199
206
|
col_name,
|
|
@@ -207,23 +214,18 @@ function cutOffOrderDirectionFromColumnFirstStr(col_name) {
|
|
|
207
214
|
}
|
|
208
215
|
return result;
|
|
209
216
|
}
|
|
210
|
-
exports.cutOffOrderDirectionFromColumnFirstStr = cutOffOrderDirectionFromColumnFirstStr;
|
|
211
217
|
function maybeKnexSubQuery(input) {
|
|
212
218
|
return typeof (input === null || input === void 0 ? void 0 : input.toQuery) === "function";
|
|
213
219
|
}
|
|
214
|
-
exports.maybeKnexSubQuery = maybeKnexSubQuery;
|
|
215
220
|
function maybeKnexRaw(input) {
|
|
216
221
|
return typeof (input === null || input === void 0 ? void 0 : input.toQuery) === "function";
|
|
217
222
|
}
|
|
218
|
-
exports.maybeKnexRaw = maybeKnexRaw;
|
|
219
223
|
function maybeKnexRawOrQueryBuilder(input) {
|
|
220
224
|
return typeof (input === null || input === void 0 ? void 0 : input.toQuery) === "function";
|
|
221
225
|
}
|
|
222
|
-
exports.maybeKnexRawOrQueryBuilder = maybeKnexRawOrQueryBuilder;
|
|
223
226
|
function isWrapperdSubQuerySelect(sql) {
|
|
224
227
|
return typeof sql === 'string' && /^\(\s*SELECT\s.*\)$/i.test(sql);
|
|
225
228
|
}
|
|
226
|
-
exports.isWrapperdSubQuerySelect = isWrapperdSubQuerySelect;
|
|
227
229
|
/** @internal */
|
|
228
230
|
function convertSqlFromTable(sql_from_item, knex, isSubQuery) {
|
|
229
231
|
var _a, _b;
|
|
@@ -233,7 +235,6 @@ function convertSqlFromTable(sql_from_item, knex, isSubQuery) {
|
|
|
233
235
|
: isSubQuery ? knex.raw(sql_from_item.table.trim()).wrap('', '')
|
|
234
236
|
: sql_from_item.table;
|
|
235
237
|
}
|
|
236
|
-
exports.convertSqlFromTable = convertSqlFromTable;
|
|
237
238
|
class ChainBuilderBase {
|
|
238
239
|
constructor(Dialect) {
|
|
239
240
|
this.Dialect = Dialect;
|
package/lib/sql-query/Insert.js
CHANGED
package/lib/sql-query/Query.d.ts
CHANGED
package/lib/sql-query/Query.js
CHANGED
package/lib/sql-query/Remove.js
CHANGED
package/lib/sql-query/Select.js
CHANGED
package/lib/sql-query/Set.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.build =
|
|
3
|
+
exports.build = build;
|
|
3
4
|
const Helpers_1 = require("./Helpers");
|
|
4
5
|
function build(knexQueryBuilder, Dialect, set, opts) {
|
|
5
6
|
opts = opts || {};
|
|
@@ -12,5 +13,4 @@ function build(knexQueryBuilder, Dialect, set, opts) {
|
|
|
12
13
|
}
|
|
13
14
|
knexQueryBuilder.update(safeSet);
|
|
14
15
|
}
|
|
15
|
-
exports.build = build;
|
|
16
16
|
;
|