mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-07 08:02:40 +00:00
exclude postgres BIGSERIAL / auto generated columns (#6734)
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 } : {})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user