ruvector/studio/data/table-rows/utils.ts
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

45 lines
1.3 KiB
TypeScript

import type { Filter, ServiceError } from 'components/grid/types'
import { isNumericalColumn } from 'components/grid/utils/types'
import { Entity, isTableLike } from 'data/table-editor/table-editor-types'
/**
* temporary fix until we implement a better filter UI
* which validate input value base on the column type
*/
export function formatFilterValue(
table: {
columns: {
name: string
format: string
}[]
},
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: Entity }): {
primaryKeys?: string[]
error?: ServiceError
} {
if (!isTableLike(table)) {
return {
error: { message: 'Only table rows can be updated or deleted' },
}
}
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) }
}