Skip to content

Commit cb42d4f

Browse files
fix(tables): emit orderKey in insert responses
The single-row and batch insert handlers dropped orderKey from the JSON response even though the service returns it, so reconcileCreatedRow always fell back to position-sorting and could place neighbor inserts wrong under the fractional-ordering flag. Serialize orderKey alongside position.
1 parent 9f67206 commit cb42d4f

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • apps/sim/app/api/table/[tableId]/rows

apps/sim/app/api/table/[tableId]/rows/route.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ async function handleBatchInsert(
8484
id: r.id,
8585
data: r.data,
8686
position: r.position,
87+
orderKey: r.orderKey ?? undefined,
8788
createdAt: r.createdAt instanceof Date ? r.createdAt.toISOString() : r.createdAt,
8889
updatedAt: r.updatedAt instanceof Date ? r.updatedAt.toISOString() : r.updatedAt,
8990
})),
@@ -177,9 +178,11 @@ export const POST = withRouteHandler(
177178
id: row.id,
178179
data: row.data,
179180
position: row.position,
181+
orderKey: row.orderKey ?? undefined,
180182
createdAt: row.createdAt instanceof Date ? row.createdAt.toISOString() : row.createdAt,
181183
updatedAt: row.updatedAt instanceof Date ? row.updatedAt.toISOString() : row.updatedAt,
182184
},
185+
183186
message: 'Row inserted successfully',
184187
},
185188
})

0 commit comments

Comments
 (0)