feat(core): Allow inserting rows into data stores with no columns (no-changelog) (#18638)

This commit is contained in:
Jaakko Husso
2025-08-21 17:48:14 +02:00
committed by GitHub
parent c99eba7fa2
commit fa15b7bfab
2 changed files with 23 additions and 24 deletions

View File

@@ -1174,24 +1174,6 @@ describe('dataStore', () => {
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 () => {
// ARRANGE
const { id: dataStoreId } = await dataStoreService.createDataStore(project1.id, {
@@ -1210,6 +1192,29 @@ describe('dataStore', () => {
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', () => {

View File

@@ -210,12 +210,6 @@ export class DataStoreService {
includeSystemColumns = false,
): Promise<void> {
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);
}