mirror of
https://github.com/supabase/supabase.git
synced 2026-07-03 14:04:21 +08:00
* chore: cleanup packages - Avoid circular imports - Export API-types as types - pg-format without depending on Node internal Buffer (not browser-compatible) - Avoid importing from barrel files in ui dir * chore: avoid barrel file imports in studio (#27771) * chore: avoid barrel file imports - Removes some unused imports - Avoids barrel file import for faster builds + less memory * add eslint rule * type fixes * delete layouts barrel * delete components/grid barrel file * delete components/grid/utils barrel file * delete components/grid/components/common barrel file * delete components/grid/components/editor barrel file * delete components/grid/components/formatter barrel file * delete components/grid/components/grid barrel file * delete components/grid/components/header/filter barrel file * remote components/grid/store barrel file * remove components/interfaces/Auth/Policies barrel file * delete components/interfaces/Settings/Logs barrel file * delete components/ui/CodeEditor barrel file * delete components/ui/Forms barrel file * delete components/ui/Shimmers barrel file * delete data/analytics barrel file * delete hooks barrel file * cleanup lib/common/fetch barrel file * final * barral files cleanup * global react-data-grid styles * remove console.log --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com> * fix build --------- Co-authored-by: Kevin Grüneberg <k.grueneberg1994@gmail.com>
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import type { Filter, ServiceError, SupaTable } from 'components/grid/types'
|
|
import { isNumericalColumn } from 'components/grid/utils/types'
|
|
import type { Table } from 'data/tables/table-query'
|
|
|
|
/**
|
|
* temporary fix until we implement a better filter UI
|
|
* which validate input value base on the column type
|
|
*/
|
|
export function formatFilterValue(table: SupaTable, filter: Filter) {
|
|
const column = table.columns.find((x) => x.name == filter.column)
|
|
if (column && isNumericalColumn(column.format)) {
|
|
const numberValue = Number(filter.value)
|
|
// Supports BigInt filter values
|
|
if (Number.isNaN(numberValue) || numberValue > Number.MAX_SAFE_INTEGER) return filter.value
|
|
else return Number(filter.value)
|
|
}
|
|
return filter.value
|
|
}
|
|
|
|
export function getPrimaryKeys({ table }: { table: Table }): {
|
|
primaryKeys?: string[]
|
|
error?: ServiceError
|
|
} {
|
|
const pkColumns = table.primary_keys
|
|
if (!pkColumns || pkColumns.length == 0) {
|
|
return {
|
|
error: { message: 'Please add a primary key column to your table to update or delete rows' },
|
|
}
|
|
}
|
|
return { primaryKeys: pkColumns.map((x) => x.name) }
|
|
}
|