fib-orm 2.0.0 → 3.0.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/README.md +42 -6
- package/index.d.ts +11 -0
- package/index.js +15 -0
- package/package.json +36 -34
- package/{lib/cli/commands/ddlFrom.js → src/cli/commands/ddlFrom.ts} +40 -26
- package/{lib/cli/commands/dumpModel.js → src/cli/commands/dumpModel.ts} +78 -31
- package/{lib/cli/commands/escape.js → src/cli/commands/escape.ts} +51 -28
- package/{lib/cli/commands/spinner.js → src/cli/commands/spinner.ts} +20 -10
- package/{lib/cli/commands/upgrade.js → src/cli/commands/upgrade.ts} +53 -33
- package/src/cli/helpers/ddl.ts +84 -0
- package/src/cli/helpers/package.ts +81 -0
- package/src/cli/index.ts +24 -0
- package/src/cli/wrapSubcommand.ts +66 -0
- package/src/db-driver/Typo.d.ts +141 -0
- package/src/db-driver/built-ins/base.class.ts +260 -0
- package/src/db-driver/built-ins/driver-dm.ts +62 -0
- package/src/db-driver/built-ins/driver-mssql.ts +67 -0
- package/src/db-driver/built-ins/driver-mysql.ts +44 -0
- package/src/db-driver/built-ins/driver-postgresql.ts +94 -0
- package/src/db-driver/built-ins/driver-redis.ts +45 -0
- package/src/db-driver/built-ins/driver-sqlite.ts +41 -0
- package/src/db-driver/index.ts +6 -0
- package/src/db-driver/parseQueryString.ts +76 -0
- package/src/db-driver/utils.ts +204 -0
- package/src/knex/deps/tarn/PendingOperation.ts +56 -0
- package/src/knex/deps/tarn/Pool.ts +610 -0
- package/src/knex/deps/tarn/PromiseInspection.ts +29 -0
- package/src/knex/deps/tarn/Resource.ts +22 -0
- package/src/knex/deps/tarn/TimeoutError.ts +1 -0
- package/src/knex/deps/tarn/tarn.ts +7 -0
- package/src/knex/deps/tarn/utils.ts +62 -0
- package/src/knex/knex.ts +11 -0
- package/src/knex/result.d.ts +27 -0
- package/src/knex/sandbox.ts +45 -0
- package/src/knex/tables.d.ts +4 -0
- package/src/knex/types.d.ts +3228 -0
- package/src/orm/Adapters.ts +53 -0
- package/src/orm/AggregateFunctions.ts +254 -0
- package/src/orm/Associations/Extend.ts +405 -0
- package/src/orm/Associations/Many.ts +784 -0
- package/src/orm/Associations/One.ts +494 -0
- package/src/orm/Associations/_utils.ts +72 -0
- package/src/orm/ChainFind.ts +427 -0
- package/src/orm/ChainInstance.ts +97 -0
- package/src/orm/Debug.ts +21 -0
- package/src/orm/Drivers/DB/base.ts +7 -0
- package/src/orm/Drivers/DB/dm.ts +35 -0
- package/src/orm/Drivers/DB/mssql.ts +35 -0
- package/src/orm/Drivers/DB/mysql.ts +35 -0
- package/src/orm/Drivers/DB/postgres.ts +35 -0
- package/src/orm/Drivers/DB/sqlite3.ts +60 -0
- package/src/orm/Drivers/DML/_ddl-sql.ts +85 -0
- package/src/orm/Drivers/DML/_dml-helpers.ts +66 -0
- package/src/orm/Drivers/DML/_shared.ts +61 -0
- package/src/orm/Drivers/DML/_utils.ts +112 -0
- package/{lib/orm/Drivers/DML/dm.js → src/orm/Drivers/DML/dm.ts} +178 -85
- package/src/orm/Drivers/DML/index.ts +10 -0
- package/src/orm/Drivers/DML/mssql.ts +366 -0
- package/src/orm/Drivers/DML/mysql.ts +347 -0
- package/src/orm/Drivers/DML/postgres.ts +382 -0
- package/src/orm/Drivers/DML/sqlite.ts +361 -0
- package/src/orm/Error.ts +49 -0
- package/src/orm/Helpers.ts +297 -0
- package/src/orm/Hook.ts +125 -0
- package/src/orm/Instance.ts +944 -0
- package/src/orm/LazyLoad.ts +117 -0
- package/src/orm/Model.ts +1235 -0
- package/src/orm/ORM.ts +301 -0
- package/src/orm/Patch/fib-cache.ts +7 -0
- package/src/orm/Patch/plugin.ts +25 -0
- package/src/orm/Property.ts +86 -0
- package/src/orm/Settings.ts +134 -0
- package/src/orm/Singleton.ts +97 -0
- package/src/orm/Typo/Adapter.d.ts +5 -0
- package/src/orm/Typo/DMLDriver.d.ts +260 -0
- package/src/orm/Typo/Db.d.ts +100 -0
- package/src/orm/Typo/Error.d.ts +36 -0
- package/src/orm/Typo/ORM.d.ts +315 -0
- package/src/orm/Typo/Validators.d.ts +39 -0
- package/src/orm/Typo/_common.d.ts +44 -0
- package/src/orm/Typo/assoc.d.ts +280 -0
- package/src/orm/Typo/hook.d.ts +68 -0
- package/src/orm/Typo/instance.d.ts +214 -0
- package/{lib → src}/orm/Typo/model.d.ts +297 -176
- package/src/orm/Typo/patch.d.ts +39 -0
- package/src/orm/Typo/property.d.ts +79 -0
- package/src/orm/Typo/query.d.ts +266 -0
- package/{lib → src}/orm/Typo/settings.d.ts +14 -7
- package/{lib → src}/orm/Typo/synchronous.d.ts +51 -26
- package/src/orm/Utilities.ts +1313 -0
- package/src/orm/Validators.ts +127 -0
- package/src/orm/Where/common.ts +8 -0
- package/src/orm/Where/filterDate.ts +74 -0
- package/src/orm/cloneDeep.ts +45 -0
- package/src/orm/index.ts +231 -0
- package/src/orm-core/callback.d.ts +15 -0
- package/{lib → src}/orm-core/dialect.d.ts +75 -52
- package/src/orm-core/error.ts +71 -0
- package/{lib/orm-core/index.d.ts → src/orm-core/index.ts} +8 -2
- package/src/orm-core/sync.d.ts +14 -0
- package/src/orm-core/utils.ts +4 -0
- package/src/orm-property/Property.ts +110 -0
- package/src/orm-property/Utils.ts +26 -0
- package/src/orm-property/customTypes.ts +13 -0
- package/src/orm-property/index.ts +34 -0
- package/src/orm-property/transformer.ts +16 -0
- package/{lib/orm-property/transformers/dm.js → src/orm-property/transformers/dm.ts} +128 -68
- package/src/orm-property/transformers/index.ts +10 -0
- package/src/orm-property/transformers/mssql.ts +285 -0
- package/src/orm-property/transformers/mysql.ts +395 -0
- package/src/orm-property/transformers/postgresql.ts +267 -0
- package/src/orm-property/transformers/sqlite.ts +217 -0
- package/src/plugins/orm-plugin-uacl/Typo.d.ts +173 -0
- package/src/plugins/orm-plugin-uacl/_utils.ts +237 -0
- package/src/plugins/orm-plugin-uacl/acl-tree.ts +440 -0
- package/src/plugins/orm-plugin-uacl/config-acl-tree.ts +592 -0
- package/src/plugins/orm-plugin-uacl/index.ts +180 -0
- package/src/plugins/orm-plugin-uacl/tree.ts +331 -0
- package/src/sql-ddl-sync/Dialects/dm.ts +493 -0
- package/{lib/sql-query/Dialects/index.d.ts → src/sql-ddl-sync/Dialects/index.ts} +3 -3
- package/src/sql-ddl-sync/Dialects/mssql.ts +441 -0
- package/src/sql-ddl-sync/Dialects/mysql.ts +414 -0
- package/src/sql-ddl-sync/Dialects/postgresql.ts +474 -0
- package/src/sql-ddl-sync/Dialects/sqlite.ts +439 -0
- package/src/sql-ddl-sync/SQL.ts +157 -0
- package/src/sql-ddl-sync/Typo/Collection.d.ts +19 -0
- package/src/sql-ddl-sync/Typo/DbIndex.d.ts +11 -0
- package/{lib → src}/sql-ddl-sync/Typo/Dialect.d.ts +67 -52
- package/src/sql-ddl-sync/Typo/Driver.d.ts +67 -0
- package/src/sql-ddl-sync/Typo/Query.d.ts +8 -0
- package/src/sql-ddl-sync/Typo/SQL.d.ts +45 -0
- package/src/sql-ddl-sync/Typo/_common.d.ts +59 -0
- package/src/sql-ddl-sync/Utils.ts +291 -0
- package/src/sql-ddl-sync/index.ts +599 -0
- package/src/sql-query/Comparators.ts +115 -0
- package/src/sql-query/Create.ts +87 -0
- package/{lib/sql-query/Dialects/dm.js → src/sql-query/Dialects/dm.ts} +42 -21
- package/src/sql-query/Dialects/index.ts +14 -0
- package/src/sql-query/Dialects/mssql.ts +91 -0
- package/src/sql-query/Dialects/mysql.ts +120 -0
- package/src/sql-query/Dialects/postgresql.ts +99 -0
- package/src/sql-query/Dialects/sqlite.ts +80 -0
- package/src/sql-query/Helpers.ts +303 -0
- package/src/sql-query/Insert.ts +41 -0
- package/src/sql-query/Query.ts +140 -0
- package/src/sql-query/Remove.ts +111 -0
- package/src/sql-query/Select.ts +719 -0
- package/src/sql-query/Set.ts +25 -0
- package/src/sql-query/Typo/Aggregation.d.ts +34 -0
- package/src/sql-query/Typo/Comparators.d.ts +156 -0
- package/src/sql-query/Typo/Dialect.d.ts +51 -0
- package/src/sql-query/Typo/Field.d.ts +10 -0
- package/src/sql-query/Typo/Helper.d.ts +4 -0
- package/src/sql-query/Typo/Query-ChainBuilder.d.ts +110 -0
- package/src/sql-query/Typo/Query.d.ts +65 -0
- package/src/sql-query/Typo/Sql.d.ts +192 -0
- package/src/sql-query/Typo/SubQuery.d.ts +52 -0
- package/{lib/sql-query/Typo/index.d.ts → src/sql-query/Typo/index.ts} +5 -2
- package/src/sql-query/Update.ts +50 -0
- package/src/sql-query/Where.ts +435 -0
- package/{lib/orm/Patch → src/typings}/fib-cache.d.ts +4 -3
- package/lib/cli/commands/ddlFrom.d.ts +0 -2
- package/lib/cli/commands/dumpModel.d.ts +0 -2
- package/lib/cli/commands/escape.d.ts +0 -2
- package/lib/cli/commands/spinner.d.ts +0 -2
- package/lib/cli/commands/upgrade.d.ts +0 -2
- package/lib/cli/helpers/ddl.d.ts +0 -17
- package/lib/cli/helpers/ddl.js +0 -55
- package/lib/cli/helpers/package.d.ts +0 -26
- package/lib/cli/helpers/package.js +0 -56
- package/lib/cli/index.d.ts +0 -2
- package/lib/cli/index.js +0 -18
- package/lib/db-driver/Typo.d.ts +0 -112
- package/lib/db-driver/Typo.js +0 -1
- package/lib/db-driver/built-ins/base.class.d.ts +0 -96
- package/lib/db-driver/built-ins/base.class.js +0 -186
- package/lib/db-driver/built-ins/driver-dm.d.ts +0 -18
- package/lib/db-driver/built-ins/driver-dm.js +0 -53
- package/lib/db-driver/built-ins/driver-mongodb.d.ts +0 -24
- package/lib/db-driver/built-ins/driver-mongodb.js +0 -46
- package/lib/db-driver/built-ins/driver-mysql.d.ts +0 -18
- package/lib/db-driver/built-ins/driver-mysql.js +0 -37
- package/lib/db-driver/built-ins/driver-postgresql.d.ts +0 -22
- package/lib/db-driver/built-ins/driver-postgresql.js +0 -76
- package/lib/db-driver/built-ins/driver-redis.d.ts +0 -12
- package/lib/db-driver/built-ins/driver-redis.js +0 -35
- package/lib/db-driver/built-ins/driver-sqlite.d.ts +0 -17
- package/lib/db-driver/built-ins/driver-sqlite.js +0 -34
- package/lib/db-driver/index.d.ts +0 -3
- package/lib/db-driver/index.js +0 -4
- package/lib/db-driver/utils.d.ts +0 -14
- package/lib/db-driver/utils.js +0 -187
- package/lib/knex/deps/tarn/dist/PendingOperation.d.ts +0 -12
- package/lib/knex/deps/tarn/dist/PendingOperation.js +0 -48
- package/lib/knex/deps/tarn/dist/Pool.d.ts +0 -97
- package/lib/knex/deps/tarn/dist/Pool.js +0 -516
- package/lib/knex/deps/tarn/dist/PromiseInspection.d.ts +0 -16
- package/lib/knex/deps/tarn/dist/PromiseInspection.js +0 -21
- package/lib/knex/deps/tarn/dist/Resource.d.ts +0 -9
- package/lib/knex/deps/tarn/dist/Resource.js +0 -19
- package/lib/knex/deps/tarn/dist/TimeoutError.d.ts +0 -2
- package/lib/knex/deps/tarn/dist/TimeoutError.js +0 -5
- package/lib/knex/deps/tarn/dist/tarn.d.ts +0 -3
- package/lib/knex/deps/tarn/dist/tarn.js +0 -10
- package/lib/knex/deps/tarn/dist/utils.d.ts +0 -14
- package/lib/knex/deps/tarn/dist/utils.js +0 -60
- package/lib/knex/knex.d.ts +0 -2
- package/lib/knex/knex.js +0 -3
- package/lib/knex/sandbox.d.ts +0 -4
- package/lib/knex/sandbox.js +0 -22
- package/lib/orm/Adapters.d.ts +0 -3
- package/lib/orm/Adapters.js +0 -44
- package/lib/orm/AggregateFunctions.d.ts +0 -3
- package/lib/orm/AggregateFunctions.js +0 -176
- package/lib/orm/Associations/Extend.d.ts +0 -22
- package/lib/orm/Associations/Extend.js +0 -274
- package/lib/orm/Associations/Many.d.ts +0 -17
- package/lib/orm/Associations/Many.js +0 -569
- package/lib/orm/Associations/One.d.ts +0 -16
- package/lib/orm/Associations/One.js +0 -310
- package/lib/orm/Associations/_utils.d.ts +0 -15
- package/lib/orm/Associations/_utils.js +0 -52
- package/lib/orm/ChainFind.d.ts +0 -3
- package/lib/orm/ChainFind.js +0 -327
- package/lib/orm/ChainInstance.d.ts +0 -6
- package/lib/orm/ChainInstance.js +0 -73
- package/lib/orm/Debug.d.ts +0 -2
- package/lib/orm/Debug.js +0 -17
- package/lib/orm/Drivers/DB/base.d.ts +0 -3
- package/lib/orm/Drivers/DB/base.js +0 -3
- package/lib/orm/Drivers/DB/dm.d.ts +0 -11
- package/lib/orm/Drivers/DB/dm.js +0 -23
- package/lib/orm/Drivers/DB/mysql.d.ts +0 -11
- package/lib/orm/Drivers/DB/mysql.js +0 -23
- package/lib/orm/Drivers/DB/postgres.d.ts +0 -11
- package/lib/orm/Drivers/DB/postgres.js +0 -22
- package/lib/orm/Drivers/DB/sqlite3.d.ts +0 -16
- package/lib/orm/Drivers/DB/sqlite3.js +0 -39
- package/lib/orm/Drivers/DML/_ddl-sql.d.ts +0 -3
- package/lib/orm/Drivers/DML/_ddl-sql.js +0 -51
- package/lib/orm/Drivers/DML/_dml-helpers.d.ts +0 -19
- package/lib/orm/Drivers/DML/_dml-helpers.js +0 -51
- package/lib/orm/Drivers/DML/_shared.d.ts +0 -9
- package/lib/orm/Drivers/DML/_shared.js +0 -38
- package/lib/orm/Drivers/DML/_utils.d.ts +0 -8
- package/lib/orm/Drivers/DML/_utils.js +0 -67
- package/lib/orm/Drivers/DML/constants.d.ts +0 -3
- package/lib/orm/Drivers/DML/constants.js +0 -2
- package/lib/orm/Drivers/DML/dm.d.ts +0 -2
- package/lib/orm/Drivers/DML/index.d.ts +0 -4
- package/lib/orm/Drivers/DML/index.js +0 -6
- package/lib/orm/Drivers/DML/mysql.d.ts +0 -2
- package/lib/orm/Drivers/DML/mysql.js +0 -251
- package/lib/orm/Drivers/DML/postgres.d.ts +0 -3
- package/lib/orm/Drivers/DML/postgres.js +0 -276
- package/lib/orm/Drivers/DML/sqlite.d.ts +0 -2
- package/lib/orm/Drivers/DML/sqlite.js +0 -266
- package/lib/orm/Error.d.ts +0 -11
- package/lib/orm/Error.js +0 -40
- package/lib/orm/Helpers.d.ts +0 -35
- package/lib/orm/Helpers.js +0 -233
- package/lib/orm/Hook.d.ts +0 -13
- package/lib/orm/Hook.js +0 -99
- package/lib/orm/Instance.d.ts +0 -2
- package/lib/orm/Instance.js +0 -697
- package/lib/orm/LazyLoad.d.ts +0 -4
- package/lib/orm/LazyLoad.js +0 -76
- package/lib/orm/Model.d.ts +0 -7
- package/lib/orm/Model.js +0 -971
- package/lib/orm/ORM.d.ts +0 -37
- package/lib/orm/ORM.js +0 -241
- package/lib/orm/Patch/fib-cache.js +0 -2
- package/lib/orm/Patch/plugin.d.ts +0 -4
- package/lib/orm/Patch/plugin.js +0 -13
- package/lib/orm/Property.d.ts +0 -9
- package/lib/orm/Property.js +0 -71
- package/lib/orm/Settings.d.ts +0 -42
- package/lib/orm/Settings.js +0 -119
- package/lib/orm/Singleton.d.ts +0 -5
- package/lib/orm/Singleton.js +0 -72
- package/lib/orm/Typo/Adapter.d.ts +0 -5
- package/lib/orm/Typo/Adapter.js +0 -1
- package/lib/orm/Typo/DMLDriver.d.ts +0 -210
- package/lib/orm/Typo/DMLDriver.js +0 -1
- package/lib/orm/Typo/Db.d.ts +0 -38
- package/lib/orm/Typo/Db.js +0 -1
- package/lib/orm/Typo/Error.d.ts +0 -31
- package/lib/orm/Typo/Error.js +0 -1
- package/lib/orm/Typo/ORM.d.ts +0 -233
- package/lib/orm/Typo/ORM.js +0 -3
- package/lib/orm/Typo/Validators.d.ts +0 -32
- package/lib/orm/Typo/Validators.js +0 -2
- package/lib/orm/Typo/_common.d.ts +0 -38
- package/lib/orm/Typo/_common.js +0 -1
- package/lib/orm/Typo/assoc.d.ts +0 -221
- package/lib/orm/Typo/assoc.js +0 -1
- package/lib/orm/Typo/hook.d.ts +0 -42
- package/lib/orm/Typo/hook.js +0 -1
- package/lib/orm/Typo/instance.d.ts +0 -157
- package/lib/orm/Typo/instance.js +0 -1
- package/lib/orm/Typo/model.js +0 -6
- package/lib/orm/Typo/patch.d.ts +0 -31
- package/lib/orm/Typo/patch.js +0 -1
- package/lib/orm/Typo/property.d.ts +0 -57
- package/lib/orm/Typo/property.js +0 -1
- package/lib/orm/Typo/query.d.ts +0 -216
- package/lib/orm/Typo/query.js +0 -1
- package/lib/orm/Typo/settings.js +0 -5
- package/lib/orm/Typo/synchronous.js +0 -1
- package/lib/orm/Utilities.d.ts +0 -179
- package/lib/orm/Utilities.js +0 -975
- package/lib/orm/Validators.d.ts +0 -34
- package/lib/orm/Validators.js +0 -100
- package/lib/orm/Where/common.d.ts +0 -1
- package/lib/orm/Where/common.js +0 -7
- package/lib/orm/Where/filterDate.d.ts +0 -11
- package/lib/orm/Where/filterDate.js +0 -58
- package/lib/orm/index.d.ts +0 -68
- package/lib/orm/index.js +0 -157
- package/lib/orm-core/callback.d.ts +0 -12
- package/lib/orm-core/callback.js +0 -1
- package/lib/orm-core/dialect.js +0 -1
- package/lib/orm-core/error.d.ts +0 -16
- package/lib/orm-core/error.js +0 -29
- package/lib/orm-core/index.js +0 -6
- package/lib/orm-core/sync.d.ts +0 -12
- package/lib/orm-core/sync.js +0 -1
- package/lib/orm-core/utils.d.ts +0 -1
- package/lib/orm-core/utils.js +0 -5
- package/lib/orm-property/Property.d.ts +0 -78
- package/lib/orm-property/Property.js +0 -1
- package/lib/orm-property/Utils.d.ts +0 -9
- package/lib/orm-property/Utils.js +0 -13
- package/lib/orm-property/customTypes.d.ts +0 -2
- package/lib/orm-property/customTypes.js +0 -13
- package/lib/orm-property/index.d.ts +0 -10
- package/lib/orm-property/index.js +0 -22
- package/lib/orm-property/transformer.d.ts +0 -5
- package/lib/orm-property/transformer.js +0 -10
- package/lib/orm-property/transformers/dm.d.ts +0 -29
- package/lib/orm-property/transformers/index.d.ts +0 -4
- package/lib/orm-property/transformers/index.js +0 -5
- package/lib/orm-property/transformers/mysql.d.ts +0 -102
- package/lib/orm-property/transformers/mysql.js +0 -261
- package/lib/orm-property/transformers/postgresql.d.ts +0 -54
- package/lib/orm-property/transformers/postgresql.js +0 -189
- package/lib/orm-property/transformers/sqlite.d.ts +0 -19
- package/lib/orm-property/transformers/sqlite.js +0 -171
- package/lib/sql-ddl-sync/Dialects/dm.d.ts +0 -40
- package/lib/sql-ddl-sync/Dialects/dm.js +0 -296
- package/lib/sql-ddl-sync/Dialects/index.d.ts +0 -7
- package/lib/sql-ddl-sync/Dialects/index.js +0 -7
- package/lib/sql-ddl-sync/Dialects/mysql.d.ts +0 -39
- package/lib/sql-ddl-sync/Dialects/mysql.js +0 -240
- package/lib/sql-ddl-sync/Dialects/postgresql.d.ts +0 -40
- package/lib/sql-ddl-sync/Dialects/postgresql.js +0 -286
- package/lib/sql-ddl-sync/Dialects/sqlite.d.ts +0 -44
- package/lib/sql-ddl-sync/Dialects/sqlite.js +0 -256
- package/lib/sql-ddl-sync/SQL.d.ts +0 -12
- package/lib/sql-ddl-sync/SQL.js +0 -108
- package/lib/sql-ddl-sync/Typo/Collection.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/Collection.js +0 -1
- package/lib/sql-ddl-sync/Typo/DbIndex.d.ts +0 -13
- package/lib/sql-ddl-sync/Typo/DbIndex.js +0 -1
- package/lib/sql-ddl-sync/Typo/Dialect.js +0 -1
- package/lib/sql-ddl-sync/Typo/Driver.d.ts +0 -53
- package/lib/sql-ddl-sync/Typo/Driver.js +0 -1
- package/lib/sql-ddl-sync/Typo/Query.d.ts +0 -7
- package/lib/sql-ddl-sync/Typo/Query.js +0 -1
- package/lib/sql-ddl-sync/Typo/SQL.d.ts +0 -31
- package/lib/sql-ddl-sync/Typo/SQL.js +0 -1
- package/lib/sql-ddl-sync/Typo/_common.d.ts +0 -29
- package/lib/sql-ddl-sync/Typo/_common.js +0 -1
- package/lib/sql-ddl-sync/Utils.d.ts +0 -40
- package/lib/sql-ddl-sync/Utils.js +0 -217
- package/lib/sql-ddl-sync/index.d.ts +0 -87
- package/lib/sql-ddl-sync/index.js +0 -371
- package/lib/sql-query/Comparators.d.ts +0 -3
- package/lib/sql-query/Comparators.js +0 -94
- package/lib/sql-query/Create.d.ts +0 -35
- package/lib/sql-query/Create.js +0 -77
- package/lib/sql-query/Dialects/dm.d.ts +0 -3
- package/lib/sql-query/Dialects/index.js +0 -12
- package/lib/sql-query/Dialects/mssql.d.ts +0 -3
- package/lib/sql-query/Dialects/mssql.js +0 -73
- package/lib/sql-query/Dialects/mysql.d.ts +0 -3
- package/lib/sql-query/Dialects/mysql.js +0 -100
- package/lib/sql-query/Dialects/postgresql.d.ts +0 -3
- package/lib/sql-query/Dialects/postgresql.js +0 -76
- package/lib/sql-query/Dialects/sqlite.d.ts +0 -3
- package/lib/sql-query/Dialects/sqlite.js +0 -61
- package/lib/sql-query/Helpers.d.ts +0 -38
- package/lib/sql-query/Helpers.js +0 -259
- package/lib/sql-query/Insert.d.ts +0 -12
- package/lib/sql-query/Insert.js +0 -33
- package/lib/sql-query/Query.d.ts +0 -29
- package/lib/sql-query/Query.js +0 -119
- package/lib/sql-query/Remove.d.ts +0 -16
- package/lib/sql-query/Remove.js +0 -93
- package/lib/sql-query/Select.d.ts +0 -62
- package/lib/sql-query/Select.js +0 -533
- package/lib/sql-query/Set.d.ts +0 -4
- package/lib/sql-query/Set.js +0 -16
- package/lib/sql-query/Typo/Aggregation.d.ts +0 -32
- package/lib/sql-query/Typo/Aggregation.js +0 -1
- package/lib/sql-query/Typo/Comparators.d.ts +0 -140
- package/lib/sql-query/Typo/Comparators.js +0 -1
- package/lib/sql-query/Typo/Dialect.d.ts +0 -39
- package/lib/sql-query/Typo/Dialect.js +0 -1
- package/lib/sql-query/Typo/Field.d.ts +0 -8
- package/lib/sql-query/Typo/Field.js +0 -1
- package/lib/sql-query/Typo/Helper.d.ts +0 -4
- package/lib/sql-query/Typo/Helper.js +0 -1
- package/lib/sql-query/Typo/Query-ChainBuilder.d.ts +0 -80
- package/lib/sql-query/Typo/Query-ChainBuilder.js +0 -1
- package/lib/sql-query/Typo/Query.d.ts +0 -34
- package/lib/sql-query/Typo/Query.js +0 -16
- package/lib/sql-query/Typo/Sql.d.ts +0 -143
- package/lib/sql-query/Typo/Sql.js +0 -1
- package/lib/sql-query/Typo/SubQuery.d.ts +0 -39
- package/lib/sql-query/Typo/SubQuery.js +0 -1
- package/lib/sql-query/Typo/index.js +0 -1
- package/lib/sql-query/Update.d.ts +0 -15
- package/lib/sql-query/Update.js +0 -38
- package/lib/sql-query/Where.d.ts +0 -4
- package/lib/sql-query/Where.js +0 -280
- /package/{lib → src}/codepoints-map.json +0 -0
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
import * as FxORMCore from '../../orm-core/index';
|
|
4
|
+
import {type IProperty, transformer} from "../../orm-property/index";
|
|
5
|
+
|
|
6
|
+
import * as SQL from '../SQL';
|
|
7
|
+
import type { FxOrmSqlDDLSync__DbIndex } from "../Typo/DbIndex";
|
|
8
|
+
import type { FxOrmSqlDDLSync__Dialect } from "../Typo/Dialect";
|
|
9
|
+
import { getSqlQueryDialect, arraify } from '../Utils';
|
|
10
|
+
|
|
11
|
+
const Transformer = transformer('dm')
|
|
12
|
+
|
|
13
|
+
type IDialect = FxOrmSqlDDLSync__Dialect.Dialect<Class_DbConnection>;
|
|
14
|
+
|
|
15
|
+
export const convertIndexes: IDialect['convertIndexes'] = function (
|
|
16
|
+
collection, index_defs
|
|
17
|
+
) {
|
|
18
|
+
const prefix = `${collection}_`;
|
|
19
|
+
return index_defs.map(indexDef => {
|
|
20
|
+
if (indexDef.name && indexDef.name.startsWith(prefix)) {
|
|
21
|
+
return indexDef;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
...indexDef,
|
|
25
|
+
name: `${prefix}${indexDef.name}`
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function fetchPrimaryKeys(dbdriver: any, name: string) {
|
|
31
|
+
const rows = dbdriver.execute(
|
|
32
|
+
getSqlQueryDialect('dm').escape(
|
|
33
|
+
[
|
|
34
|
+
"SELECT col.COLUMN_NAME ",
|
|
35
|
+
"FROM ALL_CONSTRAINTS con ",
|
|
36
|
+
"JOIN ALL_CONS_COLUMNS col ",
|
|
37
|
+
"ON con.CONSTRAINT_NAME = col.CONSTRAINT_NAME AND con.OWNER = col.OWNER ",
|
|
38
|
+
"WHERE con.CONSTRAINT_TYPE = 'P' ",
|
|
39
|
+
"AND con.TABLE_NAME = UPPER(?) ",
|
|
40
|
+
"AND con.OWNER = USER"
|
|
41
|
+
].join(''),
|
|
42
|
+
[name]
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const set = new Set<string>();
|
|
47
|
+
rows.forEach((row: any) => {
|
|
48
|
+
const col = row.COLUMN_NAME || row.column_name;
|
|
49
|
+
if (col) set.add(String(col));
|
|
50
|
+
});
|
|
51
|
+
return set;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const hasCollectionSync: IDialect['hasCollectionSync'] = function (
|
|
55
|
+
dbdriver, name
|
|
56
|
+
): boolean {
|
|
57
|
+
const rows = dbdriver.execute(
|
|
58
|
+
getSqlQueryDialect('dm').escape(
|
|
59
|
+
"SELECT TABLE_NAME FROM ALL_TABLES WHERE TABLE_NAME = UPPER(?) AND OWNER = USER",
|
|
60
|
+
[name]
|
|
61
|
+
)
|
|
62
|
+
) as any[]
|
|
63
|
+
return rows.length > 0;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const hasCollection: IDialect['hasCollection'] = function (
|
|
67
|
+
dbdriver, name, cb
|
|
68
|
+
) {
|
|
69
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
70
|
+
() => hasCollectionSync(dbdriver, name)
|
|
71
|
+
)
|
|
72
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const addPrimaryKeySync: IDialect['addPrimaryKeySync'] = function (
|
|
76
|
+
dbdriver, tableName, columnName
|
|
77
|
+
) {
|
|
78
|
+
return dbdriver.execute(
|
|
79
|
+
getSqlQueryDialect('dm').escape(
|
|
80
|
+
"ALTER TABLE ?? ADD CONSTRAINT ?? PRIMARY KEY(??)",
|
|
81
|
+
[tableName, columnName + "_PK", columnName]
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const addPrimaryKey: IDialect['addPrimaryKey'] = function (
|
|
87
|
+
dbdriver, tableName, columnName, cb
|
|
88
|
+
) {
|
|
89
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
90
|
+
() => addPrimaryKeySync(dbdriver, tableName, columnName)
|
|
91
|
+
)
|
|
92
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export const dropPrimaryKeySync: IDialect['dropPrimaryKeySync'] = function (
|
|
96
|
+
dbdriver, tableName, columnName
|
|
97
|
+
) {
|
|
98
|
+
return dbdriver.execute(
|
|
99
|
+
getSqlQueryDialect('dm').escape(
|
|
100
|
+
"ALTER TABLE ?? DROP PRIMARY KEY",
|
|
101
|
+
[tableName]
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export const dropPrimaryKey: IDialect['dropPrimaryKey'] = function (
|
|
107
|
+
dbdriver, tableName, columnName, cb
|
|
108
|
+
) {
|
|
109
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
110
|
+
() => dropPrimaryKeySync(dbdriver, tableName, columnName)
|
|
111
|
+
)
|
|
112
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const addForeignKeySync: IDialect['addForeignKeySync'] = function (
|
|
116
|
+
dbdriver, tableName, options
|
|
117
|
+
) {
|
|
118
|
+
return dbdriver.execute(
|
|
119
|
+
getSqlQueryDialect('dm').escape(
|
|
120
|
+
"ALTER TABLE ?? ADD CONSTRAINT ?? FOREIGN KEY(??) REFERENCES ??(??)",
|
|
121
|
+
[tableName, options.name + "_fk", options.name, options.references.table, options.references.column]
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const addForeignKey: IDialect['addForeignKey'] = function (
|
|
127
|
+
dbdriver, tableName, options, cb
|
|
128
|
+
) {
|
|
129
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
130
|
+
() => addForeignKeySync(dbdriver, tableName, options)
|
|
131
|
+
)
|
|
132
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const dropForeignKeySync: IDialect['dropForeignKeySync'] = function (
|
|
136
|
+
dbdriver, tableName, columnName
|
|
137
|
+
) {
|
|
138
|
+
return dbdriver.execute(
|
|
139
|
+
getSqlQueryDialect('dm').escape(
|
|
140
|
+
"ALTER TABLE ?? DROP CONSTRAINT ??",
|
|
141
|
+
[tableName, columnName + "_fk"]
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const dropForeignKey: IDialect['dropForeignKey'] = function (
|
|
147
|
+
dbdriver, tableName, columnName, cb
|
|
148
|
+
) {
|
|
149
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
150
|
+
() => dropForeignKeySync(dbdriver, tableName, columnName)
|
|
151
|
+
)
|
|
152
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const getCollectionColumnsSync: IDialect['getCollectionColumnsSync'] = function (
|
|
156
|
+
dbdriver, name
|
|
157
|
+
) {
|
|
158
|
+
return (dbdriver.execute(
|
|
159
|
+
getSqlQueryDialect('dm').escape(
|
|
160
|
+
"SELECT c.*, cc.COMMENTS FROM ALL_TAB_COLUMNS c LEFT JOIN ALL_COL_COMMENTS cc ON c.OWNER = cc.OWNER AND c.TABLE_NAME = cc.TABLE_NAME AND c.COLUMN_NAME = cc.COLUMN_NAME WHERE c.TABLE_NAME = UPPER(?) AND c.OWNER = USER ORDER BY c.COLUMN_ID",
|
|
161
|
+
[name]
|
|
162
|
+
)
|
|
163
|
+
) as any[]).map((row: any) => Transformer.filterRawColumns!(row as any)) as any
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const getCollectionColumns: IDialect['getCollectionColumns'] = function (
|
|
167
|
+
dbdriver, name, cb
|
|
168
|
+
) {
|
|
169
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
170
|
+
() => getCollectionColumnsSync(dbdriver, name)
|
|
171
|
+
)
|
|
172
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const getCollectionPropertiesSync: IDialect['getCollectionPropertiesSync'] = function (
|
|
176
|
+
dbdriver, name
|
|
177
|
+
) {
|
|
178
|
+
const cols = getCollectionColumnsSync(dbdriver, name)
|
|
179
|
+
const pkSet = fetchPrimaryKeys(dbdriver as any, name);
|
|
180
|
+
|
|
181
|
+
const props = {} as { [col: string]: IProperty };
|
|
182
|
+
|
|
183
|
+
for (let i = 0; i < cols.length; i++) {
|
|
184
|
+
const colInfo = cols[i];
|
|
185
|
+
const mapsToRaw = colInfo.COLUMN_NAME || colInfo.column_name;
|
|
186
|
+
const mapsTo = mapsToRaw !== undefined ? String(mapsToRaw) : '';
|
|
187
|
+
const prop = Transformer.rawToProperty(colInfo, {
|
|
188
|
+
collection: name,
|
|
189
|
+
}).property;
|
|
190
|
+
|
|
191
|
+
if (mapsTo && pkSet.has(String(mapsTo))) {
|
|
192
|
+
prop.primary = true;
|
|
193
|
+
prop.key = true;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (mapsTo) props[mapsTo] = prop;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return props;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const getCollectionProperties: IDialect['getCollectionProperties'] = function (
|
|
203
|
+
dbdriver, name, cb
|
|
204
|
+
) {
|
|
205
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
206
|
+
() => getCollectionPropertiesSync(dbdriver, name)
|
|
207
|
+
)
|
|
208
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
export const createCollectionSync: IDialect['createCollectionSync'] = function (
|
|
212
|
+
dbdriver, name, columns, keys, opts
|
|
213
|
+
) {
|
|
214
|
+
return dbdriver.execute(
|
|
215
|
+
SQL.CREATE_TABLE({
|
|
216
|
+
name: name,
|
|
217
|
+
columns: columns,
|
|
218
|
+
keys: keys,
|
|
219
|
+
comment: opts?.comment
|
|
220
|
+
}, 'dm')
|
|
221
|
+
)
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export const createCollection: IDialect['createCollection'] = function (
|
|
225
|
+
dbdriver, name, columns, keys, opts, cb
|
|
226
|
+
) {
|
|
227
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
228
|
+
() => createCollectionSync(dbdriver, name, columns, keys, opts)
|
|
229
|
+
)
|
|
230
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export const dropCollectionSync: IDialect['dropCollectionSync'] = function (
|
|
234
|
+
dbdriver, name
|
|
235
|
+
) {
|
|
236
|
+
return dbdriver.execute(
|
|
237
|
+
SQL.DROP_TABLE({ name: name }, 'dm')
|
|
238
|
+
)
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export const dropCollection: IDialect['dropCollection'] = function (
|
|
242
|
+
dbdriver, name, cb
|
|
243
|
+
) {
|
|
244
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
245
|
+
() => dropCollectionSync(dbdriver, name)
|
|
246
|
+
)
|
|
247
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export const hasCollectionColumnsSync: IDialect['hasCollectionColumnsSync'] = function (
|
|
251
|
+
dbdriver, name, column
|
|
252
|
+
) {
|
|
253
|
+
const columns = arraify(column)
|
|
254
|
+
let res: null | any[] = null, has = false
|
|
255
|
+
try {
|
|
256
|
+
has = columns.every(
|
|
257
|
+
columnName =>
|
|
258
|
+
(res = dbdriver.execute(
|
|
259
|
+
SQL.CHECK_TABLE_HAS_COLUMN({
|
|
260
|
+
name: name,
|
|
261
|
+
column: columnName,
|
|
262
|
+
}, 'dm')
|
|
263
|
+
)) && !!(res && res.length)
|
|
264
|
+
)
|
|
265
|
+
} catch (error) {
|
|
266
|
+
has = false
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
return has
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export const hasCollectionColumns: IDialect['hasCollectionColumns'] = function (
|
|
273
|
+
dbdriver, name, column, cb
|
|
274
|
+
) {
|
|
275
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
276
|
+
() => hasCollectionColumnsSync(dbdriver, name, column)
|
|
277
|
+
)
|
|
278
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export const addCollectionColumnSync: IDialect['addCollectionColumnSync'] = function (
|
|
282
|
+
dbdriver, name, column, after_column
|
|
283
|
+
) {
|
|
284
|
+
return dbdriver.execute(
|
|
285
|
+
SQL.ALTER_TABLE_ADD_COLUMN({
|
|
286
|
+
name: name,
|
|
287
|
+
column: column,
|
|
288
|
+
after: after_column,
|
|
289
|
+
first: !after_column
|
|
290
|
+
}, 'dm')
|
|
291
|
+
)
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export const addCollectionColumn: IDialect['addCollectionColumn'] = function (
|
|
295
|
+
dbdriver, name, column, after_column, cb
|
|
296
|
+
) {
|
|
297
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
298
|
+
() => addCollectionColumnSync(dbdriver, name, column, after_column)
|
|
299
|
+
)
|
|
300
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export const renameCollectionColumnSync: IDialect['renameCollectionColumnSync'] = function (
|
|
304
|
+
dbdriver, name, oldColName, newColName
|
|
305
|
+
) {
|
|
306
|
+
return dbdriver.execute(
|
|
307
|
+
SQL.ALTER_TABLE_RENAME_COLUMN({
|
|
308
|
+
name: name,
|
|
309
|
+
oldColName: oldColName,
|
|
310
|
+
newColName: newColName
|
|
311
|
+
}, 'dm')
|
|
312
|
+
)
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
export const renameCollectionColumn: IDialect['renameCollectionColumn'] = function (
|
|
316
|
+
dbdriver, name, oldColName, newColName, cb
|
|
317
|
+
) {
|
|
318
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
319
|
+
() => renameCollectionColumnSync(dbdriver, name, oldColName, newColName)
|
|
320
|
+
)
|
|
321
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
export const modifyCollectionColumnSync: IDialect['modifyCollectionColumnSync'] = function (
|
|
325
|
+
dbdriver, name, column
|
|
326
|
+
) {
|
|
327
|
+
return dbdriver.execute(
|
|
328
|
+
SQL.ALTER_TABLE_MODIFY_COLUMN({
|
|
329
|
+
name: name,
|
|
330
|
+
column: column
|
|
331
|
+
}, 'dm')
|
|
332
|
+
)
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export const modifyCollectionColumn: IDialect['modifyCollectionColumn'] = function (
|
|
336
|
+
dbdriver, name, column, cb
|
|
337
|
+
) {
|
|
338
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
339
|
+
() => modifyCollectionColumnSync(dbdriver, name, column)
|
|
340
|
+
)
|
|
341
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
342
|
+
};
|
|
343
|
+
|
|
344
|
+
export const dropCollectionColumnSync: IDialect['dropCollectionColumnSync'] = function (
|
|
345
|
+
dbdriver, name, column
|
|
346
|
+
) {
|
|
347
|
+
return dbdriver.execute(
|
|
348
|
+
SQL.ALTER_TABLE_DROP_COLUMN({
|
|
349
|
+
name: name,
|
|
350
|
+
column: column
|
|
351
|
+
}, 'dm')
|
|
352
|
+
)
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
export const dropCollectionColumn: IDialect['dropCollectionColumn'] = function (
|
|
356
|
+
dbdriver, name, column, cb
|
|
357
|
+
) {
|
|
358
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
359
|
+
() => dropCollectionColumnSync(dbdriver, name, column)
|
|
360
|
+
)
|
|
361
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export const getCollectionIndexesSync: IDialect['getCollectionIndexesSync'] = function (
|
|
365
|
+
dbdriver, name
|
|
366
|
+
) {
|
|
367
|
+
const indexRows = dbdriver.execute(
|
|
368
|
+
getSqlQueryDialect('dm').escape(
|
|
369
|
+
[
|
|
370
|
+
"SELECT i.INDEX_NAME, i.UNIQUENESS, c.COLUMN_NAME ",
|
|
371
|
+
"FROM ALL_INDEXES i ",
|
|
372
|
+
"JOIN ALL_IND_COLUMNS c ",
|
|
373
|
+
"ON i.INDEX_NAME = c.INDEX_NAME AND i.TABLE_NAME = c.TABLE_NAME AND i.OWNER = c.INDEX_OWNER ",
|
|
374
|
+
"WHERE i.TABLE_NAME = UPPER(?) AND i.OWNER = USER"
|
|
375
|
+
].join(''),
|
|
376
|
+
[name]
|
|
377
|
+
)
|
|
378
|
+
) as any[]
|
|
379
|
+
|
|
380
|
+
const pkRows = dbdriver.execute(
|
|
381
|
+
getSqlQueryDialect('dm').escape(
|
|
382
|
+
[
|
|
383
|
+
"SELECT CONSTRAINT_NAME ",
|
|
384
|
+
"FROM ALL_CONSTRAINTS ",
|
|
385
|
+
"WHERE CONSTRAINT_TYPE = 'P' ",
|
|
386
|
+
"AND TABLE_NAME = UPPER(?) ",
|
|
387
|
+
"AND OWNER = USER"
|
|
388
|
+
].join(''),
|
|
389
|
+
[name]
|
|
390
|
+
)
|
|
391
|
+
) as any[]
|
|
392
|
+
|
|
393
|
+
const pkIndexSet = new Set<string>();
|
|
394
|
+
pkRows.forEach((row: any) => {
|
|
395
|
+
const cname = row.CONSTRAINT_NAME || row.constraint_name;
|
|
396
|
+
if (cname) pkIndexSet.add(String(cname));
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
return convertIndexRows(indexRows, pkIndexSet);
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
export const getCollectionIndexes: IDialect['getCollectionIndexes'] = function (
|
|
403
|
+
dbdriver, name, cb
|
|
404
|
+
) {
|
|
405
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
406
|
+
() => getCollectionIndexesSync(dbdriver, name)
|
|
407
|
+
)
|
|
408
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
409
|
+
};
|
|
410
|
+
|
|
411
|
+
export const addIndexSync: IDialect['addIndexSync'] = function (
|
|
412
|
+
dbdriver, indexName, unique, collection, columns
|
|
413
|
+
) {
|
|
414
|
+
return dbdriver.execute(
|
|
415
|
+
SQL.CREATE_INDEX({
|
|
416
|
+
name: indexName,
|
|
417
|
+
unique: unique,
|
|
418
|
+
collection: collection,
|
|
419
|
+
columns: columns
|
|
420
|
+
}, 'dm')
|
|
421
|
+
)
|
|
422
|
+
};
|
|
423
|
+
|
|
424
|
+
export const addIndex: IDialect['addIndex'] = function (
|
|
425
|
+
dbdriver, indexName, unique, collection, columns, cb
|
|
426
|
+
) {
|
|
427
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
428
|
+
() => addIndexSync(dbdriver, indexName, unique, collection, columns)
|
|
429
|
+
)
|
|
430
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
431
|
+
};
|
|
432
|
+
|
|
433
|
+
export const removeIndexSync: IDialect['removeIndexSync'] = function (
|
|
434
|
+
dbdriver, collection, name
|
|
435
|
+
) {
|
|
436
|
+
return dbdriver.execute(
|
|
437
|
+
SQL.DROP_INDEX({
|
|
438
|
+
name: name,
|
|
439
|
+
collection: collection
|
|
440
|
+
}, 'dm')
|
|
441
|
+
)
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
export const removeIndex: IDialect['removeIndex'] = function (
|
|
445
|
+
dbdriver, collection, name, cb
|
|
446
|
+
) {
|
|
447
|
+
const exposedErrResults = FxORMCore.Utils.exposeErrAndResultFromSyncMethod(
|
|
448
|
+
() => removeIndexSync(dbdriver, collection, name)
|
|
449
|
+
)
|
|
450
|
+
FxORMCore.Utils.throwErrOrCallabckErrResult(exposedErrResults, { no_throw: true, callback: cb });
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
export const toRawType: IDialect['toRawType'] = function (
|
|
454
|
+
property, ctx
|
|
455
|
+
) {
|
|
456
|
+
return Transformer.toStorageType(property, {
|
|
457
|
+
collection: ctx.collection,
|
|
458
|
+
customTypes: ctx.driver?.customTypes,
|
|
459
|
+
escapeVal: getSqlQueryDialect(ctx.driver?.type || 'dm').escapeVal
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
function convertIndexRows(
|
|
464
|
+
rows: any[],
|
|
465
|
+
pkIndexSet: Set<string>
|
|
466
|
+
): Record<string, FxOrmSqlDDLSync__DbIndex.DbIndexInfo> {
|
|
467
|
+
const indexes = {} as Record<string, FxOrmSqlDDLSync__DbIndex.DbIndexInfo>;
|
|
468
|
+
|
|
469
|
+
for (let i = 0; i < rows.length; i++) {
|
|
470
|
+
const index_name = rows[i].INDEX_NAME || rows[i].index_name;
|
|
471
|
+
const uniqueness = rows[i].UNIQUENESS || rows[i].uniqueness;
|
|
472
|
+
const column_name = rows[i].COLUMN_NAME || rows[i].column_name;
|
|
473
|
+
|
|
474
|
+
if (!index_name || pkIndexSet.has(String(index_name))) {
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (/^INDEX\d+$/i.test(String(index_name))) {
|
|
479
|
+
continue;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
if (!indexes.hasOwnProperty(index_name)) {
|
|
483
|
+
indexes[index_name] = {
|
|
484
|
+
columns: [],
|
|
485
|
+
unique: String(uniqueness).toUpperCase() === 'UNIQUE'
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
indexes[index_name].columns.push(column_name);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
return indexes;
|
|
493
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as mysql from './mysql';
|
|
2
2
|
export { mysql };
|
|
3
|
-
import * as postgresql from './postgresql';
|
|
4
|
-
export { postgresql };
|
|
5
3
|
import * as sqlite from './sqlite';
|
|
6
4
|
export { sqlite };
|
|
5
|
+
import * as postgresql from './postgresql';
|
|
6
|
+
export { postgresql };
|
|
7
7
|
import * as mssql from './mssql';
|
|
8
8
|
export { mssql };
|
|
9
9
|
import * as dm from './dm';
|
|
10
|
-
export { dm };
|
|
10
|
+
export { dm };
|