@e22m4u/js-repository 0.1.0 → 0.1.1
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/docs/classes/Adapter.html +14 -14
- package/docs/classes/AdapterLoader.html +2 -2
- package/docs/classes/AdapterRegistry.html +2 -2
- package/docs/classes/BelongsToResolver.html +3 -3
- package/docs/classes/DatasourceDefinitionValidator.html +2 -2
- package/docs/classes/DefinitionRegistry.html +7 -7
- package/docs/classes/FieldsClauseTool.html +4 -4
- package/docs/classes/HasManyResolver.html +4 -4
- package/docs/classes/HasOneResolver.html +4 -4
- package/docs/classes/IncludeClauseTool.html +6 -6
- package/docs/classes/InvalidArgumentError.html +1 -1
- package/docs/classes/InvalidOperatorValueError.html +2 -2
- package/docs/classes/ModelDataSanitizer.html +2 -2
- package/docs/classes/ModelDataValidator.html +3 -3
- package/docs/classes/ModelDefinitionUtils.html +17 -17
- package/docs/classes/ModelDefinitionValidator.html +2 -2
- package/docs/classes/NotImplementedError.html +1 -1
- package/docs/classes/OperatorClauseTool.html +14 -14
- package/docs/classes/OrderClauseTool.html +4 -4
- package/docs/classes/PrimaryKeysDefinitionValidator.html +2 -2
- package/docs/classes/PropertiesDefinitionValidator.html +2 -2
- package/docs/classes/ReferencesManyResolver.html +2 -2
- package/docs/classes/RelationsDefinitionValidator.html +2 -2
- package/docs/classes/Repository.html +17 -17
- package/docs/classes/RepositoryRegistry.html +3 -3
- package/docs/classes/Schema.html +4 -4
- package/docs/classes/SliceClauseTool.html +4 -4
- package/docs/classes/WhereClauseTool.html +3 -3
- package/docs/enums/DataType.html +2 -2
- package/docs/enums/RelationType.html +2 -2
- package/docs/functions/capitalize.html +1 -1
- package/docs/functions/cloneDeep.html +1 -1
- package/docs/functions/excludeObjectKeys.html +1 -1
- package/docs/functions/getCtorName.html +1 -1
- package/docs/functions/getValueByPath.html +1 -1
- package/docs/functions/isCtor.html +1 -1
- package/docs/functions/isPureObject.html +1 -1
- package/docs/functions/selectObjectKeys.html +1 -1
- package/docs/functions/singularize.html +1 -1
- package/docs/functions/stringToRegexp.html +1 -1
- package/docs/interfaces/AndClause.html +2 -2
- package/docs/interfaces/OrClause.html +2 -2
- package/docs/types/AnyObject.html +1 -1
- package/docs/types/BelongsToDefinition.html +1 -1
- package/docs/types/DEFAULT_PRIMARY_KEY_PROPERTY_NAME.html +1 -1
- package/docs/types/DatasourceDefinition.html +1 -1
- package/docs/types/FieldsClause.html +1 -1
- package/docs/types/FilterClause.html +1 -1
- package/docs/types/Flatten.html +1 -1
- package/docs/types/FullPropertyDefinition.html +1 -1
- package/docs/types/HasManyDefinition.html +1 -1
- package/docs/types/HasOneDefinition.html +1 -1
- package/docs/types/Identity.html +1 -1
- package/docs/types/IncludeClause.html +1 -1
- package/docs/types/ItemFilterClause.html +1 -1
- package/docs/types/ModelData.html +1 -1
- package/docs/types/ModelDefinition.html +1 -1
- package/docs/types/ModelId.html +1 -1
- package/docs/types/NestedIncludeClause.html +1 -1
- package/docs/types/NormalizedFieldsClause.html +1 -1
- package/docs/types/NormalizedIncludeClause.html +1 -1
- package/docs/types/OperatorClause.html +1 -1
- package/docs/types/OptionalUnlessRequiredId.html +1 -1
- package/docs/types/OrderClause.html +1 -1
- package/docs/types/PartialBy.html +1 -1
- package/docs/types/PartialWithoutId.html +1 -1
- package/docs/types/PolyBelongsToDefinition.html +1 -1
- package/docs/types/PolyHasManyDefinitionWithTargetKeys.html +1 -1
- package/docs/types/PolyHasManyDefinitionWithTargetRelationName.html +1 -1
- package/docs/types/PolyHasOneDefinitionWithTargetKeys.html +1 -1
- package/docs/types/PolyHasOneDefinitionWithTargetRelationName.html +1 -1
- package/docs/types/PropertiesClause.html +1 -1
- package/docs/types/PropertyDefinition.html +1 -1
- package/docs/types/PropertyDefinitionMap.html +1 -1
- package/docs/types/ReferencesManyDefinition.html +1 -1
- package/docs/types/RelationDefinition.html +1 -1
- package/docs/types/RelationDefinitionMap.html +1 -1
- package/docs/types/WhereClause.html +1 -1
- package/docs/types/WithoutId.html +1 -1
- package/package.json +1 -1
- package/src/adapter/builtin/memory-adapter.js +6 -2
- package/src/adapter/builtin/memory-adapter.spec.js +116 -0
|
@@ -187,6 +187,64 @@ describe('MemoryAdapter', function () {
|
|
|
187
187
|
expect(tableData).to.be.eql({...input, [DEF_PK]: idValue});
|
|
188
188
|
});
|
|
189
189
|
|
|
190
|
+
it('generates a new identifier when a value of a primary key is an empty string', async function () {
|
|
191
|
+
const schema = new Schema();
|
|
192
|
+
schema.defineDatasource({
|
|
193
|
+
name: 'memory',
|
|
194
|
+
adapter: 'memory',
|
|
195
|
+
});
|
|
196
|
+
schema.defineModel({
|
|
197
|
+
name: 'model',
|
|
198
|
+
datasource: 'memory',
|
|
199
|
+
properties: {
|
|
200
|
+
foo: DataType.STRING,
|
|
201
|
+
bar: DataType.NUMBER,
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
const adapter = new MemoryAdapter(schema.container, {});
|
|
205
|
+
const input = {
|
|
206
|
+
[DEF_PK]: '',
|
|
207
|
+
foo: 'string',
|
|
208
|
+
bar: 10,
|
|
209
|
+
};
|
|
210
|
+
const created = await adapter.create('model', input);
|
|
211
|
+
const idValue = created[DEF_PK];
|
|
212
|
+
expect(idValue).to.be.not.eq('');
|
|
213
|
+
expect(created).to.be.eql({...input, [DEF_PK]: idValue});
|
|
214
|
+
const table = adapter._getTableOrCreate('model');
|
|
215
|
+
const tableData = table.get(idValue);
|
|
216
|
+
expect(tableData).to.be.eql({...input, [DEF_PK]: idValue});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('generates a new identifier when a value of a primary key is zero', async function () {
|
|
220
|
+
const schema = new Schema();
|
|
221
|
+
schema.defineDatasource({
|
|
222
|
+
name: 'memory',
|
|
223
|
+
adapter: 'memory',
|
|
224
|
+
});
|
|
225
|
+
schema.defineModel({
|
|
226
|
+
name: 'model',
|
|
227
|
+
datasource: 'memory',
|
|
228
|
+
properties: {
|
|
229
|
+
foo: DataType.STRING,
|
|
230
|
+
bar: DataType.NUMBER,
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
const adapter = new MemoryAdapter(schema.container, {});
|
|
234
|
+
const input = {
|
|
235
|
+
[DEF_PK]: 0,
|
|
236
|
+
foo: 'string',
|
|
237
|
+
bar: 10,
|
|
238
|
+
};
|
|
239
|
+
const created = await adapter.create('model', input);
|
|
240
|
+
const idValue = created[DEF_PK];
|
|
241
|
+
expect(idValue).to.be.not.eq(0);
|
|
242
|
+
expect(created).to.be.eql({...input, [DEF_PK]: idValue});
|
|
243
|
+
const table = adapter._getTableOrCreate('model');
|
|
244
|
+
const tableData = table.get(idValue);
|
|
245
|
+
expect(tableData).to.be.eql({...input, [DEF_PK]: idValue});
|
|
246
|
+
});
|
|
247
|
+
|
|
190
248
|
it('generates a new identifier for a primary key of a "number" type', async function () {
|
|
191
249
|
const schema = new Schema();
|
|
192
250
|
schema.defineDatasource({
|
|
@@ -1214,6 +1272,64 @@ describe('MemoryAdapter', function () {
|
|
|
1214
1272
|
expect(tableData).to.be.eql({...input, [DEF_PK]: idValue});
|
|
1215
1273
|
});
|
|
1216
1274
|
|
|
1275
|
+
it('generates a new identifier when a value of a primary key is an empty string', async function () {
|
|
1276
|
+
const schema = new Schema();
|
|
1277
|
+
schema.defineDatasource({
|
|
1278
|
+
name: 'memory',
|
|
1279
|
+
adapter: 'memory',
|
|
1280
|
+
});
|
|
1281
|
+
schema.defineModel({
|
|
1282
|
+
name: 'model',
|
|
1283
|
+
datasource: 'memory',
|
|
1284
|
+
properties: {
|
|
1285
|
+
foo: DataType.STRING,
|
|
1286
|
+
bar: DataType.NUMBER,
|
|
1287
|
+
},
|
|
1288
|
+
});
|
|
1289
|
+
const adapter = new MemoryAdapter(schema.container, {});
|
|
1290
|
+
const input = {
|
|
1291
|
+
[DEF_PK]: '',
|
|
1292
|
+
foo: 'string',
|
|
1293
|
+
bar: 10,
|
|
1294
|
+
};
|
|
1295
|
+
const created = await adapter.replaceOrCreate('model', input);
|
|
1296
|
+
const idValue = created[DEF_PK];
|
|
1297
|
+
expect(idValue).to.be.not.eq('');
|
|
1298
|
+
expect(created).to.be.eql({...input, [DEF_PK]: idValue});
|
|
1299
|
+
const table = adapter._getTableOrCreate('model');
|
|
1300
|
+
const tableData = table.get(idValue);
|
|
1301
|
+
expect(tableData).to.be.eql({...input, [DEF_PK]: idValue});
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
it('generates a new identifier when a value of a primary key is zero', async function () {
|
|
1305
|
+
const schema = new Schema();
|
|
1306
|
+
schema.defineDatasource({
|
|
1307
|
+
name: 'memory',
|
|
1308
|
+
adapter: 'memory',
|
|
1309
|
+
});
|
|
1310
|
+
schema.defineModel({
|
|
1311
|
+
name: 'model',
|
|
1312
|
+
datasource: 'memory',
|
|
1313
|
+
properties: {
|
|
1314
|
+
foo: DataType.STRING,
|
|
1315
|
+
bar: DataType.NUMBER,
|
|
1316
|
+
},
|
|
1317
|
+
});
|
|
1318
|
+
const adapter = new MemoryAdapter(schema.container, {});
|
|
1319
|
+
const input = {
|
|
1320
|
+
[DEF_PK]: 0,
|
|
1321
|
+
foo: 'string',
|
|
1322
|
+
bar: 10,
|
|
1323
|
+
};
|
|
1324
|
+
const created = await adapter.replaceOrCreate('model', input);
|
|
1325
|
+
const idValue = created[DEF_PK];
|
|
1326
|
+
expect(idValue).to.be.not.eq(0);
|
|
1327
|
+
expect(created).to.be.eql({...input, [DEF_PK]: idValue});
|
|
1328
|
+
const table = adapter._getTableOrCreate('model');
|
|
1329
|
+
const tableData = table.get(idValue);
|
|
1330
|
+
expect(tableData).to.be.eql({...input, [DEF_PK]: idValue});
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1217
1333
|
it('generates a new identifier for a primary key of a "number" type', async function () {
|
|
1218
1334
|
const schema = new Schema();
|
|
1219
1335
|
schema.defineDatasource({
|