orange-orm 3.10.2
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/.dockerignore +1 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +45 -0
- package/.gitattributes +3 -0
- package/CNAME +1 -0
- package/CONTRIBUTING.md +43 -0
- package/LICENSE +7 -0
- package/README.md +1969 -0
- package/SECURITY.md +12 -0
- package/bin/build.js +127 -0
- package/bin/compile.js +26 -0
- package/bin/rdb.js +4 -0
- package/docs/CODE_OF_CONDUCT.md +18 -0
- package/docs/changelog.md +461 -0
- package/docs/docs.md +2373 -0
- package/docs/orange.svg +32 -0
- package/docs/relations.png +0 -0
- package/package.json +139 -0
- package/src/applyPatch.js +105 -0
- package/src/client/axiosInterceptor.js +46 -0
- package/src/client/clientMap.js +72 -0
- package/src/client/createPatch.js +122 -0
- package/src/client/createProviders.js +121 -0
- package/src/client/index.js +997 -0
- package/src/client/index.mjs +6295 -0
- package/src/client/map.js +110 -0
- package/src/client/merge.js +9 -0
- package/src/client/netAdapter.js +133 -0
- package/src/client/rollup.config.js +12 -0
- package/src/client/self.js +4 -0
- package/src/client/stringify.js +22 -0
- package/src/client/toKeyPositionMap.js +30 -0
- package/src/clsTest.js +79 -0
- package/src/createDomain/negotiateForwardProperty.js +23 -0
- package/src/createDomain.js +31 -0
- package/src/dateToISOString.js +25 -0
- package/src/emitEvent.js +46 -0
- package/src/emptyFilter.js +35 -0
- package/src/flags.js +6 -0
- package/src/fromCompareObject.js +24 -0
- package/src/generic-pool.js +641 -0
- package/src/getManyDto/newQuery.js +18 -0
- package/src/getManyDto/query/newColumnSql.js +8 -0
- package/src/getManyDto/query/newSingleQuery.js +19 -0
- package/src/getManyDto/query/singleQuery/newJoinedColumnSql.js +25 -0
- package/src/getManyDto/query/singleQuery/newShallowColumnSql.js +25 -0
- package/src/getManyDto.js +255 -0
- package/src/getTSDefinition.js +510 -0
- package/src/hostExpress/executePath.js +433 -0
- package/src/hostExpress/getMeta.js +49 -0
- package/src/hostExpress.js +125 -0
- package/src/hostLocal.js +110 -0
- package/src/index.d.ts +324 -0
- package/src/index.js +116 -0
- package/src/jsconfig.json +8 -0
- package/src/lock/toIntKey.js +35 -0
- package/src/lock.js +26 -0
- package/src/map.d.ts +1729 -0
- package/src/mssql/encodeBuffer.js +7 -0
- package/src/mssql/newDatabase.js +129 -0
- package/src/mssql/newPool.js +19 -0
- package/src/mssql/newTransaction.js +69 -0
- package/src/mssql/pool/defaults.js +45 -0
- package/src/mssql/pool/end.js +13 -0
- package/src/mssql/pool/newGenericPool.js +62 -0
- package/src/mssql/wrapQuery.js +34 -0
- package/src/mySql/deleteFromSql.js +8 -0
- package/src/mySql/encodeBoolean.js +7 -0
- package/src/mySql/insert.js +21 -0
- package/src/mySql/insertSql.js +62 -0
- package/src/mySql/lastInsertedSql.js +11 -0
- package/src/mySql/limitAndOffset.js +18 -0
- package/src/mySql/newDatabase.js +127 -0
- package/src/mySql/newPool.js +19 -0
- package/src/mySql/newTransaction.js +54 -0
- package/src/mySql/pool/defaults.js +16 -0
- package/src/mySql/pool/end.js +13 -0
- package/src/mySql/pool/negotiatePoolOptions.js +12 -0
- package/src/mySql/pool/newGenericPool.js +67 -0
- package/src/mySql/selectForUpdateSql.js +3 -0
- package/src/mySql/wrapQuery.js +16 -0
- package/src/mySql/wrapQueryStream.js +9 -0
- package/src/newArray.js +3 -0
- package/src/newCollection.js +55 -0
- package/src/newId.js +1 -0
- package/src/newImmutable.js +22 -0
- package/src/newObject.js +5 -0
- package/src/oracle/deleteFromSql.js +8 -0
- package/src/oracle/encodeBoolean.js +7 -0
- package/src/oracle/encodeBuffer.js +7 -0
- package/src/oracle/encodeDate.js +7 -0
- package/src/oracle/formatDateIn.js +5 -0
- package/src/oracle/formatDateOut.js +5 -0
- package/src/oracle/insert.js +23 -0
- package/src/oracle/insertSql.js +73 -0
- package/src/oracle/lastInsertedSql.js +14 -0
- package/src/oracle/limitAndOffset.js +18 -0
- package/src/oracle/mergeSql.js +79 -0
- package/src/oracle/newDatabase.js +128 -0
- package/src/oracle/newInsertCommandCore.js +27 -0
- package/src/oracle/newPool.js +19 -0
- package/src/oracle/newTransaction.js +63 -0
- package/src/oracle/outputInsertedSql.js +5 -0
- package/src/oracle/pool/defaults.js +45 -0
- package/src/oracle/pool/end.js +13 -0
- package/src/oracle/pool/newGenericPool.js +64 -0
- package/src/oracle/replaceParamChar.js +14 -0
- package/src/oracle/selectForUpdateSql.js +3 -0
- package/src/oracle/wrapQuery.js +38 -0
- package/src/patchRow.js +13 -0
- package/src/patchTable.js +317 -0
- package/src/pg/deleteFromSql.js +8 -0
- package/src/pg/encodeBoolean.js +5 -0
- package/src/pg/encodeDate.js +7 -0
- package/src/pg/encodeJSON.js +15 -0
- package/src/pg/formatDateOut.js +5 -0
- package/src/pg/insert.js +14 -0
- package/src/pg/insertSql.js +70 -0
- package/src/pg/lastInsertedSql.js +11 -0
- package/src/pg/limitAndOffset.js +18 -0
- package/src/pg/newDatabase.js +153 -0
- package/src/pg/newPool.js +19 -0
- package/src/pg/newStreamableQuery.js +7 -0
- package/src/pg/newTransaction.js +58 -0
- package/src/pg/pool/defaults.js +45 -0
- package/src/pg/pool/end.js +13 -0
- package/src/pg/pool/newPgPool.js +82 -0
- package/src/pg/replaceParamChar.js +14 -0
- package/src/pg/schema.js +11 -0
- package/src/pg/selectForUpdateSql.js +3 -0
- package/src/pg/wrapQuery.js +33 -0
- package/src/pg/wrapQueryStream.js +20 -0
- package/src/pools.js +17 -0
- package/src/query/negotiateParameters.js +10 -0
- package/src/query/negotiateSql.js +14 -0
- package/src/query/wrapQuery.js +17 -0
- package/src/query.js +13 -0
- package/src/sap/deleteFromSql.js +8 -0
- package/src/sap/encodeBoolean.js +7 -0
- package/src/sap/encodeBuffer.js +7 -0
- package/src/sap/formatDateOut.js +5 -0
- package/src/sap/insert.js +21 -0
- package/src/sap/insertSql.js +64 -0
- package/src/sap/lastInsertedSql.js +12 -0
- package/src/sap/limitAndOffset.js +16 -0
- package/src/sap/mergeSql.js +73 -0
- package/src/sap/newDatabase.js +129 -0
- package/src/sap/newPool.js +19 -0
- package/src/sap/newTransaction.js +69 -0
- package/src/sap/pool/end.js +13 -0
- package/src/sap/selectForUpdateSql.js +3 -0
- package/src/sqlite/deleteFromSql.js +8 -0
- package/src/sqlite/encodeBoolean.js +7 -0
- package/src/sqlite/encodeBuffer.js +7 -0
- package/src/sqlite/insert.js +21 -0
- package/src/sqlite/insertSql.js +64 -0
- package/src/sqlite/lastInsertedSql.js +12 -0
- package/src/sqlite/limitAndOffset.js +18 -0
- package/src/sqlite/newDatabase.js +128 -0
- package/src/sqlite/newPool.js +19 -0
- package/src/sqlite/newTransaction.js +58 -0
- package/src/sqlite/pool/defaults.js +45 -0
- package/src/sqlite/pool/end.js +13 -0
- package/src/sqlite/pool/newGenericPool.js +59 -0
- package/src/sqlite/selectForUpdateSql.js +3 -0
- package/src/sqlite/wrapQuery.js +24 -0
- package/src/table/aggregate.js +9 -0
- package/src/table/begin.js +10 -0
- package/src/table/cascadeDelete.js +11 -0
- package/src/table/cloneStrategy.js +18 -0
- package/src/table/column/binary/newDecode.js +15 -0
- package/src/table/column/binary/newEncode.js +23 -0
- package/src/table/column/binary/purify.js +12 -0
- package/src/table/column/binary.js +12 -0
- package/src/table/column/boolean/newDecode.js +12 -0
- package/src/table/column/boolean/newEncode.js +36 -0
- package/src/table/column/boolean/purify.js +7 -0
- package/src/table/column/boolean.js +14 -0
- package/src/table/column/date/formatOut.js +11 -0
- package/src/table/column/date/newDecode.js +17 -0
- package/src/table/column/date/newEncode.js +47 -0
- package/src/table/column/date/purify.js +17 -0
- package/src/table/column/date/toISOString.js +25 -0
- package/src/table/column/date/tryParseISO.js +14 -0
- package/src/table/column/date.js +14 -0
- package/src/table/column/dateWithTimeZone/newEncode.js +41 -0
- package/src/table/column/dateWithTimeZone.js +14 -0
- package/src/table/column/encodeFilterArg.js +8 -0
- package/src/table/column/equal.js +15 -0
- package/src/table/column/extractAlias.js +7 -0
- package/src/table/column/greaterThan.js +12 -0
- package/src/table/column/greaterThanOrEqual.js +12 -0
- package/src/table/column/guid/newDecode.js +10 -0
- package/src/table/column/guid/newEncode.js +30 -0
- package/src/table/column/guid/purify.js +10 -0
- package/src/table/column/guid.js +12 -0
- package/src/table/column/in.js +24 -0
- package/src/table/column/json/formatOut.js +11 -0
- package/src/table/column/json/newDecode.js +21 -0
- package/src/table/column/json/newEncode.js +41 -0
- package/src/table/column/json/purify.js +7 -0
- package/src/table/column/json.js +22 -0
- package/src/table/column/lessThan.js +12 -0
- package/src/table/column/lessThanOrEqual.js +12 -0
- package/src/table/column/negotiateNextAndFilter.js +7 -0
- package/src/table/column/negotiateNextOrFilter.js +7 -0
- package/src/table/column/negotiateRawSqlFilter.js +74 -0
- package/src/table/column/newBoolean.js +54 -0
- package/src/table/column/newColumn.js +89 -0
- package/src/table/column/newDecodeCore.js +10 -0
- package/src/table/column/notEqual.js +15 -0
- package/src/table/column/numeric/negotiateDefault.js +5 -0
- package/src/table/column/numeric/newDecode.js +16 -0
- package/src/table/column/numeric/newEncode.js +25 -0
- package/src/table/column/numeric/purify.js +12 -0
- package/src/table/column/numeric.js +15 -0
- package/src/table/column/string/contains.js +3 -0
- package/src/table/column/string/containsCore.js +16 -0
- package/src/table/column/string/endsWith.js +3 -0
- package/src/table/column/string/endsWithCore.js +16 -0
- package/src/table/column/string/iContains.js +3 -0
- package/src/table/column/string/iEndsWith.js +3 -0
- package/src/table/column/string/iEqual.js +15 -0
- package/src/table/column/string/iStartsWith.js +3 -0
- package/src/table/column/string/newEncode.js +31 -0
- package/src/table/column/string/purify.js +7 -0
- package/src/table/column/string/startsWith.js +3 -0
- package/src/table/column/string/startsWithCore.js +16 -0
- package/src/table/column/string.js +55 -0
- package/src/table/column.js +154 -0
- package/src/table/commands/beginCommand.js +13 -0
- package/src/table/commands/commitCommand.js +9 -0
- package/src/table/commands/compressChanges.js +25 -0
- package/src/table/commands/delete/createAlias.js +6 -0
- package/src/table/commands/delete/newSingleCommand.js +17 -0
- package/src/table/commands/delete/singleCommand/joinSql.js +26 -0
- package/src/table/commands/delete/singleCommand/newSingleCommandCore.js +19 -0
- package/src/table/commands/delete/singleCommand/selectSql.js +11 -0
- package/src/table/commands/delete/singleCommand/subFilter.js +19 -0
- package/src/table/commands/delete/singleCommand/whereSql.js +25 -0
- package/src/table/commands/getChangeSet.js +6 -0
- package/src/table/commands/insert/getSqlTemplate.js +68 -0
- package/src/table/commands/lastCommandMatches.js +11 -0
- package/src/table/commands/negotiateEndEdit.js +7 -0
- package/src/table/commands/newDeleteCommand.js +23 -0
- package/src/table/commands/newGetLastInsertedCommand.js +49 -0
- package/src/table/commands/newGetLastInsertedCommandCore.js +42 -0
- package/src/table/commands/newInsertAndForgetCommand.js +55 -0
- package/src/table/commands/newInsertCommand.js +56 -0
- package/src/table/commands/newInsertCommandCore.js +27 -0
- package/src/table/commands/newRow.js +51 -0
- package/src/table/commands/newUpdateCommand.js +62 -0
- package/src/table/commands/newUpdateCommandCore.js +45 -0
- package/src/table/commands/pushCommand.js +10 -0
- package/src/table/commands/rollbackCommand.js +13 -0
- package/src/table/commit.js +30 -0
- package/src/table/count.js +29 -0
- package/src/table/createJSONReadStream.js +7 -0
- package/src/table/createJSONReadStreamDefault.js +33 -0
- package/src/table/createJSONReadStreamNative.js +31 -0
- package/src/table/createReadStream.js +24 -0
- package/src/table/createReadStreamCoreNative.js +40 -0
- package/src/table/createReadStreamDefault.js +102 -0
- package/src/table/createReadStreamNative.js +17 -0
- package/src/table/delete.js +20 -0
- package/src/table/deleteSessionContext.js +17 -0
- package/src/table/encodeDbSpecific.js +10 -0
- package/src/table/executeQueries/executeChanges.js +35 -0
- package/src/table/executeQueries/executeQueriesCore.js +12 -0
- package/src/table/executeQueries/executeQuery.js +8 -0
- package/src/table/executeQueries/resolveExecuteQuery.js +57 -0
- package/src/table/executeQueries.js +15 -0
- package/src/table/extractDeleteStrategy.js +9 -0
- package/src/table/fuzzyPromise.js +18 -0
- package/src/table/getById.js +33 -0
- package/src/table/getFirstFromDb.js +10 -0
- package/src/table/getFromDbById.js +17 -0
- package/src/table/getIdArgs.js +14 -0
- package/src/table/getMany.js +26 -0
- package/src/table/getManyDto/newQuery.js +32 -0
- package/src/table/getManyDto/pg/newQuery.js +8 -0
- package/src/table/getManyDto.js +10 -0
- package/src/table/getManyDtoFast/getSubRows.js +172 -0
- package/src/table/getManyDtoFast/newQuery.js +8 -0
- package/src/table/getManyDtoFast/newQueryCore.js +18 -0
- package/src/table/getManyDtoFast/query/newSingleQuery.js +20 -0
- package/src/table/getManyDtoFast/query/newSubQueries/joinLegToQuery.js +18 -0
- package/src/table/getManyDtoFast/query/newSubQueries/manyLegToQuery.js +20 -0
- package/src/table/getManyDtoFast/query/newSubQueries/oneLegToQuery.js +21 -0
- package/src/table/getManyDtoFast/query/newSubQueries.js +47 -0
- package/src/table/getManyDtoFast/query/singleQuery/newShallowColumnSql.js +21 -0
- package/src/table/getSessionContext.js +10 -0
- package/src/table/getSessionSingleton.js +5 -0
- package/src/table/groupBy/newQuery.js +25 -0
- package/src/table/groupBy.js +65 -0
- package/src/table/hasMany.js +33 -0
- package/src/table/hasOne.js +33 -0
- package/src/table/insert.js +91 -0
- package/src/table/insertDefault.js +88 -0
- package/src/table/join.js +42 -0
- package/src/table/joinRelation/getRelatives.js +64 -0
- package/src/table/log.js +39 -0
- package/src/table/negotiateAddStrategy.js +20 -0
- package/src/table/negotiateExpandInverse.js +13 -0
- package/src/table/newCache.js +96 -0
- package/src/table/newCascadeDeleteStrategy.js +30 -0
- package/src/table/newGetRelated.js +21 -0
- package/src/table/newJoinRelation.js +117 -0
- package/src/table/newManyRelation.js +61 -0
- package/src/table/newOneRelation.js +61 -0
- package/src/table/newPrimaryKeyFilter.js +13 -0
- package/src/table/newQuery.js +18 -0
- package/src/table/newRelatedTable.js +100 -0
- package/src/table/newRowCache.js +106 -0
- package/src/table/newThrow.js +11 -0
- package/src/table/nullPromise.js +1 -0
- package/src/table/objectToCallback.js +7 -0
- package/src/table/oneRelation/getRelatives.js +45 -0
- package/src/table/popChanges.js +19 -0
- package/src/table/promise.js +14 -0
- package/src/table/purifyStrategy.js +49 -0
- package/src/table/query/extractFilter.js +9 -0
- package/src/table/query/extractLimit.js +11 -0
- package/src/table/query/extractLimitQuery.js +23 -0
- package/src/table/query/extractOffset.js +11 -0
- package/src/table/query/extractOrderBy.js +57 -0
- package/src/table/query/extractSql.js +10 -0
- package/src/table/query/newParameterized.js +38 -0
- package/src/table/query/newSingleQuery.js +23 -0
- package/src/table/query/parameterized/extractParameters.js +8 -0
- package/src/table/query/singleQuery/columnSql/joinLegToColumnSql.js +16 -0
- package/src/table/query/singleQuery/columnSql/newJoinedColumnSql.js +27 -0
- package/src/table/query/singleQuery/columnSql/newShallowColumnSql.js +37 -0
- package/src/table/query/singleQuery/joinSql/joinLegToJoinSql.js +13 -0
- package/src/table/query/singleQuery/joinSql/joinLegToShallowJoinSql.js +9 -0
- package/src/table/query/singleQuery/joinSql/newDiscriminatorSql.js +11 -0
- package/src/table/query/singleQuery/joinSql/newShallowJoinSql.js +9 -0
- package/src/table/query/singleQuery/joinSql/newShallowJoinSqlCore.js +25 -0
- package/src/table/query/singleQuery/joinSql/oneLegToJoinSql.js +13 -0
- package/src/table/query/singleQuery/joinSql/oneLegToShallowJoinSql.js +10 -0
- package/src/table/query/singleQuery/negotiateExclusive.js +11 -0
- package/src/table/query/singleQuery/negotiateLimit.js +10 -0
- package/src/table/query/singleQuery/newColumnSql.js +8 -0
- package/src/table/query/singleQuery/newDiscriminatorSql.js +33 -0
- package/src/table/query/singleQuery/newJoinSql.js +41 -0
- package/src/table/query/singleQuery/newQueryContext.js +20 -0
- package/src/table/query/singleQuery/newWhereSql.js +19 -0
- package/src/table/readStream/extractLimit.js +7 -0
- package/src/table/readStream/extractOrderBy.js +55 -0
- package/src/table/readStream/mySql/newQuery.js +16 -0
- package/src/table/readStream/mySql/query/newSingleQuery.js +21 -0
- package/src/table/readStream/mySql/query/newSubQueries/joinLegToQuery.js +19 -0
- package/src/table/readStream/mySql/query/newSubQueries/manyLegToQuery.js +22 -0
- package/src/table/readStream/mySql/query/newSubQueries/newQueryCore.js +9 -0
- package/src/table/readStream/mySql/query/newSubQueries/newSingleQueryCore.js +18 -0
- package/src/table/readStream/mySql/query/newSubQueries/oneLegToQuery.js +22 -0
- package/src/table/readStream/mySql/query/newSubQueries.js +47 -0
- package/src/table/readStream/mySql/query/singleQuery/newShallowColumnSql.js +17 -0
- package/src/table/readStream/newQuery.js +32 -0
- package/src/table/readStream/newQueryStream.js +8 -0
- package/src/table/readStream/pg/newQuery.js +8 -0
- package/src/table/readStream/pg/newQueryCore.js +17 -0
- package/src/table/readStream/pg/query/newSingleQuery.js +19 -0
- package/src/table/readStream/pg/query/newSubQueries/joinLegToQuery.js +19 -0
- package/src/table/readStream/pg/query/newSubQueries/manyLegToQuery.js +22 -0
- package/src/table/readStream/pg/query/newSubQueries/oneLegToQuery.js +19 -0
- package/src/table/readStream/pg/query/newSubQueries.js +47 -0
- package/src/table/readStream/pg/query/singleQuery/newShallowColumnSql.js +19 -0
- package/src/table/readStreamDefault/createBatchFilter.js +39 -0
- package/src/table/relatedTable/aggregate/aggregateJoinSql.js +37 -0
- package/src/table/relatedTable/aggregate/joinSql.js +38 -0
- package/src/table/relatedTable/aggregate.js +48 -0
- package/src/table/relatedTable/all.js +24 -0
- package/src/table/relatedTable/any.js +70 -0
- package/src/table/relatedTable/childColumn.js +61 -0
- package/src/table/relatedTable/columnAggregate.js +16 -0
- package/src/table/relatedTable/columnAggregateGroup.js +59 -0
- package/src/table/relatedTable/joinSql.js +40 -0
- package/src/table/relatedTable/joinSqlArray.js +32 -0
- package/src/table/relatedTable/none.js +22 -0
- package/src/table/relatedTable/relatedColumn.js +49 -0
- package/src/table/relatedTable/relationFilter.js +16 -0
- package/src/table/relatedTable/selectSql.js +11 -0
- package/src/table/relatedTable/subFilter.js +16 -0
- package/src/table/relatedTable/where.js +50 -0
- package/src/table/relatedTable/whereSql.js +41 -0
- package/src/table/relation/manyCache/extractParentKey.js +17 -0
- package/src/table/relation/manyCache/synchronizeAdded.js +13 -0
- package/src/table/relation/manyCache/synchronizeChanged.js +31 -0
- package/src/table/relation/manyCache/synchronizeRemoved.js +13 -0
- package/src/table/relation/newExpanderCache.js +7 -0
- package/src/table/relation/newForeignKeyFilter.js +20 -0
- package/src/table/relation/newJoinLeg.js +23 -0
- package/src/table/relation/newManyCache.js +57 -0
- package/src/table/relation/newManyCacheCore.js +53 -0
- package/src/table/relation/newManyLeg.js +15 -0
- package/src/table/relation/newOneCache.js +28 -0
- package/src/table/relation/newOneLeg.js +25 -0
- package/src/table/releaseDbClient.js +15 -0
- package/src/table/resultToPromise.js +8 -0
- package/src/table/resultToRows/dbRowToRow.js +51 -0
- package/src/table/resultToRows/dbRowsToRows.js +13 -0
- package/src/table/resultToRows/decodeDbRow.js +25 -0
- package/src/table/resultToRows/delete/removeFromCache.js +33 -0
- package/src/table/resultToRows/delete.js +31 -0
- package/src/table/resultToRows/negotiateQueryContext.js +6 -0
- package/src/table/resultToRows/newDecodeDbRow.js +262 -0
- package/src/table/resultToRows/toDto/createDto.js +20 -0
- package/src/table/resultToRows/toDto/extractStrategy.js +41 -0
- package/src/table/resultToRows/toDto.js +92 -0
- package/src/table/resultToRows.js +37 -0
- package/src/table/rollback.js +31 -0
- package/src/table/rowArray/negotiateNextTick.js +11 -0
- package/src/table/rowArray/orderBy.js +51 -0
- package/src/table/rowArray.js +62 -0
- package/src/table/setSessionSingleton.js +5 -0
- package/src/table/strategyToSpan.js +49 -0
- package/src/table/tryGetById.js +13 -0
- package/src/table/tryGetFirstFromDb.js +23 -0
- package/src/table/tryGetFromCacheById.js +12 -0
- package/src/table/tryGetFromDbById/extractStrategy.js +9 -0
- package/src/table/tryGetFromDbById.js +19 -0
- package/src/table/tryGetSessionContext.js +16 -0
- package/src/table/tryReleaseDbClient.js +14 -0
- package/src/table/updateField.js +12 -0
- package/src/table/where.js +12 -0
- package/src/table.js +174 -0
- package/src/tedious/deleteFromSql.js +8 -0
- package/src/tedious/encodeBoolean.js +7 -0
- package/src/tedious/encodeBuffer.js +7 -0
- package/src/tedious/formatDateOut.js +5 -0
- package/src/tedious/formatJSONOut.js +5 -0
- package/src/tedious/getManyDto/newQuery.js +8 -0
- package/src/tedious/getManyDto/newQueryCore.js +18 -0
- package/src/tedious/getManyDto/query/newSingleQuery.js +29 -0
- package/src/tedious/getManyDto/query/newSubQueries/joinLegToQuery.js +16 -0
- package/src/tedious/getManyDto/query/newSubQueries/manyLegToQuery.js +16 -0
- package/src/tedious/getManyDto/query/newSubQueries/oneLegToQuery.js +19 -0
- package/src/tedious/getManyDto/query/newSubQueries.js +48 -0
- package/src/tedious/getManyDto/query/singleQuery/newShallowColumnSql.js +34 -0
- package/src/tedious/getManyDto.js +27 -0
- package/src/tedious/insert.js +13 -0
- package/src/tedious/insertSql.js +70 -0
- package/src/tedious/limitAndOffset.js +16 -0
- package/src/tedious/mergeSql.js +76 -0
- package/src/tedious/newDatabase.js +129 -0
- package/src/tedious/newPool.js +19 -0
- package/src/tedious/newTransaction.js +72 -0
- package/src/tedious/outputInsertedSql.js +11 -0
- package/src/tedious/pool/defaults.js +45 -0
- package/src/tedious/pool/end.js +13 -0
- package/src/tedious/pool/newGenericPool.js +71 -0
- package/src/tedious/pool/parseConnectionString.js +40 -0
- package/src/tedious/selectForUpdateSql.js +3 -0
- package/src/tedious/wrapQuery.js +112 -0
- package/src/toCompareObject.js +41 -0
- package/src/useHook.js +9 -0
- package/src/validateDeleteAllowed.js +49 -0
- package/src/validateDeleteConflict.js +92 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
var util = require('util');
|
|
2
|
+
//todo delete
|
|
3
|
+
function _new(table,alias,span) {
|
|
4
|
+
let columnsMap = span.columns;
|
|
5
|
+
var columnFormat = '%s as "%s"';
|
|
6
|
+
var columns = table._columns;
|
|
7
|
+
var sql = '';
|
|
8
|
+
var separator = '';
|
|
9
|
+
for (var i = 0; i < columns.length; i++) {
|
|
10
|
+
var column = columns[i];
|
|
11
|
+
if (!columnsMap || (columnsMap.get(column))) {
|
|
12
|
+
if (column.dbNull === null)
|
|
13
|
+
sql = sql + separator + alias + '.' + util.format(columnFormat, column._dbName, column.alias);
|
|
14
|
+
else {
|
|
15
|
+
const encoded = column.encode.unsafe(column.dbNull);
|
|
16
|
+
sql = sql + separator + `CASE WHEN ${alias}.${column._dbName}=${encoded} THEN null ELSE ${alias}.${column._dbName} END as ${column.alias}`;
|
|
17
|
+
}
|
|
18
|
+
separator = ',';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return sql;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = _new;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
const newQuery = require('./getManyDto/newQuery');
|
|
2
|
+
const negotiateRawSqlFilter = require('./table/column/negotiateRawSqlFilter');
|
|
3
|
+
const strategyToSpan = require('./table/strategyToSpan');
|
|
4
|
+
const executeQueries = require('./table/executeQueries');
|
|
5
|
+
const newPrimaryKeyFilter = require('./table/newPrimaryKeyFilter');
|
|
6
|
+
const newForeignKeyFilter = require('./table/relation/newForeignKeyFilter');
|
|
7
|
+
|
|
8
|
+
async function getManyDto(table, filter, strategy, spanFromParent) {
|
|
9
|
+
filter = negotiateRawSqlFilter(filter, table);
|
|
10
|
+
if (strategy && strategy.where) {
|
|
11
|
+
let arg = typeof strategy.where === 'function' ? strategy.where(table) : strategy.where;
|
|
12
|
+
filter = filter.and(arg);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let span = spanFromParent || strategyToSpan(table, strategy);
|
|
16
|
+
let alias = table._dbName;
|
|
17
|
+
|
|
18
|
+
const query = newQuery(table, filter, span, alias);
|
|
19
|
+
const res = await executeQueries([query]);
|
|
20
|
+
return decode(strategy, span, await res[0]);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function newCreateRow(span) {
|
|
24
|
+
let columnsMap = span.columns;
|
|
25
|
+
const columns = span.table._columns.filter(column => !columnsMap || columnsMap.get(column));
|
|
26
|
+
const protoRow = createProto(columns, span);
|
|
27
|
+
const manyNames = [];
|
|
28
|
+
|
|
29
|
+
const c = {};
|
|
30
|
+
c.visitJoin = () => { };
|
|
31
|
+
c.visitOne = () => { };
|
|
32
|
+
c.visitMany = function(leg) {
|
|
33
|
+
manyNames.push(leg.name);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
span.legs.forEach(onEachLeg);
|
|
37
|
+
return createRow;
|
|
38
|
+
|
|
39
|
+
function onEachLeg(leg) {
|
|
40
|
+
leg.accept(c);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function createRow() {
|
|
44
|
+
const obj = Object.create(protoRow);
|
|
45
|
+
for (let i = 0; i < manyNames.length; i++) {
|
|
46
|
+
obj[manyNames[i]] = [];
|
|
47
|
+
}
|
|
48
|
+
return obj;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function createProto(columns, span) {
|
|
53
|
+
let obj = {};
|
|
54
|
+
for (let i = 0; i < columns.length; i++) {
|
|
55
|
+
obj[columns[i].alias] = null;
|
|
56
|
+
}
|
|
57
|
+
for (let key in span.aggregates) {
|
|
58
|
+
obj[key] = null;
|
|
59
|
+
}
|
|
60
|
+
const c = {};
|
|
61
|
+
|
|
62
|
+
c.visitJoin = function(leg) {
|
|
63
|
+
obj[leg.name] = null;
|
|
64
|
+
};
|
|
65
|
+
c.visitOne = c.visitJoin;
|
|
66
|
+
c.visitMany = function(leg) {
|
|
67
|
+
obj[leg.name] = null;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
span.legs.forEach(onEachLeg);
|
|
71
|
+
|
|
72
|
+
function onEachLeg(leg) {
|
|
73
|
+
leg.accept(c);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function hasManyRelations(span) {
|
|
80
|
+
let result;
|
|
81
|
+
const c = {};
|
|
82
|
+
c.visitJoin = () => { };
|
|
83
|
+
c.visitOne = c.visitJoin;
|
|
84
|
+
c.visitMany = function() {
|
|
85
|
+
result = true;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
span.legs.forEach(onEachLeg);
|
|
89
|
+
return result;
|
|
90
|
+
|
|
91
|
+
function onEachLeg(leg) {
|
|
92
|
+
leg.accept(c);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async function decode(strategy, span, rows, keys = rows.length > 0 ? Object.keys(rows[0]) : []) {
|
|
97
|
+
const table = span.table;
|
|
98
|
+
let columnsMap = span.columns;
|
|
99
|
+
const columns = table._columns.filter(column => !columnsMap || columnsMap.get(column));
|
|
100
|
+
const rowsLength = rows.length;
|
|
101
|
+
const columnsLength = columns.length;
|
|
102
|
+
const primaryColumns = table._primaryColumns;
|
|
103
|
+
const primaryColumnsLength = primaryColumns.length;
|
|
104
|
+
const rowsMap = new Map();
|
|
105
|
+
const fkIds = new Array(rows.length);
|
|
106
|
+
const getIds = createGetIds();
|
|
107
|
+
const aggregateKeys = Object.keys(span.aggregates);
|
|
108
|
+
|
|
109
|
+
const outRows = new Array(rowsLength);
|
|
110
|
+
const createRow = newCreateRow(span);
|
|
111
|
+
const shouldCreateMap = hasManyRelations(span);
|
|
112
|
+
for (let i = 0; i < rowsLength; i++) {
|
|
113
|
+
const row = rows[i];
|
|
114
|
+
let outRow = createRow();
|
|
115
|
+
let pkWithNullCount = 0;
|
|
116
|
+
for (let j = 0; j < columnsLength; j++) {
|
|
117
|
+
if (j < primaryColumnsLength) {
|
|
118
|
+
if (row[keys[j]] === null)
|
|
119
|
+
pkWithNullCount++;
|
|
120
|
+
if (pkWithNullCount === primaryColumnsLength) {
|
|
121
|
+
outRow = null;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const column = columns[j];
|
|
126
|
+
outRow[column.alias] = column.decode(row[keys[j]]);
|
|
127
|
+
if (shouldCreateMap)
|
|
128
|
+
fkIds[i] = getIds(outRow);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
for (let j = 0; j < aggregateKeys.length; j++) {
|
|
132
|
+
const key = aggregateKeys[j];
|
|
133
|
+
const parse = span.aggregates[key].column?.decode || Number.parseFloat;
|
|
134
|
+
outRow[key] = parse(row[keys[j+columnsLength]]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
outRows[i] = outRow;
|
|
138
|
+
if (shouldCreateMap)
|
|
139
|
+
addToMap(rowsMap, primaryColumns, outRow);
|
|
140
|
+
}
|
|
141
|
+
span._rowsMap = rowsMap;
|
|
142
|
+
span._ids = fkIds;
|
|
143
|
+
|
|
144
|
+
for (let i = 0; i < columnsLength + aggregateKeys.length; i++) {
|
|
145
|
+
keys.shift();
|
|
146
|
+
}
|
|
147
|
+
await decodeRelations(strategy, span, rows, outRows, keys);
|
|
148
|
+
return outRows;
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
function createGetIds() {
|
|
152
|
+
const primaryColumns = table._primaryColumns;
|
|
153
|
+
const length = primaryColumns.length;
|
|
154
|
+
if (length > 1) {
|
|
155
|
+
const alias = table._primaryColumns[0].alias;
|
|
156
|
+
return (row) => row[alias];
|
|
157
|
+
}
|
|
158
|
+
else
|
|
159
|
+
return (row) => {
|
|
160
|
+
const result = new Array(length);
|
|
161
|
+
for (let i = 0; i < length; i++) {
|
|
162
|
+
result[i] = row[primaryColumns[i].alias];
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function decodeRelations(strategy, span, rawRows, resultRows, keys) {
|
|
171
|
+
const promises = [];
|
|
172
|
+
const c = {};
|
|
173
|
+
c.visitJoin = function(leg) {
|
|
174
|
+
const name = leg.name;
|
|
175
|
+
const p = decode(strategy[name], leg.span, rawRows, keys).then((rows) => {
|
|
176
|
+
for (let i = 0; i < rows.length; i++) {
|
|
177
|
+
resultRows[i][name] = rows[i];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
promises.push(p);
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
c.visitOne = c.visitJoin;
|
|
184
|
+
|
|
185
|
+
c.visitMany = function(leg) {
|
|
186
|
+
const name = leg.name;
|
|
187
|
+
const table = span.table;
|
|
188
|
+
const relation = table._relations[name];
|
|
189
|
+
const filter = createOneFilter(relation, span._ids, resultRows, table);
|
|
190
|
+
const rowsMap = span._rowsMap;
|
|
191
|
+
const p = getManyDto(relation.childTable, filter, strategy[name], leg.span).then(subRows => {
|
|
192
|
+
for (let i = 0; i < subRows.length; i++) {
|
|
193
|
+
const key = leg.columns.map(column => subRows[i][column.alias]);
|
|
194
|
+
const parentRow = getFromMap(rowsMap, table._primaryColumns, key);
|
|
195
|
+
parentRow[name].push(subRows[i]);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
promises.push(p);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
span.legs.forEach(onEachLeg);
|
|
202
|
+
|
|
203
|
+
function onEachLeg(leg) {
|
|
204
|
+
leg.accept(c);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
await Promise.all(promises);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function createOneFilter(relation, ids, parentRows, table) {
|
|
211
|
+
let parentTable = relation.joinRelation.childTable;
|
|
212
|
+
|
|
213
|
+
if (parentTable._primaryColumns.length === 1)
|
|
214
|
+
return relation.joinRelation.columns[0].in(ids);
|
|
215
|
+
|
|
216
|
+
else
|
|
217
|
+
return createCompositeFilter();
|
|
218
|
+
|
|
219
|
+
function createCompositeFilter() {
|
|
220
|
+
var filter = newPrimaryKeyFilter.apply(null, parentRows[0]);
|
|
221
|
+
|
|
222
|
+
for (var i = 1; i < ids.length; i++) {
|
|
223
|
+
const args = [table].concat(parentRows[i]);
|
|
224
|
+
filter = filter.or(newForeignKeyFilter.apply(null, args));
|
|
225
|
+
}
|
|
226
|
+
return filter;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function addToMap(map, primaryColumns, row) {
|
|
231
|
+
|
|
232
|
+
const lastIndex = primaryColumns.length - 1;
|
|
233
|
+
for (let i = 0; i < lastIndex; i++) {
|
|
234
|
+
const id = row[primaryColumns[i].alias];
|
|
235
|
+
if (map.has(id))
|
|
236
|
+
map = map.get(id);
|
|
237
|
+
else {
|
|
238
|
+
const next = new Map();
|
|
239
|
+
map.set(id, next);
|
|
240
|
+
map = next;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
map.set(row[primaryColumns[lastIndex].alias], row);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function getFromMap(map, primaryColumns, values) {
|
|
247
|
+
const length = primaryColumns.length;
|
|
248
|
+
for (let i = 0; i < length; i++) {
|
|
249
|
+
map = map.get(values[i]);
|
|
250
|
+
}
|
|
251
|
+
return map;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
module.exports = getManyDto;
|