mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
feat(core): Allow inserting rows into data stores with no columns (no-changelog) (#18638)
This commit is contained in:
@@ -1174,24 +1174,6 @@ describe('dataStore', () => {
|
|||||||
await expect(result).rejects.toThrow(DataStoreNotFoundError);
|
await expect(result).rejects.toThrow(DataStoreNotFoundError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects on empty column list', async () => {
|
|
||||||
// ARRANGE
|
|
||||||
const { id: dataStoreId } = await dataStoreService.createDataStore(project1.id, {
|
|
||||||
name: 'dataStore',
|
|
||||||
columns: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
// ACT
|
|
||||||
const result = dataStoreService.insertRows(dataStoreId, project1.id, [{}, {}]);
|
|
||||||
|
|
||||||
// ASSERT
|
|
||||||
await expect(result).rejects.toThrow(
|
|
||||||
new DataStoreValidationError(
|
|
||||||
'No columns found for this data store or data store not found',
|
|
||||||
),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('fails on type mismatch', async () => {
|
it('fails on type mismatch', async () => {
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
const { id: dataStoreId } = await dataStoreService.createDataStore(project1.id, {
|
const { id: dataStoreId } = await dataStoreService.createDataStore(project1.id, {
|
||||||
@@ -1210,6 +1192,29 @@ describe('dataStore', () => {
|
|||||||
new DataStoreValidationError("value 'true' does not match column type 'number'"),
|
new DataStoreValidationError("value 'true' does not match column type 'number'"),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('inserts rows into an existing table with no columns', async () => {
|
||||||
|
// ARRANGE
|
||||||
|
const { id: dataStoreId } = await dataStoreService.createDataStore(project1.id, {
|
||||||
|
name: 'dataStore',
|
||||||
|
columns: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
// ACT
|
||||||
|
const rows = [{}, {}, {}];
|
||||||
|
const result = await dataStoreService.insertRows(dataStoreId, project1.id, rows);
|
||||||
|
|
||||||
|
// ASSERT
|
||||||
|
expect(result).toEqual([1, 2, 3]);
|
||||||
|
|
||||||
|
const { count, data } = await dataStoreService.getManyRowsAndCount(
|
||||||
|
dataStoreId,
|
||||||
|
project1.id,
|
||||||
|
{},
|
||||||
|
);
|
||||||
|
expect(count).toEqual(3);
|
||||||
|
expect(data).toEqual([{ id: 1 }, { id: 2 }, { id: 3 }]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('upsertRows', () => {
|
describe('upsertRows', () => {
|
||||||
|
|||||||
@@ -210,12 +210,6 @@ export class DataStoreService {
|
|||||||
includeSystemColumns = false,
|
includeSystemColumns = false,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const columns = await this.dataStoreColumnRepository.getColumns(dataStoreId);
|
const columns = await this.dataStoreColumnRepository.getColumns(dataStoreId);
|
||||||
if (columns.length === 0) {
|
|
||||||
throw new DataStoreValidationError(
|
|
||||||
'No columns found for this data store or data store not found',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.validateRowsWithColumns(rows, columns, allowPartial, includeSystemColumns);
|
this.validateRowsWithColumns(rows, columns, allowPartial, includeSystemColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user