drizzle-orm 0.10.45 → 0.10.46
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/package.json +5 -2
- package/{builders → src/builders}/aggregators/abstractAggregator.d.ts +0 -0
- package/{builders → src/builders}/aggregators/abstractAggregator.js +0 -0
- package/{builders → src/builders}/aggregators/deleteAggregator.d.ts +0 -0
- package/{builders → src/builders}/aggregators/deleteAggregator.js +0 -0
- package/{builders → src/builders}/aggregators/insertAggregator.d.ts +0 -0
- package/{builders → src/builders}/aggregators/insertAggregator.js +0 -0
- package/{builders → src/builders}/aggregators/selectAggregator.d.ts +0 -0
- package/{builders → src/builders}/aggregators/selectAggregator.js +0 -0
- package/{builders → src/builders}/aggregators/updateAggregator.d.ts +0 -0
- package/{builders → src/builders}/aggregators/updateAggregator.js +0 -0
- package/{builders → src/builders}/highLvlBuilders/abstractRequestBuilder.d.ts +1 -0
- package/{builders → src/builders}/highLvlBuilders/abstractRequestBuilder.js +1 -0
- package/{builders → src/builders}/highLvlBuilders/deleteRequestBuilder.d.ts +0 -0
- package/{builders → src/builders}/highLvlBuilders/deleteRequestBuilder.js +0 -0
- package/{builders → src/builders}/highLvlBuilders/insertRequestBuilder.d.ts +0 -0
- package/{builders → src/builders}/highLvlBuilders/insertRequestBuilder.js +0 -0
- package/{builders → src/builders}/highLvlBuilders/order.d.ts +0 -0
- package/{builders → src/builders}/highLvlBuilders/order.js +0 -0
- package/{builders → src/builders}/highLvlBuilders/selectRequestBuilder.d.ts +0 -0
- package/{builders → src/builders}/highLvlBuilders/selectRequestBuilder.js +2 -0
- package/{builders → src/builders}/highLvlBuilders/updateRequestBuilder.d.ts +0 -0
- package/{builders → src/builders}/highLvlBuilders/updateRequestBuilder.js +0 -0
- package/{builders → src/builders}/index.d.ts +0 -0
- package/{builders → src/builders}/index.js +0 -0
- package/{builders → src/builders}/joinBuilders/builders/abstractJoinBuilder.d.ts +1 -1
- package/{builders → src/builders}/joinBuilders/builders/abstractJoinBuilder.js +0 -0
- package/{builders → src/builders}/joinBuilders/builders/selectWithFiveJoins.d.ts +1 -1
- package/{builders → src/builders}/joinBuilders/builders/selectWithFiveJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/builders/selectWithFourJoins.d.ts +1 -1
- package/{builders → src/builders}/joinBuilders/builders/selectWithFourJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/builders/selectWithJoin.d.ts +1 -1
- package/{builders → src/builders}/joinBuilders/builders/selectWithJoin.js +0 -0
- package/{builders → src/builders}/joinBuilders/builders/selectWithThreeJoins.d.ts +1 -1
- package/{builders → src/builders}/joinBuilders/builders/selectWithThreeJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/builders/selectWithTwoJoins.d.ts +1 -1
- package/{builders → src/builders}/joinBuilders/builders/selectWithTwoJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/join.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/join.js +0 -0
- package/{builders → src/builders}/joinBuilders/joinWith.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/joinWith.js +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseFiveJoins.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseFiveJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseFourJoins.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseFourJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseThreeJoins.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseThreeJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseTwoJoins.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseTwoJoins.js +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseWithJoin.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/responses/selectResponseWithJoin.js +0 -0
- package/{builders → src/builders}/joinBuilders/static.d.ts +0 -0
- package/{builders → src/builders}/joinBuilders/static.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/alter.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/alter.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/create.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/create.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/delets/delete.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/delets/delete.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/delets/deleteFilter.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/delets/deleteFilter.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/delets/deleteFrom.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/delets/deleteFrom.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/insert.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/insert.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/insertInto.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/insertInto.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/onConflictInsert.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/onConflictInsert.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/valuesInsert.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/inserts/valuesInsert.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/select.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/select.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/selectFrom.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/selectFrom.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/selectJoined.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/selectJoined.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/whereSelect.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/selects/whereSelect.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/update.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/update.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/updateIn.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/updateIn.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/whereSelect.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/whereSelect.js +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/whereSet.d.ts +0 -0
- package/{builders → src/builders}/lowLvlBuilders/updates/whereSet.js +0 -0
- package/{builders → src/builders}/requestBuilders/updates/combine.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/updates/combine.js +0 -0
- package/{builders → src/builders}/requestBuilders/updates/increment.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/updates/increment.js +0 -0
- package/{builders → src/builders}/requestBuilders/updates/setObjects.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/updates/setObjects.js +0 -0
- package/{builders → src/builders}/requestBuilders/updates/static.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/updates/static.js +0 -0
- package/{builders → src/builders}/requestBuilders/updates/updates.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/updates/updates.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/and.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/and.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/const.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/const.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/constArray.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/constArray.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/eqWhere.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/eqWhere.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/greater.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/greater.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/greaterEq.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/greaterEq.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/in.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/in.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/isNotNull.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/isNotNull.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/isNull.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/isNull.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/less.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/less.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/lessEq.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/lessEq.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/like.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/like.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/notEqWhere.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/notEqWhere.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/or.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/or.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/rawWhere.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/rawWhere.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/static.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/static.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/var.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/var.js +0 -0
- package/{builders → src/builders}/requestBuilders/where/where.d.ts +0 -0
- package/{builders → src/builders}/requestBuilders/where/where.js +0 -0
- package/{builders → src/builders}/transaction/transaction.d.ts +0 -0
- package/{builders → src/builders}/transaction/transaction.js +0 -0
- package/{columns → src/columns}/column.d.ts +0 -0
- package/{columns → src/columns}/column.js +0 -0
- package/{columns → src/columns}/index.d.ts +0 -0
- package/{columns → src/columns}/index.js +0 -0
- package/{columns → src/columns}/types/columnType.d.ts +0 -0
- package/{columns → src/columns}/types/columnType.js +0 -0
- package/{columns → src/columns}/types/pgBigDecimal.d.ts +0 -0
- package/{columns → src/columns}/types/pgBigDecimal.js +0 -0
- package/{columns → src/columns}/types/pgBigInt.d.ts +0 -0
- package/{columns → src/columns}/types/pgBigInt.js +0 -0
- package/{columns → src/columns}/types/pgBigSerial.d.ts +0 -0
- package/{columns → src/columns}/types/pgBigSerial.js +0 -0
- package/{columns → src/columns}/types/pgBoolean.d.ts +0 -0
- package/{columns → src/columns}/types/pgBoolean.js +0 -0
- package/{columns → src/columns}/types/pgEnum.d.ts +0 -0
- package/{columns → src/columns}/types/pgEnum.js +0 -0
- package/{columns → src/columns}/types/pgInteger.d.ts +0 -0
- package/{columns → src/columns}/types/pgInteger.js +0 -0
- package/{columns → src/columns}/types/pgJsonb.d.ts +0 -0
- package/{columns → src/columns}/types/pgJsonb.js +0 -0
- package/{columns → src/columns}/types/pgSerial.d.ts +0 -0
- package/{columns → src/columns}/types/pgSerial.js +0 -0
- package/{columns → src/columns}/types/pgSmallInt.d.ts +0 -0
- package/{columns → src/columns}/types/pgSmallInt.js +0 -0
- package/{columns → src/columns}/types/pgText.d.ts +0 -0
- package/{columns → src/columns}/types/pgText.js +0 -0
- package/{columns → src/columns}/types/pgTime.d.ts +0 -0
- package/{columns → src/columns}/types/pgTime.js +0 -0
- package/{columns → src/columns}/types/pgTimestamp.d.ts +0 -0
- package/{columns → src/columns}/types/pgTimestamp.js +0 -0
- package/{columns → src/columns}/types/pgTimestamptz.d.ts +0 -0
- package/{columns → src/columns}/types/pgTimestamptz.js +0 -0
- package/{columns → src/columns}/types/pgVarChar.d.ts +0 -0
- package/{columns → src/columns}/types/pgVarChar.js +0 -0
- package/{db → src/db}/db.d.ts +0 -0
- package/{db → src/db}/db.js +0 -0
- package/{db → src/db}/dbConnector.d.ts +0 -0
- package/{db → src/db}/dbConnector.js +2 -2
- package/{db → src/db}/dbStringConnector.d.ts +0 -0
- package/{db → src/db}/dbStringConnector.js +0 -0
- package/{db → src/db}/group_by.d.ts +0 -0
- package/{db → src/db}/group_by.js +0 -0
- package/{db → src/db}/index.d.ts +0 -0
- package/{db → src/db}/index.js +0 -0
- package/{db → src/db}/session.d.ts +5 -2
- package/{db → src/db}/session.js +8 -1
- package/{docs → src/docs}/cases/simple_delete.d.ts +0 -0
- package/{docs → src/docs}/cases/simple_delete.js +0 -0
- package/{docs → src/docs}/cases/simple_insert.d.ts +0 -0
- package/{docs → src/docs}/cases/simple_insert.js +0 -0
- package/{docs → src/docs}/cases/simple_join.d.ts +0 -0
- package/{docs → src/docs}/cases/simple_join.js +0 -0
- package/{docs → src/docs}/cases/simple_select.d.ts +0 -0
- package/{docs → src/docs}/cases/simple_select.js +0 -0
- package/{docs → src/docs}/cases/simple_update.d.ts +0 -0
- package/{docs → src/docs}/cases/simple_update.js +0 -0
- package/{docs → src/docs}/tables/citiesTable.d.ts +0 -0
- package/{docs → src/docs}/tables/citiesTable.js +0 -0
- package/{docs → src/docs}/tables/userGroupsTable.d.ts +0 -0
- package/{docs → src/docs}/tables/userGroupsTable.js +0 -0
- package/{docs → src/docs}/tables/usersTable.d.ts +0 -0
- package/{docs → src/docs}/tables/usersTable.js +0 -0
- package/{docs → src/docs}/tables/usersToUserGroups.d.ts +0 -0
- package/{docs → src/docs}/tables/usersToUserGroups.js +0 -0
- package/{docs → src/docs}/types/rolesType.d.ts +0 -0
- package/{docs → src/docs}/types/rolesType.js +0 -0
- package/{errors → src/errors}/baseError.d.ts +0 -0
- package/{errors → src/errors}/baseError.js +0 -0
- package/{errors → src/errors}/builderError.d.ts +0 -0
- package/{errors → src/errors}/builderError.js +0 -0
- package/{errors → src/errors}/dbErrors.d.ts +0 -0
- package/{errors → src/errors}/dbErrors.js +0 -0
- package/{index.d.ts → src/index.d.ts} +0 -0
- package/{index.js → src/index.js} +0 -0
- package/{indexes → src/indexes}/tableIndex.d.ts +0 -0
- package/{indexes → src/indexes}/tableIndex.js +0 -0
- package/{logger → src/logger}/abstractLogger.d.ts +0 -0
- package/{logger → src/logger}/abstractLogger.js +0 -0
- package/{logger → src/logger}/consoleLogger.d.ts +0 -0
- package/{logger → src/logger}/consoleLogger.js +0 -0
- package/{mappers → src/mappers}/index.d.ts +0 -0
- package/{mappers → src/mappers}/index.js +0 -0
- package/{mappers → src/mappers}/responseMapper.d.ts +0 -0
- package/{mappers → src/mappers}/responseMapper.js +0 -0
- package/{migrator → src/migrator}/index.d.ts +0 -0
- package/{migrator → src/migrator}/index.js +0 -0
- package/{migrator → src/migrator}/migrator.d.ts +0 -0
- package/{migrator → src/migrator}/migrator.js +0 -0
- package/{serializer → src/serializer}/serializer.d.ts +15 -4
- package/{serializer → src/serializer}/serializer.js +0 -0
- package/{tables → src/tables}/abstractTable.d.ts +0 -0
- package/{tables → src/tables}/abstractTable.js +0 -0
- package/{tables → src/tables}/index.d.ts +0 -0
- package/{tables → src/tables}/index.js +0 -0
- package/{tables → src/tables}/inferTypes.d.ts +0 -0
- package/{tables → src/tables}/inferTypes.js +0 -0
- package/{tables → src/tables}/migrationsTable.d.ts +0 -0
- package/{tables → src/tables}/migrationsTable.js +0 -0
- package/src/test.d.ts +0 -0
- package/src/test.js +135 -0
- package/{types → src/types}/type.d.ts +0 -0
- package/{types → src/types}/type.js +0 -0
- package/{utils → src/utils}/ecranate.d.ts +0 -0
- package/{utils → src/utils}/ecranate.js +0 -0
- package/tests/columnTypesTests/int/int.test.d.ts +1 -0
- package/tests/columnTypesTests/int/int.test.js +561 -0
- package/tests/columnTypesTests/int/models.d.ts +10 -0
- package/tests/columnTypesTests/int/models.js +69 -0
- package/tests/columnTypesTests/int/to/allIntsTable.d.ts +16 -0
- package/tests/columnTypesTests/int/to/allIntsTable.js +28 -0
- package/tests/examples/selects/index.test.d.ts +1 -0
- package/tests/examples/selects/index.test.js +71 -0
- package/tests/examples/selects/tables/to.d.ts +12 -0
- package/tests/examples/selects/tables/to.js +25 -0
- package/tests/highLevelBuilders/selects/index.test.d.ts +1 -0
- package/tests/highLevelBuilders/selects/index.test.js +61 -0
- package/tests/highLevelBuilders/selects/tables/to.d.ts +12 -0
- package/tests/highLevelBuilders/selects/tables/to.js +25 -0
- package/{test.d.ts → tests/lowLevelbuilders/filters/filters.test.d.ts} +0 -0
- package/tests/lowLevelbuilders/filters/filters.test.js +56 -0
- package/tests/lowLevelbuilders/filters/usersTable.d.ts +18 -0
- package/tests/lowLevelbuilders/filters/usersTable.js +32 -0
- package/tests/lowLevelbuilders/updates/updates.test.d.ts +1 -0
- package/tests/lowLevelbuilders/updates/updates.test.js +50 -0
- package/tests/lowLevelbuilders/updates/usersTable.d.ts +18 -0
- package/tests/lowLevelbuilders/updates/usersTable.js +32 -0
- package/tests/suites/simpleTableSuite/allInts/usersTable.d.ts +11 -0
- package/tests/suites/simpleTableSuite/allInts/usersTable.js +22 -0
- package/tests/suites/simpleTableSuite/allTexts/usersTable.d.ts +11 -0
- package/tests/suites/simpleTableSuite/allTexts/usersTable.js +22 -0
- package/tests/utils.d.ts +8 -0
- package/tests/utils.js +75 -0
- package/test.js +0 -104
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
23
|
+
require("dotenv/config");
|
|
24
|
+
const uvu_1 = require("uvu");
|
|
25
|
+
const assert = __importStar(require("uvu/assert"));
|
|
26
|
+
const src_1 = require("../../../src");
|
|
27
|
+
const utils_1 = require("../../utils");
|
|
28
|
+
const models_1 = require("./models");
|
|
29
|
+
const allIntsTable_1 = __importStar(require("./to/allIntsTable")), schema = allIntsTable_1;
|
|
30
|
+
const allIntsTable_2 = require("./to/allIntsTable");
|
|
31
|
+
const AllIntsSuite = uvu_1.suite('AllIntsSuite', {
|
|
32
|
+
db: undefined,
|
|
33
|
+
allIntsTable: undefined,
|
|
34
|
+
});
|
|
35
|
+
AllIntsSuite.before(async (context) => {
|
|
36
|
+
try {
|
|
37
|
+
const db = await new src_1.DbConnector()
|
|
38
|
+
.params({
|
|
39
|
+
database: process.env.POSTGRES_DB,
|
|
40
|
+
host: process.env.POSTGRES_HOST,
|
|
41
|
+
port: Number(process.env.POSTGRES_PORT),
|
|
42
|
+
password: process.env.POSTGRES_PASSWORD,
|
|
43
|
+
user: 'postgres',
|
|
44
|
+
})
|
|
45
|
+
.connect();
|
|
46
|
+
context.db = db;
|
|
47
|
+
context.allIntsTable = new allIntsTable_1.default(db);
|
|
48
|
+
const sql = await utils_1.prepareTestSqlFromSchema(schema);
|
|
49
|
+
await db.session().execute(sql);
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
console.log(e);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
// Success cases
|
|
56
|
+
// Flow
|
|
57
|
+
// 1. insert by <strategy>
|
|
58
|
+
// -> 2.select and check expected values (full + several partial selects)
|
|
59
|
+
// -> 3. update by <strategy>
|
|
60
|
+
// -> 4. select and check expected values (full + several partial selects)
|
|
61
|
+
// -> 5. delete by <strategy>
|
|
62
|
+
// -> 6. select and check expected values (full + several partial selects)
|
|
63
|
+
// Insert strategies (each insert should have all() + execute()
|
|
64
|
+
// After using all() -> check that returned object fields are expected
|
|
65
|
+
// )
|
|
66
|
+
// 1. insert all fields to table;
|
|
67
|
+
// 2. insert all required fields to table;
|
|
68
|
+
// 3. insertMany with same model for all inserted values;
|
|
69
|
+
// 4. insertMany with different models for all inserted values;
|
|
70
|
+
// 5. insert with onConflict statement on each field, that has such possibility(upsert)
|
|
71
|
+
// Update strategies (each update should have all() + execute()
|
|
72
|
+
// After using all() -> check that returned object fields are expected
|
|
73
|
+
// )
|
|
74
|
+
// 1. Update all fields from table;
|
|
75
|
+
// 2. Update 1 by 1 field from table;
|
|
76
|
+
// 3. Update batches of several fields from table(2-3 different batches will be enough);
|
|
77
|
+
// Delete strategies (each delete should have all() + execute()
|
|
78
|
+
// After using all() -> check that returned object fields are expected
|
|
79
|
+
// )
|
|
80
|
+
// 1. Delete rows by each field values
|
|
81
|
+
// Exception cases
|
|
82
|
+
// Insert cases
|
|
83
|
+
// 1. Insert with same unique key - should have an excpetion
|
|
84
|
+
// 2. Insert with same primary key - should have an excpetion
|
|
85
|
+
// 3. Insert float instead of int - should have an excpetion
|
|
86
|
+
// 4. OnConflict was used by unexisting index - should have an exception
|
|
87
|
+
// Update cases
|
|
88
|
+
// 1. Update with same unique key - should have an excpetion
|
|
89
|
+
// 2. Update with same primary key - should have an excpetion
|
|
90
|
+
// 3. Update to float instead of int - should have an excpetion
|
|
91
|
+
// Delete cases
|
|
92
|
+
// Select cases
|
|
93
|
+
// Insert
|
|
94
|
+
AllIntsSuite('Insert all fields to table', async (context) => {
|
|
95
|
+
const allIntsTable = context.allIntsTable;
|
|
96
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
97
|
+
const insertedValues = await allIntsTable.insert(models_1.mixedFields).all();
|
|
98
|
+
const fullSelectResponse = await allIntsTable.select().all();
|
|
99
|
+
const partialSelectResponse = await allIntsTable
|
|
100
|
+
.select({
|
|
101
|
+
notNullInt: allIntsTable.notNullInt,
|
|
102
|
+
intWithDefault: allIntsTable.intWithDefault,
|
|
103
|
+
})
|
|
104
|
+
.all();
|
|
105
|
+
assert.is(insertedValues.length, 1);
|
|
106
|
+
assert.equal(insertedValues[0], models_1.mixedFields);
|
|
107
|
+
assert.is(fullSelectResponse.length, 2);
|
|
108
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0], models_1.allPositiveFields);
|
|
109
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.mixedFields.serialInt)[0], models_1.mixedFields);
|
|
110
|
+
assert.is(partialSelectResponse.length, 2);
|
|
111
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.allPositiveFields.notNullInt)[0]
|
|
112
|
+
.intWithDefault, models_1.allPositiveFields.intWithDefault);
|
|
113
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.mixedFields.notNullInt)[0]
|
|
114
|
+
.intWithDefault, models_1.mixedFields.intWithDefault);
|
|
115
|
+
});
|
|
116
|
+
AllIntsSuite('Insert all required fields to table', async (context) => {
|
|
117
|
+
const allIntsTable = context.allIntsTable;
|
|
118
|
+
await allIntsTable.insert(models_1.requiredPositiveFields).execute();
|
|
119
|
+
const insertedValues = await allIntsTable.insert(models_1.requiredMixedFields).all();
|
|
120
|
+
const fullSelectResponse = await allIntsTable.select().all();
|
|
121
|
+
const partialSelectResponse = await allIntsTable
|
|
122
|
+
.select({
|
|
123
|
+
notNullInt: allIntsTable.notNullInt,
|
|
124
|
+
notNullIntWithDefault: allIntsTable.notNullIntWithDefault,
|
|
125
|
+
notNullUniqueInt: allIntsTable.notNullUniqueInt,
|
|
126
|
+
})
|
|
127
|
+
.all();
|
|
128
|
+
assert.is(insertedValues.length, 1);
|
|
129
|
+
assert.equal(insertedValues[0], {
|
|
130
|
+
...models_1.requiredMixedFields,
|
|
131
|
+
serialInt: 2,
|
|
132
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
133
|
+
uniqueInt: undefined,
|
|
134
|
+
simpleInt: undefined,
|
|
135
|
+
});
|
|
136
|
+
assert.is(fullSelectResponse.length, 2);
|
|
137
|
+
assert.equal(fullSelectResponse.filter((it) => it.primaryInt === models_1.requiredPositiveFields.primaryInt)[0], {
|
|
138
|
+
...models_1.requiredPositiveFields,
|
|
139
|
+
serialInt: 1,
|
|
140
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
141
|
+
uniqueInt: undefined,
|
|
142
|
+
simpleInt: undefined,
|
|
143
|
+
});
|
|
144
|
+
assert.equal(fullSelectResponse.filter((it) => it.primaryInt === models_1.requiredMixedFields.primaryInt)[0], {
|
|
145
|
+
...models_1.requiredMixedFields,
|
|
146
|
+
serialInt: 2,
|
|
147
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
148
|
+
uniqueInt: undefined,
|
|
149
|
+
simpleInt: undefined,
|
|
150
|
+
});
|
|
151
|
+
assert.is(partialSelectResponse.length, 2);
|
|
152
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.requiredPositiveFields.notNullInt)[0]
|
|
153
|
+
.notNullInt, models_1.requiredPositiveFields.notNullInt);
|
|
154
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.requiredMixedFields.notNullInt)[0]
|
|
155
|
+
.notNullInt, models_1.requiredMixedFields.notNullInt);
|
|
156
|
+
});
|
|
157
|
+
AllIntsSuite('InsertMany with same model for all inserted values', async (context) => {
|
|
158
|
+
const allIntsTable = context.allIntsTable;
|
|
159
|
+
await allIntsTable.insertMany([models_1.allPositiveFields, models_1.mixedFields]).execute();
|
|
160
|
+
const insertedValues = await allIntsTable
|
|
161
|
+
.insertMany([models_1.updatePositiveFields, models_1.updateMixedFields])
|
|
162
|
+
.all();
|
|
163
|
+
const fullSelectResponse = await allIntsTable.select().all();
|
|
164
|
+
const partialSelectResponse = await allIntsTable
|
|
165
|
+
.select({
|
|
166
|
+
notNullInt: allIntsTable.notNullInt,
|
|
167
|
+
notNullIntWithDefault: allIntsTable.notNullIntWithDefault,
|
|
168
|
+
notNullUniqueInt: allIntsTable.notNullUniqueInt,
|
|
169
|
+
})
|
|
170
|
+
.all();
|
|
171
|
+
assert.is(insertedValues.length, 2);
|
|
172
|
+
assert.equal(insertedValues[0], models_1.updatePositiveFields);
|
|
173
|
+
assert.equal(insertedValues[1], models_1.updateMixedFields);
|
|
174
|
+
assert.is(fullSelectResponse.length, 4);
|
|
175
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0], models_1.allPositiveFields);
|
|
176
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.mixedFields.serialInt)[0], models_1.mixedFields);
|
|
177
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.updatePositiveFields.serialInt)[0], models_1.updatePositiveFields);
|
|
178
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.updateMixedFields.serialInt)[0], models_1.updateMixedFields);
|
|
179
|
+
assert.is(partialSelectResponse.length, 4);
|
|
180
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.allPositiveFields.notNullInt)[0]
|
|
181
|
+
.notNullUniqueInt, models_1.allPositiveFields.notNullUniqueInt);
|
|
182
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.mixedFields.notNullInt)[0]
|
|
183
|
+
.notNullUniqueInt, models_1.mixedFields.notNullUniqueInt);
|
|
184
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.updatePositiveFields.notNullInt)[0]
|
|
185
|
+
.notNullUniqueInt, models_1.updatePositiveFields.notNullUniqueInt);
|
|
186
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.updateMixedFields.notNullInt)[0]
|
|
187
|
+
.notNullUniqueInt, models_1.updateMixedFields.notNullUniqueInt);
|
|
188
|
+
});
|
|
189
|
+
AllIntsSuite('InsertMany with different models for all inserted values', async (context) => {
|
|
190
|
+
const allIntsTable = context.allIntsTable;
|
|
191
|
+
await allIntsTable.insertMany([models_1.allPositiveFields, models_1.differentPositiveFields]).execute();
|
|
192
|
+
const insertedValues = await allIntsTable.insertMany([models_1.mixedFields, models_1.differentMixedFields]).all();
|
|
193
|
+
const fullSelectResponse = await allIntsTable.select().all();
|
|
194
|
+
const partialSelectResponse = await allIntsTable
|
|
195
|
+
.select({
|
|
196
|
+
notNullInt: allIntsTable.notNullInt,
|
|
197
|
+
notNullIntWithDefault: allIntsTable.notNullIntWithDefault,
|
|
198
|
+
notNullUniqueInt: allIntsTable.notNullUniqueInt,
|
|
199
|
+
})
|
|
200
|
+
.all();
|
|
201
|
+
assert.is(insertedValues.length, 2);
|
|
202
|
+
assert.equal(insertedValues[0], models_1.mixedFields);
|
|
203
|
+
assert.equal(insertedValues[1], {
|
|
204
|
+
...models_1.differentMixedFields,
|
|
205
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
206
|
+
uniqueInt: undefined,
|
|
207
|
+
simpleInt: undefined,
|
|
208
|
+
});
|
|
209
|
+
assert.is(fullSelectResponse.length, 4);
|
|
210
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0], models_1.allPositiveFields);
|
|
211
|
+
assert.equal(fullSelectResponse.filter((it) => it.serialInt === models_1.mixedFields.serialInt)[0], models_1.mixedFields);
|
|
212
|
+
assert.equal(fullSelectResponse.filter((it) => it.primaryInt === models_1.differentPositiveFields.primaryInt)[0], {
|
|
213
|
+
...models_1.differentPositiveFields,
|
|
214
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
215
|
+
uniqueInt: undefined,
|
|
216
|
+
simpleInt: undefined,
|
|
217
|
+
});
|
|
218
|
+
assert.equal(fullSelectResponse.filter((it) => it.primaryInt === models_1.differentMixedFields.primaryInt)[0], {
|
|
219
|
+
...models_1.differentMixedFields,
|
|
220
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
221
|
+
uniqueInt: undefined,
|
|
222
|
+
simpleInt: undefined,
|
|
223
|
+
});
|
|
224
|
+
assert.is(partialSelectResponse.length, 4);
|
|
225
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.allPositiveFields.notNullInt)[0]
|
|
226
|
+
.notNullUniqueInt, models_1.allPositiveFields.notNullUniqueInt);
|
|
227
|
+
assert.is(partialSelectResponse.filter((it) => it.notNullInt === models_1.mixedFields.notNullInt)[0]
|
|
228
|
+
.notNullUniqueInt, models_1.mixedFields.notNullUniqueInt);
|
|
229
|
+
assert.equal(fullSelectResponse.filter((it) => it.primaryInt === models_1.differentPositiveFields.primaryInt)[0], {
|
|
230
|
+
...models_1.differentPositiveFields,
|
|
231
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
232
|
+
uniqueInt: undefined,
|
|
233
|
+
simpleInt: undefined,
|
|
234
|
+
});
|
|
235
|
+
assert.equal(fullSelectResponse.filter((it) => it.primaryInt === models_1.differentMixedFields.primaryInt)[0], {
|
|
236
|
+
...models_1.differentMixedFields,
|
|
237
|
+
intWithDefault: allIntsTable_2.defaultInt,
|
|
238
|
+
uniqueInt: undefined,
|
|
239
|
+
simpleInt: undefined,
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
AllIntsSuite('Insert with onConflict statement', async (context) => {
|
|
243
|
+
const allIntsTable = context.allIntsTable;
|
|
244
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
245
|
+
try {
|
|
246
|
+
await allIntsTable
|
|
247
|
+
.insertMany([models_1.allPositiveFields, models_1.updatePositiveFields])
|
|
248
|
+
.onConflict((table) => table.simpleIntIndex, { simpleInt: 777 })
|
|
249
|
+
.all();
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
assert.unreachable(err.message);
|
|
253
|
+
}
|
|
254
|
+
const select = await allIntsTable.select().all();
|
|
255
|
+
assert.is(select.length, 2);
|
|
256
|
+
assert.is(select.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0].simpleInt, 777);
|
|
257
|
+
});
|
|
258
|
+
// ticket DRI-17
|
|
259
|
+
// AllIntsSuite('Inserting an null value into a serial field', async (context) => {
|
|
260
|
+
// const allIntsTable = context.allIntsTable!;
|
|
261
|
+
// const undefinedSerial = { ...allPositiveFields, serialInt: undefined };
|
|
262
|
+
// try {
|
|
263
|
+
// await allIntsTable.insert(undefinedSerial).execute();
|
|
264
|
+
// } catch (error) {
|
|
265
|
+
// assert.unreachable(err.message);
|
|
266
|
+
// }
|
|
267
|
+
// const selectResponse = await allIntsTable.select().all();
|
|
268
|
+
// assert.is(selectResponse.length, 1);
|
|
269
|
+
// });
|
|
270
|
+
// Update
|
|
271
|
+
AllIntsSuite('Update all fields from table', async (context) => {
|
|
272
|
+
const allIntsTable = context.allIntsTable;
|
|
273
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
274
|
+
await allIntsTable.insert(models_1.mixedFields).execute();
|
|
275
|
+
await allIntsTable
|
|
276
|
+
.update()
|
|
277
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.allPositiveFields.serialInt))
|
|
278
|
+
.set(models_1.updatePositiveFields)
|
|
279
|
+
.execute();
|
|
280
|
+
const updatedValues = await allIntsTable
|
|
281
|
+
.update()
|
|
282
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.mixedFields.serialInt))
|
|
283
|
+
.set(models_1.updateMixedFields)
|
|
284
|
+
.all();
|
|
285
|
+
const fullSelectUpdate = await allIntsTable.select().all();
|
|
286
|
+
const partialSelectUpdate = await allIntsTable
|
|
287
|
+
.select({
|
|
288
|
+
uniqueInt: allIntsTable.uniqueInt,
|
|
289
|
+
notNullUniqueInt: allIntsTable.notNullUniqueInt,
|
|
290
|
+
})
|
|
291
|
+
.all();
|
|
292
|
+
assert.is(updatedValues.length, 1);
|
|
293
|
+
assert.equal(updatedValues[0], models_1.updateMixedFields);
|
|
294
|
+
assert.is(fullSelectUpdate.length, 2);
|
|
295
|
+
assert.equal(fullSelectUpdate.filter((it) => it.serialInt === models_1.updatePositiveFields.serialInt)[0], models_1.updatePositiveFields);
|
|
296
|
+
assert.equal(fullSelectUpdate.filter((it) => it.serialInt === models_1.updateMixedFields.serialInt)[0], models_1.updateMixedFields);
|
|
297
|
+
assert.is(partialSelectUpdate.length, 2);
|
|
298
|
+
assert.is(partialSelectUpdate.filter((it) => it.uniqueInt === models_1.updatePositiveFields.uniqueInt)[0]
|
|
299
|
+
.notNullUniqueInt, models_1.updatePositiveFields.notNullUniqueInt);
|
|
300
|
+
assert.is(partialSelectUpdate.filter((it) => it.uniqueInt === models_1.updateMixedFields.uniqueInt)[0]
|
|
301
|
+
.notNullUniqueInt, models_1.updateMixedFields.notNullUniqueInt);
|
|
302
|
+
});
|
|
303
|
+
AllIntsSuite('Update 1 by 1 field from table', async (context) => {
|
|
304
|
+
const allIntsTable = context.allIntsTable;
|
|
305
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
306
|
+
await allIntsTable.insert(models_1.mixedFields).execute();
|
|
307
|
+
await allIntsTable
|
|
308
|
+
.update()
|
|
309
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.allPositiveFields.serialInt))
|
|
310
|
+
.set({ simpleInt: models_1.updatePositiveFields.simpleInt })
|
|
311
|
+
.execute();
|
|
312
|
+
const updatedValues = await allIntsTable
|
|
313
|
+
.update()
|
|
314
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.mixedFields.serialInt))
|
|
315
|
+
.set({ simpleInt: models_1.updateMixedFields.simpleInt })
|
|
316
|
+
.all();
|
|
317
|
+
const fullSelectUpdate = await allIntsTable.select().all();
|
|
318
|
+
const partialSelectUpdate = await allIntsTable
|
|
319
|
+
.select({
|
|
320
|
+
uniqueInt: allIntsTable.uniqueInt,
|
|
321
|
+
notNullUniqueInt: allIntsTable.notNullUniqueInt,
|
|
322
|
+
simpleInt: allIntsTable.simpleInt,
|
|
323
|
+
})
|
|
324
|
+
.all();
|
|
325
|
+
assert.is(updatedValues.length, 1);
|
|
326
|
+
assert.equal(updatedValues[0], {
|
|
327
|
+
...models_1.mixedFields,
|
|
328
|
+
simpleInt: models_1.updateMixedFields.simpleInt,
|
|
329
|
+
});
|
|
330
|
+
assert.is(fullSelectUpdate.length, 2);
|
|
331
|
+
assert.equal(fullSelectUpdate.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0], {
|
|
332
|
+
...models_1.allPositiveFields,
|
|
333
|
+
simpleInt: models_1.updatePositiveFields.simpleInt,
|
|
334
|
+
});
|
|
335
|
+
assert.equal(fullSelectUpdate.filter((it) => it.serialInt === models_1.mixedFields.serialInt)[0], {
|
|
336
|
+
...models_1.mixedFields,
|
|
337
|
+
simpleInt: models_1.updateMixedFields.simpleInt,
|
|
338
|
+
});
|
|
339
|
+
assert.is(partialSelectUpdate.length, 2);
|
|
340
|
+
assert.is(partialSelectUpdate.filter((it) => it.uniqueInt === models_1.allPositiveFields.uniqueInt)[0].simpleInt, models_1.updatePositiveFields.simpleInt);
|
|
341
|
+
assert.is(partialSelectUpdate.filter((it) => it.uniqueInt === models_1.mixedFields.uniqueInt)[0].simpleInt, models_1.updateMixedFields.simpleInt);
|
|
342
|
+
});
|
|
343
|
+
AllIntsSuite('Update batches of several fields from table', async (context) => {
|
|
344
|
+
const allIntsTable = context.allIntsTable;
|
|
345
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
346
|
+
await allIntsTable.insert(models_1.mixedFields).execute();
|
|
347
|
+
await allIntsTable
|
|
348
|
+
.update()
|
|
349
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.allPositiveFields.serialInt))
|
|
350
|
+
.set({
|
|
351
|
+
notNullUniqueInt: models_1.updatePositiveFields.notNullUniqueInt,
|
|
352
|
+
notNullInt: models_1.updatePositiveFields.notNullInt,
|
|
353
|
+
notNullIntWithDefault: models_1.updatePositiveFields.notNullIntWithDefault,
|
|
354
|
+
})
|
|
355
|
+
.execute();
|
|
356
|
+
const updatedValues = await allIntsTable
|
|
357
|
+
.update()
|
|
358
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.mixedFields.serialInt))
|
|
359
|
+
.set({
|
|
360
|
+
notNullUniqueInt: models_1.updateMixedFields.notNullUniqueInt,
|
|
361
|
+
notNullInt: models_1.updateMixedFields.notNullInt,
|
|
362
|
+
notNullIntWithDefault: models_1.updateMixedFields.notNullIntWithDefault,
|
|
363
|
+
})
|
|
364
|
+
.all();
|
|
365
|
+
const fullSelectUpdate = await allIntsTable.select().all();
|
|
366
|
+
const partialSelectUpdate = await allIntsTable
|
|
367
|
+
.select({
|
|
368
|
+
serialInt: allIntsTable.serialInt,
|
|
369
|
+
uniqueInt: allIntsTable.uniqueInt,
|
|
370
|
+
notNullUniqueInt: allIntsTable.notNullUniqueInt,
|
|
371
|
+
})
|
|
372
|
+
.all();
|
|
373
|
+
assert.is(updatedValues.length, 1);
|
|
374
|
+
assert.equal(updatedValues[0], {
|
|
375
|
+
...models_1.mixedFields,
|
|
376
|
+
notNullUniqueInt: models_1.updateMixedFields.notNullUniqueInt,
|
|
377
|
+
notNullInt: models_1.updateMixedFields.notNullInt,
|
|
378
|
+
notNullIntWithDefault: models_1.updateMixedFields.notNullIntWithDefault,
|
|
379
|
+
});
|
|
380
|
+
assert.is(fullSelectUpdate.length, 2);
|
|
381
|
+
assert.equal(fullSelectUpdate.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0], {
|
|
382
|
+
...models_1.allPositiveFields,
|
|
383
|
+
notNullUniqueInt: models_1.updatePositiveFields.notNullUniqueInt,
|
|
384
|
+
notNullInt: models_1.updatePositiveFields.notNullInt,
|
|
385
|
+
notNullIntWithDefault: models_1.updatePositiveFields.notNullIntWithDefault,
|
|
386
|
+
});
|
|
387
|
+
assert.equal(fullSelectUpdate.filter((it) => it.serialInt === models_1.mixedFields.serialInt)[0], {
|
|
388
|
+
...models_1.mixedFields,
|
|
389
|
+
notNullUniqueInt: models_1.updateMixedFields.notNullUniqueInt,
|
|
390
|
+
notNullInt: models_1.updateMixedFields.notNullInt,
|
|
391
|
+
notNullIntWithDefault: models_1.updateMixedFields.notNullIntWithDefault,
|
|
392
|
+
});
|
|
393
|
+
assert.is(partialSelectUpdate.length, 2);
|
|
394
|
+
assert.is(partialSelectUpdate.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0]
|
|
395
|
+
.notNullUniqueInt, models_1.updatePositiveFields.notNullUniqueInt);
|
|
396
|
+
assert.is(partialSelectUpdate.filter((it) => it.serialInt === models_1.mixedFields.serialInt)[0].notNullUniqueInt, models_1.updateMixedFields.notNullUniqueInt);
|
|
397
|
+
});
|
|
398
|
+
// Delete
|
|
399
|
+
AllIntsSuite('Delete by serial int', async (context) => {
|
|
400
|
+
const allIntsTable = context.allIntsTable;
|
|
401
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
402
|
+
await allIntsTable.insert(models_1.mixedFields).execute();
|
|
403
|
+
await allIntsTable
|
|
404
|
+
.delete()
|
|
405
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.allPositiveFields.serialInt))
|
|
406
|
+
.execute();
|
|
407
|
+
const partialSelectDelete = await allIntsTable
|
|
408
|
+
.select({
|
|
409
|
+
primaryInt: allIntsTable.primaryInt,
|
|
410
|
+
simpleInt: allIntsTable.simpleInt,
|
|
411
|
+
})
|
|
412
|
+
.all();
|
|
413
|
+
const deleteValue = await allIntsTable
|
|
414
|
+
.delete()
|
|
415
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.mixedFields.serialInt))
|
|
416
|
+
.all();
|
|
417
|
+
const fullSelectDelete = await allIntsTable.select().all();
|
|
418
|
+
assert.is(deleteValue.length, 1);
|
|
419
|
+
assert.equal(deleteValue[0], models_1.mixedFields);
|
|
420
|
+
assert.is(partialSelectDelete.length, 1);
|
|
421
|
+
assert.is(partialSelectDelete.filter((it) => it.primaryInt === models_1.mixedFields.primaryInt)[0].simpleInt, models_1.mixedFields.simpleInt);
|
|
422
|
+
assert.not(partialSelectDelete.filter((it) => it.primaryInt === models_1.allPositiveFields.primaryInt)[0]);
|
|
423
|
+
assert.is(fullSelectDelete.length, 0);
|
|
424
|
+
assert.not(fullSelectDelete.filter((it) => it.serialInt === models_1.allPositiveFields.serialInt)[0]);
|
|
425
|
+
assert.not(fullSelectDelete.filter((it) => it.serialInt === models_1.mixedFields.serialInt)[0]);
|
|
426
|
+
});
|
|
427
|
+
// Exception cases
|
|
428
|
+
// Insert
|
|
429
|
+
AllIntsSuite('Exception cases: insert double primary int', async (context) => {
|
|
430
|
+
const allIntsTable = context.allIntsTable;
|
|
431
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
432
|
+
const doublePrimaryInt = {
|
|
433
|
+
...models_1.allPositiveFields,
|
|
434
|
+
uniqueInt: Math.round(Math.random() * 100),
|
|
435
|
+
notNullUniqueInt: Math.round(Math.random() * 100),
|
|
436
|
+
};
|
|
437
|
+
try {
|
|
438
|
+
await allIntsTable.insert(doublePrimaryInt).execute();
|
|
439
|
+
assert.unreachable('should have thrown');
|
|
440
|
+
}
|
|
441
|
+
catch (err) {
|
|
442
|
+
assert.is(err.message, 'duplicate key value violates unique constraint "table_with_all_ints_pkey"');
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
AllIntsSuite('Exception cases: insert double unique int', async (context) => {
|
|
446
|
+
const allIntsTable = context.allIntsTable;
|
|
447
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
448
|
+
const doubleUniqueInt = {
|
|
449
|
+
...models_1.allPositiveFields,
|
|
450
|
+
primaryInt: Math.round(Math.random() * 100),
|
|
451
|
+
notNullUniqueInt: Math.round(Math.random() * 100),
|
|
452
|
+
};
|
|
453
|
+
try {
|
|
454
|
+
await allIntsTable.insert(doubleUniqueInt).execute();
|
|
455
|
+
assert.unreachable('should have thrown');
|
|
456
|
+
}
|
|
457
|
+
catch (err) {
|
|
458
|
+
assert.is(err.message, 'duplicate key value violates unique constraint "table_with_all_ints_unique_int_index"');
|
|
459
|
+
}
|
|
460
|
+
});
|
|
461
|
+
AllIntsSuite('Exception cases: insert float ', async (context) => {
|
|
462
|
+
const allIntsTable = context.allIntsTable;
|
|
463
|
+
const addFloat = {
|
|
464
|
+
...models_1.allPositiveFields,
|
|
465
|
+
simpleInt: +(Math.random() * 100).toFixed(2),
|
|
466
|
+
};
|
|
467
|
+
try {
|
|
468
|
+
await allIntsTable.insert(addFloat).execute();
|
|
469
|
+
assert.unreachable('should have thrown');
|
|
470
|
+
}
|
|
471
|
+
catch (err) {
|
|
472
|
+
assert.ok(err.message);
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
AllIntsSuite('Exception cases: onConflict insert used a non-existent index', async (context) => {
|
|
476
|
+
const allIntsTable = context.allIntsTable;
|
|
477
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
478
|
+
try {
|
|
479
|
+
await allIntsTable
|
|
480
|
+
.insertMany([models_1.allPositiveFields, models_1.updatePositiveFields])
|
|
481
|
+
.onConflict((table) => table.intWithDefaultIndex, { intWithDefault: 777 })
|
|
482
|
+
.all();
|
|
483
|
+
assert.unreachable('should have thrown');
|
|
484
|
+
}
|
|
485
|
+
catch (err) {
|
|
486
|
+
assert.is(err.message, 'there is no unique or exclusion constraint matching the ON CONFLICT specification');
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
// Exception cases
|
|
490
|
+
// Update
|
|
491
|
+
AllIntsSuite('Exception cases: update double primary int', async (context) => {
|
|
492
|
+
const allIntsTable = context.allIntsTable;
|
|
493
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
494
|
+
await allIntsTable.insert(models_1.mixedFields).execute();
|
|
495
|
+
const doublePrimaryIntUpdate = {
|
|
496
|
+
...models_1.allPositiveFields,
|
|
497
|
+
primaryInt: models_1.mixedFields.primaryInt,
|
|
498
|
+
};
|
|
499
|
+
try {
|
|
500
|
+
await allIntsTable
|
|
501
|
+
.update()
|
|
502
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.allPositiveFields.serialInt))
|
|
503
|
+
.set(doublePrimaryIntUpdate)
|
|
504
|
+
.execute();
|
|
505
|
+
assert.unreachable('should have thrown');
|
|
506
|
+
}
|
|
507
|
+
catch (err) {
|
|
508
|
+
assert.is(err.message, 'duplicate key value violates unique constraint "table_with_all_ints_pkey"');
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
AllIntsSuite('Exception cases: update double unique int', async (context) => {
|
|
512
|
+
const allIntsTable = context.allIntsTable;
|
|
513
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
514
|
+
await allIntsTable.insert(models_1.mixedFields).execute();
|
|
515
|
+
const doubleUniqueIntUpdate = {
|
|
516
|
+
...models_1.allPositiveFields,
|
|
517
|
+
uniqueInt: models_1.mixedFields.uniqueInt,
|
|
518
|
+
};
|
|
519
|
+
try {
|
|
520
|
+
await allIntsTable
|
|
521
|
+
.update()
|
|
522
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.allPositiveFields.serialInt))
|
|
523
|
+
.set(doubleUniqueIntUpdate)
|
|
524
|
+
.execute();
|
|
525
|
+
assert.unreachable('should have thrown');
|
|
526
|
+
}
|
|
527
|
+
catch (err) {
|
|
528
|
+
assert.is(err.message, 'duplicate key value violates unique constraint "table_with_all_ints_unique_int_index"');
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
AllIntsSuite('Exception cases: update to float', async (context) => {
|
|
532
|
+
const allIntsTable = context.allIntsTable;
|
|
533
|
+
await allIntsTable.insert(models_1.allPositiveFields).execute();
|
|
534
|
+
const addFloatUpdate = {
|
|
535
|
+
...models_1.allPositiveFields,
|
|
536
|
+
simpleInt: +(Math.random() * 100).toFixed(2),
|
|
537
|
+
};
|
|
538
|
+
try {
|
|
539
|
+
await allIntsTable
|
|
540
|
+
.update()
|
|
541
|
+
.where(src_1.eq(allIntsTable.serialInt, models_1.allPositiveFields.serialInt))
|
|
542
|
+
.set(addFloatUpdate)
|
|
543
|
+
.execute();
|
|
544
|
+
assert.unreachable('should have thrown');
|
|
545
|
+
}
|
|
546
|
+
catch (err) {
|
|
547
|
+
assert.ok(err.message);
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
AllIntsSuite('Insert1 -> Update1 -> Delete1', async (context) => {
|
|
551
|
+
const allIntsTable = context.allIntsTable;
|
|
552
|
+
});
|
|
553
|
+
// if needed
|
|
554
|
+
AllIntsSuite.after.each(async (context) => {
|
|
555
|
+
await context.db.session().execute(`TRUNCATE ${context.allIntsTable.tableName()}`);
|
|
556
|
+
});
|
|
557
|
+
AllIntsSuite.after(async (context) => {
|
|
558
|
+
await context.db.session().execute(`DROP TABLE ${context.allIntsTable.tableName()}`);
|
|
559
|
+
await context.db.session().closeConnection();
|
|
560
|
+
});
|
|
561
|
+
AllIntsSuite.run();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExtractModel } from '@/tables';
|
|
2
|
+
import AllIntsTable from './to/allIntsTable';
|
|
3
|
+
export declare const allPositiveFields: ExtractModel<AllIntsTable>;
|
|
4
|
+
export declare const mixedFields: ExtractModel<AllIntsTable>;
|
|
5
|
+
export declare const updatePositiveFields: ExtractModel<AllIntsTable>;
|
|
6
|
+
export declare const updateMixedFields: ExtractModel<AllIntsTable>;
|
|
7
|
+
export declare const requiredPositiveFields: ExtractModel<AllIntsTable>;
|
|
8
|
+
export declare const requiredMixedFields: ExtractModel<AllIntsTable>;
|
|
9
|
+
export declare const differentPositiveFields: ExtractModel<AllIntsTable>;
|
|
10
|
+
export declare const differentMixedFields: ExtractModel<AllIntsTable>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.differentMixedFields = exports.differentPositiveFields = exports.requiredMixedFields = exports.requiredPositiveFields = exports.updateMixedFields = exports.updatePositiveFields = exports.mixedFields = exports.allPositiveFields = void 0;
|
|
4
|
+
exports.allPositiveFields = {
|
|
5
|
+
serialInt: 2,
|
|
6
|
+
primaryInt: 3,
|
|
7
|
+
simpleInt: 4,
|
|
8
|
+
notNullInt: 5,
|
|
9
|
+
intWithDefault: 6,
|
|
10
|
+
notNullIntWithDefault: 7,
|
|
11
|
+
uniqueInt: 8,
|
|
12
|
+
notNullUniqueInt: 9,
|
|
13
|
+
};
|
|
14
|
+
exports.mixedFields = {
|
|
15
|
+
serialInt: 11,
|
|
16
|
+
primaryInt: 12,
|
|
17
|
+
simpleInt: 13,
|
|
18
|
+
notNullInt: 0,
|
|
19
|
+
intWithDefault: -1,
|
|
20
|
+
notNullIntWithDefault: -2,
|
|
21
|
+
uniqueInt: -3,
|
|
22
|
+
notNullUniqueInt: -4,
|
|
23
|
+
};
|
|
24
|
+
exports.updatePositiveFields = {
|
|
25
|
+
primaryInt: 9,
|
|
26
|
+
serialInt: 8,
|
|
27
|
+
simpleInt: 7,
|
|
28
|
+
notNullInt: 6,
|
|
29
|
+
intWithDefault: 5,
|
|
30
|
+
notNullIntWithDefault: 4,
|
|
31
|
+
uniqueInt: 3,
|
|
32
|
+
notNullUniqueInt: 2,
|
|
33
|
+
};
|
|
34
|
+
exports.updateMixedFields = {
|
|
35
|
+
primaryInt: -5,
|
|
36
|
+
serialInt: 14,
|
|
37
|
+
simpleInt: -1,
|
|
38
|
+
notNullInt: 7,
|
|
39
|
+
intWithDefault: 2,
|
|
40
|
+
notNullIntWithDefault: 16,
|
|
41
|
+
uniqueInt: -7,
|
|
42
|
+
notNullUniqueInt: -2,
|
|
43
|
+
};
|
|
44
|
+
exports.requiredPositiveFields = {
|
|
45
|
+
primaryInt: 15,
|
|
46
|
+
notNullInt: 5,
|
|
47
|
+
notNullIntWithDefault: 7,
|
|
48
|
+
notNullUniqueInt: 18,
|
|
49
|
+
};
|
|
50
|
+
exports.requiredMixedFields = {
|
|
51
|
+
primaryInt: 17,
|
|
52
|
+
notNullInt: 0,
|
|
53
|
+
notNullIntWithDefault: -2,
|
|
54
|
+
notNullUniqueInt: -12,
|
|
55
|
+
};
|
|
56
|
+
exports.differentPositiveFields = {
|
|
57
|
+
serialInt: 2,
|
|
58
|
+
primaryInt: 15,
|
|
59
|
+
notNullInt: 5,
|
|
60
|
+
notNullIntWithDefault: 7,
|
|
61
|
+
notNullUniqueInt: 18,
|
|
62
|
+
};
|
|
63
|
+
exports.differentMixedFields = {
|
|
64
|
+
serialInt: 11,
|
|
65
|
+
primaryInt: 17,
|
|
66
|
+
notNullInt: 0,
|
|
67
|
+
notNullIntWithDefault: -2,
|
|
68
|
+
notNullUniqueInt: -12,
|
|
69
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AbstractTable from '../../../../src/tables/abstractTable';
|
|
2
|
+
export declare const defaultInt = 1;
|
|
3
|
+
export declare const notNullWithDefault = 1;
|
|
4
|
+
export default class AllIntsTable extends AbstractTable<AllIntsTable> {
|
|
5
|
+
primaryInt: import("../../../../src").Column<import("../../../../src").PgInteger, false, false, this>;
|
|
6
|
+
serialInt: import("../../../../src").Column<import("../../../../src/columns/types/pgSerial").default, true, true, this>;
|
|
7
|
+
simpleInt: import("../../../../src").Column<import("../../../../src").PgInteger, true, false, this>;
|
|
8
|
+
notNullInt: import("../../../../src").Column<import("../../../../src").PgInteger, false, false, this>;
|
|
9
|
+
intWithDefault: import("../../../../src").Column<import("../../../../src").PgInteger, true, false, this>;
|
|
10
|
+
notNullIntWithDefault: import("../../../../src").Column<import("../../../../src").PgInteger, true, false, this>;
|
|
11
|
+
uniqueInt: import("../../../../src").Column<import("../../../../src").PgInteger, true, false, this>;
|
|
12
|
+
notNullUniqueInt: import("../../../../src").Column<import("../../../../src").PgInteger, false, false, this>;
|
|
13
|
+
simpleIntIndex: import("../../../../src/indexes/tableIndex").default;
|
|
14
|
+
intWithDefaultIndex: import("../../../../src/indexes/tableIndex").default;
|
|
15
|
+
tableName(): string;
|
|
16
|
+
}
|