@expo/entity-database-adapter-knex 0.38.0 → 0.40.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/build/__integration-tests__/PostgresEntityIntegration-test.js +112 -38
- package/build/__integration-tests__/PostgresEntityIntegration-test.js.map +1 -1
- package/build/__integration-tests__/PostgresEntityQueryContextProvider-test.js +14 -7
- package/build/__integration-tests__/PostgresEntityQueryContextProvider-test.js.map +1 -1
- package/build/__integration-tests__/PostgresInvalidSetup-test.js +29 -9
- package/build/__integration-tests__/PostgresInvalidSetup-test.js.map +1 -1
- package/build/__integration-tests__/errors-test.js +24 -12
- package/build/__integration-tests__/errors-test.js.map +1 -1
- package/build/errors/__tests__/wrapNativePostgresCallAsync-test.js +1 -1
- package/build/errors/wrapNativePostgresCallAsync.js +1 -1
- package/build/errors/wrapNativePostgresCallAsync.js.map +1 -1
- package/build/testfixtures/PostgresTriggerTestEntity.js.map +1 -1
- package/build/testfixtures/PostgresValidatorTestEntity.js.map +1 -1
- package/package.json +17 -8
- package/src/__integration-tests__/PostgresEntityIntegration-test.ts +120 -38
- package/src/__integration-tests__/PostgresEntityQueryContextProvider-test.ts +14 -7
- package/src/__integration-tests__/PostgresInvalidSetup-test.ts +31 -11
- package/src/__integration-tests__/errors-test.ts +24 -12
- package/src/errors/__tests__/wrapNativePostgresCallAsync-test.ts +1 -1
- package/src/testfixtures/PostgresTriggerTestEntity.ts +4 -4
- package/src/testfixtures/PostgresValidatorTestEntity.ts +2 -2
|
@@ -42,9 +42,10 @@ describe('postgres errors', () => {
|
|
|
42
42
|
it('throws EntityDatabaseAdapterTransientError on Knex timeout', async () => {
|
|
43
43
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
44
44
|
await ErrorsTestEntity.creator(vc)
|
|
45
|
+
.enforcing()
|
|
45
46
|
.setField('id', 1)
|
|
46
47
|
.setField('fieldNonNull', 'hello')
|
|
47
|
-
.
|
|
48
|
+
.createAsync();
|
|
48
49
|
|
|
49
50
|
const shortTimeoutKnexInstance = knex({
|
|
50
51
|
client: 'pg',
|
|
@@ -70,9 +71,10 @@ describe('postgres errors', () => {
|
|
|
70
71
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
71
72
|
await expect(
|
|
72
73
|
ErrorsTestEntity.creator(vc)
|
|
74
|
+
.enforcing()
|
|
73
75
|
.setField('id', 1)
|
|
74
76
|
.setField('fieldNonNull', null as any)
|
|
75
|
-
.
|
|
77
|
+
.createAsync(),
|
|
76
78
|
).rejects.toThrow(EntityDatabaseAdapterNotNullConstraintError);
|
|
77
79
|
});
|
|
78
80
|
|
|
@@ -80,10 +82,11 @@ describe('postgres errors', () => {
|
|
|
80
82
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
81
83
|
await expect(
|
|
82
84
|
ErrorsTestEntity.creator(vc)
|
|
85
|
+
.enforcing()
|
|
83
86
|
.setField('id', 1)
|
|
84
87
|
.setField('fieldNonNull', 'hello')
|
|
85
88
|
.setField('fieldForeignKey', 2)
|
|
86
|
-
.
|
|
89
|
+
.createAsync(),
|
|
87
90
|
).rejects.toThrow(EntityDatabaseAdapterForeignKeyConstraintError);
|
|
88
91
|
});
|
|
89
92
|
|
|
@@ -91,32 +94,36 @@ describe('postgres errors', () => {
|
|
|
91
94
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
92
95
|
|
|
93
96
|
await ErrorsTestEntity.creator(vc)
|
|
97
|
+
.enforcing()
|
|
94
98
|
.setField('id', 1)
|
|
95
99
|
.setField('fieldNonNull', 'hello')
|
|
96
|
-
.
|
|
100
|
+
.createAsync();
|
|
97
101
|
|
|
98
102
|
await expect(
|
|
99
103
|
ErrorsTestEntity.creator(vc)
|
|
104
|
+
.enforcing()
|
|
100
105
|
.setField('id', 1)
|
|
101
106
|
.setField('fieldNonNull', 'hello')
|
|
102
|
-
.
|
|
107
|
+
.createAsync(),
|
|
103
108
|
).rejects.toThrow(EntityDatabaseAdapterUniqueConstraintError);
|
|
104
109
|
});
|
|
105
110
|
|
|
106
111
|
it('throws EntityDatabaseAdapterUniqueConstraintError when unique constraint is violated', async () => {
|
|
107
112
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
108
113
|
await ErrorsTestEntity.creator(vc)
|
|
114
|
+
.enforcing()
|
|
109
115
|
.setField('id', 2)
|
|
110
116
|
.setField('fieldNonNull', 'hello')
|
|
111
117
|
.setField('fieldUnique', 'hello')
|
|
112
|
-
.
|
|
118
|
+
.createAsync();
|
|
113
119
|
|
|
114
120
|
await expect(
|
|
115
121
|
ErrorsTestEntity.creator(vc)
|
|
122
|
+
.enforcing()
|
|
116
123
|
.setField('id', 1)
|
|
117
124
|
.setField('fieldNonNull', 'hello')
|
|
118
125
|
.setField('fieldUnique', 'hello')
|
|
119
|
-
.
|
|
126
|
+
.createAsync(),
|
|
120
127
|
).rejects.toThrow(EntityDatabaseAdapterUniqueConstraintError);
|
|
121
128
|
});
|
|
122
129
|
|
|
@@ -124,18 +131,20 @@ describe('postgres errors', () => {
|
|
|
124
131
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
125
132
|
await expect(
|
|
126
133
|
ErrorsTestEntity.creator(vc)
|
|
134
|
+
.enforcing()
|
|
127
135
|
.setField('id', 1)
|
|
128
136
|
.setField('fieldNonNull', 'hello')
|
|
129
137
|
.setField('checkLessThan5', 2)
|
|
130
|
-
.
|
|
138
|
+
.createAsync(),
|
|
131
139
|
).resolves.toBeTruthy();
|
|
132
140
|
|
|
133
141
|
await expect(
|
|
134
142
|
ErrorsTestEntity.creator(vc)
|
|
143
|
+
.enforcing()
|
|
135
144
|
.setField('id', 2)
|
|
136
145
|
.setField('fieldNonNull', 'hello')
|
|
137
146
|
.setField('checkLessThan5', 10)
|
|
138
|
-
.
|
|
147
|
+
.createAsync(),
|
|
139
148
|
).rejects.toThrow(EntityDatabaseAdapterCheckConstraintError);
|
|
140
149
|
});
|
|
141
150
|
|
|
@@ -143,18 +152,20 @@ describe('postgres errors', () => {
|
|
|
143
152
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
144
153
|
await expect(
|
|
145
154
|
ErrorsTestEntity.creator(vc)
|
|
155
|
+
.enforcing()
|
|
146
156
|
.setField('id', 1)
|
|
147
157
|
.setField('fieldNonNull', 'hello')
|
|
148
158
|
.setField('fieldExclusion', 'what')
|
|
149
|
-
.
|
|
159
|
+
.createAsync(),
|
|
150
160
|
).resolves.toBeTruthy();
|
|
151
161
|
|
|
152
162
|
await expect(
|
|
153
163
|
ErrorsTestEntity.creator(vc)
|
|
164
|
+
.enforcing()
|
|
154
165
|
.setField('id', 2)
|
|
155
166
|
.setField('fieldNonNull', 'hello')
|
|
156
167
|
.setField('fieldExclusion', 'what')
|
|
157
|
-
.
|
|
168
|
+
.createAsync(),
|
|
158
169
|
).rejects.toThrow(EntityDatabaseAdapterExclusionConstraintError);
|
|
159
170
|
});
|
|
160
171
|
|
|
@@ -162,10 +173,11 @@ describe('postgres errors', () => {
|
|
|
162
173
|
const vc = new ViewerContext(createKnexIntegrationTestEntityCompanionProvider(knexInstance));
|
|
163
174
|
await expect(
|
|
164
175
|
ErrorsTestEntity.creator(vc)
|
|
176
|
+
.enforcing()
|
|
165
177
|
.setField('id', 1)
|
|
166
178
|
.setField('fieldNonNull', 'hello')
|
|
167
179
|
.setField('nonExistentColumn', 'what')
|
|
168
|
-
.
|
|
180
|
+
.createAsync(),
|
|
169
181
|
).rejects.toThrow(EntityDatabaseAdapterUnknownError);
|
|
170
182
|
});
|
|
171
183
|
});
|
|
@@ -3,7 +3,7 @@ import wrapNativePostgresCallAsync from '../wrapNativePostgresCallAsync';
|
|
|
3
3
|
describe(wrapNativePostgresCallAsync, () => {
|
|
4
4
|
it('rethrows literals', async () => {
|
|
5
5
|
const throwingFn = async (): Promise<void> => {
|
|
6
|
-
// eslint-disable-next-line no-throw-literal,@typescript-eslint/
|
|
6
|
+
// eslint-disable-next-line no-throw-literal,@typescript-eslint/only-throw-error
|
|
7
7
|
throw 'hello';
|
|
8
8
|
};
|
|
9
9
|
|
|
@@ -117,8 +117,8 @@ class ThrowConditionallyTrigger extends EntityMutationTrigger<
|
|
|
117
117
|
PostgresTriggerTestEntity
|
|
118
118
|
> {
|
|
119
119
|
constructor(
|
|
120
|
-
private fieldName: keyof PostgresTriggerTestEntityFields,
|
|
121
|
-
private badValue: string,
|
|
120
|
+
private readonly fieldName: keyof PostgresTriggerTestEntityFields,
|
|
121
|
+
private readonly badValue: string,
|
|
122
122
|
) {
|
|
123
123
|
super();
|
|
124
124
|
}
|
|
@@ -147,8 +147,8 @@ class ThrowConditionallyNonTransactionalTrigger extends EntityNonTransactionalMu
|
|
|
147
147
|
PostgresTriggerTestEntity
|
|
148
148
|
> {
|
|
149
149
|
constructor(
|
|
150
|
-
private fieldName: keyof PostgresTriggerTestEntityFields,
|
|
151
|
-
private badValue: string,
|
|
150
|
+
private readonly fieldName: keyof PostgresTriggerTestEntityFields,
|
|
151
|
+
private readonly badValue: string,
|
|
152
152
|
) {
|
|
153
153
|
super();
|
|
154
154
|
}
|
|
@@ -106,8 +106,8 @@ class ThrowConditionallyTrigger extends EntityMutationTrigger<
|
|
|
106
106
|
PostgresValidatorTestEntity
|
|
107
107
|
> {
|
|
108
108
|
constructor(
|
|
109
|
-
private fieldName: keyof PostgresValidatorTestEntityFields,
|
|
110
|
-
private badValue: string,
|
|
109
|
+
private readonly fieldName: keyof PostgresValidatorTestEntityFields,
|
|
110
|
+
private readonly badValue: string,
|
|
111
111
|
) {
|
|
112
112
|
super();
|
|
113
113
|
}
|