diff --git a/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte b/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte index 00453468f0..3c7812109f 100644 --- a/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte +++ b/frontend/src/lib/components/apps/components/display/dbtable/InsertRow.svelte @@ -135,8 +135,10 @@ let fields = $derived( columnDefs ?.filter((t) => { - const shouldFilter = t.isidentity === ColumnIdentity.Always || t?.hideInsert === true - + const shouldFilter = + t.isidentity === ColumnIdentity.Always || + t?.hideInsert === true || + t.defaultvalue?.startsWith('nextval(') // exclude postgres serial/auto increment fields return !shouldFilter }) .map((column) => { diff --git a/frontend/src/lib/components/apps/components/display/dbtable/queries/insert.ts b/frontend/src/lib/components/apps/components/display/dbtable/queries/insert.ts index ca83586fee..0933ce4b0d 100644 --- a/frontend/src/lib/components/apps/components/display/dbtable/queries/insert.ts +++ b/frontend/src/lib/components/apps/components/display/dbtable/queries/insert.ts @@ -82,7 +82,9 @@ function shouldOmitColumnInInsert(column: ColumnDef) { export function makeInsertQuery(table: string, columns: ColumnDef[], dbType: DbType) { if (!table) throw new Error('Table name is required') - const columnsInsert = columns.filter((x) => !x.hideInsert) + const columnsInsert = columns.filter( + (x) => !x.hideInsert && !(dbType == 'postgresql' && x.defaultvalue?.startsWith('nextval(')) + ) const columnsDefault = columns.filter((c) => !shouldOmitColumnInInsert(c)) const allInsertColumns = columnsInsert.concat(columnsDefault) @@ -97,6 +99,7 @@ export function makeInsertQuery(table: string, columns: ColumnDef[], dbType: DbT const commaOrEmpty = shouldInsertComma ? ', ' : '' query += `INSERT INTO ${table} (${columnNames}) VALUES (${insertValues}${commaOrEmpty}${defaultValues})` + console.log(query) return query } diff --git a/frontend/src/lib/components/apps/components/display/table/utils.ts b/frontend/src/lib/components/apps/components/display/table/utils.ts index 2cfb668b83..015cdc54db 100644 --- a/frontend/src/lib/components/apps/components/display/table/utils.ts +++ b/frontend/src/lib/components/apps/components/display/table/utils.ts @@ -27,9 +27,9 @@ export abstract class AbstractCellRenderer implements ICellRendererComp { eGui: any protected component: | { - refresh: (params: ICellRendererParams) => void - destroy: () => void - } + refresh: (params: ICellRendererParams) => void + destroy: () => void + } | undefined constructor(parentElement = 'span') { // create empty span (or other element) to place svelte component in @@ -218,18 +218,27 @@ export function transformColumnDefs({ // Set default minWidth based on number of actions (if not wrapping) ...(!wrapActions ? { minWidth: 130 * actions?.length } : {}), // Respect user-specified overrides when placeholder present (these should override defaults) - ...( - actionsIndex > -1 - ? { + ...(actionsIndex > -1 + ? { // keep width/pin/flex/align/hide from placeholder when provided - ...(['width', 'minWidth', 'maxWidth', 'flex', 'pinned', 'headerName', 'cellStyle', 'cellClass', 'autoHeight', 'hide'] - .reduce((acc, key) => { - if (r[actionsIndex] && r[actionsIndex][key] !== undefined) acc[key] = r[actionsIndex][key] - return acc - }, {} as any)) + ...[ + 'width', + 'minWidth', + 'maxWidth', + 'flex', + 'pinned', + 'headerName', + 'cellStyle', + 'cellClass', + 'autoHeight', + 'hide' + ].reduce((acc, key) => { + if (r[actionsIndex] && r[actionsIndex][key] !== undefined) + acc[key] = r[actionsIndex][key] + return acc + }, {} as any) } - : {} - ), + : {}), ...(customActionsHeader?.trim() ? { headerName: customActionsHeader } : {}) }