From 768e5b2dc6ab6a145cd13722ae5f8dfe9d400943 Mon Sep 17 00:00:00 2001 From: Hemang Kandwal Date: Tue, 28 Jan 2025 19:33:59 +0530 Subject: [PATCH 1/2] feat(core): add filters totalCount for all databases --- core/graph/generated.go | 63 +++++++++++++++++++ core/graph/model/models_gen.go | 1 + core/graph/schema.graphqls | 1 + core/graph/schema.resolvers.go | 1 + core/src/engine/plugin.go | 1 + core/src/plugins/clickhouse/chat.go | 61 ++++++++++++++++++ core/src/plugins/clickhouse/clickhouse.go | 35 +++++++++-- core/src/plugins/clickhouse/query.go | 14 +++-- .../plugins/elasticsearch/elasticsearch.go | 12 ++-- core/src/plugins/mongodb/mongodb.go | 6 ++ core/src/plugins/mysql/mysql.go | 28 +++++++-- core/src/plugins/postgres/postgres.go | 24 ++++++- frontend/src/components/editor.tsx | 8 +-- frontend/src/generated/graphql.tsx | 4 +- .../storage-unit/explore-storage-unit.tsx | 8 +-- .../get-storage-unit-rows.graphql | 1 + .../src/pages/storage-unit/storage-unit.tsx | 3 +- 17 files changed, 239 insertions(+), 32 deletions(-) create mode 100644 core/src/plugins/clickhouse/chat.go diff --git a/core/graph/generated.go b/core/graph/generated.go index 2b4f61f1..b3bec08a 100644 --- a/core/graph/generated.go +++ b/core/graph/generated.go @@ -109,6 +109,7 @@ type ComplexityRoot struct { Columns func(childComplexity int) int DisableUpdate func(childComplexity int) int Rows func(childComplexity int) int + TotalCount func(childComplexity int) int } SettingsConfig struct { @@ -497,6 +498,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.RowsResult.Rows(childComplexity), true + case "RowsResult.TotalCount": + if e.complexity.RowsResult.TotalCount == nil { + break + } + + return e.complexity.RowsResult.TotalCount(childComplexity), true + case "SettingsConfig.MetricsEnabled": if e.complexity.SettingsConfig.MetricsEnabled == nil { break @@ -1722,6 +1730,8 @@ func (ec *executionContext) fieldContext_AIChatMessage_Result(_ context.Context, return ec.fieldContext_RowsResult_Columns(ctx, field) case "Rows": return ec.fieldContext_RowsResult_Rows(ctx, field) + case "TotalCount": + return ec.fieldContext_RowsResult_TotalCount(ctx, field) case "DisableUpdate": return ec.fieldContext_RowsResult_DisableUpdate(ctx, field) } @@ -2983,6 +2993,8 @@ func (ec *executionContext) fieldContext_Query_Row(ctx context.Context, field gr return ec.fieldContext_RowsResult_Columns(ctx, field) case "Rows": return ec.fieldContext_RowsResult_Rows(ctx, field) + case "TotalCount": + return ec.fieldContext_RowsResult_TotalCount(ctx, field) case "DisableUpdate": return ec.fieldContext_RowsResult_DisableUpdate(ctx, field) } @@ -3046,6 +3058,8 @@ func (ec *executionContext) fieldContext_Query_RawExecute(ctx context.Context, f return ec.fieldContext_RowsResult_Columns(ctx, field) case "Rows": return ec.fieldContext_RowsResult_Rows(ctx, field) + case "TotalCount": + return ec.fieldContext_RowsResult_TotalCount(ctx, field) case "DisableUpdate": return ec.fieldContext_RowsResult_DisableUpdate(ctx, field) } @@ -3604,6 +3618,50 @@ func (ec *executionContext) fieldContext_RowsResult_Rows(_ context.Context, fiel return fc, nil } +func (ec *executionContext) _RowsResult_TotalCount(ctx context.Context, field graphql.CollectedField, obj *model.RowsResult) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_RowsResult_TotalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_RowsResult_TotalCount(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "RowsResult", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _RowsResult_DisableUpdate(ctx context.Context, field graphql.CollectedField, obj *model.RowsResult) (ret graphql.Marshaler) { fc, err := ec.fieldContext_RowsResult_DisableUpdate(ctx, field) if err != nil { @@ -6515,6 +6573,11 @@ func (ec *executionContext) _RowsResult(ctx context.Context, sel ast.SelectionSe if out.Values[i] == graphql.Null { out.Invalids++ } + case "TotalCount": + out.Values[i] = ec._RowsResult_TotalCount(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "DisableUpdate": out.Values[i] = ec._RowsResult_DisableUpdate(ctx, field, obj) if out.Values[i] == graphql.Null { diff --git a/core/graph/model/models_gen.go b/core/graph/model/models_gen.go index 902bc2c2..0b7f91e9 100644 --- a/core/graph/model/models_gen.go +++ b/core/graph/model/models_gen.go @@ -79,6 +79,7 @@ type RecordInput struct { type RowsResult struct { Columns []*Column `json:"Columns"` Rows [][]string `json:"Rows"` + TotalCount int `json:"TotalCount"` DisableUpdate bool `json:"DisableUpdate"` } diff --git a/core/graph/schema.graphqls b/core/graph/schema.graphqls index 9d8aab07..f9a6c8fa 100644 --- a/core/graph/schema.graphqls +++ b/core/graph/schema.graphqls @@ -17,6 +17,7 @@ type Column { type RowsResult { Columns: [Column!]! Rows: [[String!]!]! + TotalCount: Int! DisableUpdate: Boolean! } diff --git a/core/graph/schema.resolvers.go b/core/graph/schema.resolvers.go index fc7a9890..aa5ecad1 100644 --- a/core/graph/schema.resolvers.go +++ b/core/graph/schema.resolvers.go @@ -232,6 +232,7 @@ func (r *queryResolver) Row(ctx context.Context, schema string, storageUnit stri Columns: columns, Rows: rowsResult.Rows, DisableUpdate: rowsResult.DisableUpdate, + TotalCount: rowsResult.TotalCount, }, nil } diff --git a/core/src/engine/plugin.go b/core/src/engine/plugin.go index 45379d10..e9e0543e 100644 --- a/core/src/engine/plugin.go +++ b/core/src/engine/plugin.go @@ -41,6 +41,7 @@ type Column struct { type GetRowsResult struct { Columns []Column Rows [][]string + TotalCount int DisableUpdate bool } diff --git a/core/src/plugins/clickhouse/chat.go b/core/src/plugins/clickhouse/chat.go new file mode 100644 index 00000000..517e1e2b --- /dev/null +++ b/core/src/plugins/clickhouse/chat.go @@ -0,0 +1,61 @@ +package clickhouse + +import ( + "fmt" + "strings" + + "github.com/clidey/whodb/core/src/common" + "github.com/clidey/whodb/core/src/engine" + "github.com/clidey/whodb/core/src/llm" +) + +func (p *ClickHousePlugin) Chat(config *engine.PluginConfig, schema string, model string, previousConversation string, query string) ([]*engine.ChatMessage, error) { + db, err := DB(config) + if err != nil { + return nil, err + } + + tableFields, err := getAllTableSchema(db, schema) + if err != nil { + return nil, err + } + + tableDetails := strings.Builder{} + for tableName, fields := range tableFields { + tableDetails.WriteString(fmt.Sprintf("table: %v\n", tableName)) + for _, field := range fields { + tableDetails.WriteString(fmt.Sprintf("- %v (%v)\n", field.Key, field.Value)) + } + } + + context := tableDetails.String() + + completeQuery := fmt.Sprintf(common.RawSQLQueryPrompt, "Postgres", schema, context, previousConversation, query, "Postgres") + + response, err := llm.Instance(config).Complete(completeQuery, llm.LLMModel(model), nil) + if err != nil { + return nil, err + } + + chats := common.ExtractCodeFromResponse(*response) + chatMessages := []*engine.ChatMessage{} + for _, chat := range chats { + var result *engine.GetRowsResult + chatType := "message" + if chat.Type == "sql" { + rowResult, err := p.RawExecute(config, chat.Text) + if err != nil { + return nil, err + } + chatType = "sql" + result = rowResult + } + chatMessages = append(chatMessages, &engine.ChatMessage{ + Type: chatType, + Result: result, + Text: chat.Text, + }) + } + + return chatMessages, nil +} diff --git a/core/src/plugins/clickhouse/clickhouse.go b/core/src/plugins/clickhouse/clickhouse.go index fc5658d2..94245e5d 100644 --- a/core/src/plugins/clickhouse/clickhouse.go +++ b/core/src/plugins/clickhouse/clickhouse.go @@ -102,6 +102,35 @@ func (p *ClickHousePlugin) GetStorageUnits(config *engine.PluginConfig, schema s return storageUnits, nil } +func getAllTableSchema(conn *sql.DB, schema string) (map[string][]engine.Record, error) { + query := fmt.Sprintf(` + SELECT + table, + name, + type + FROM system.columns + WHERE database = '%s' + ORDER BY table, position + `, schema) + + rows, err := conn.QueryContext(context.Background(), query) + if err != nil { + return nil, err + } + defer rows.Close() + + tableColumnsMap := make(map[string][]engine.Record) + for rows.Next() { + var tableName, columnName, dataType string + if err := rows.Scan(&tableName, &columnName, &dataType); err != nil { + return nil, err + } + tableColumnsMap[tableName] = append(tableColumnsMap[tableName], engine.Record{Key: columnName, Value: dataType}) + } + + return tableColumnsMap, nil +} + func getTableSchema(conn *sql.DB, schema string, tableName string) ([]engine.Record, error) { query := fmt.Sprintf(` SELECT @@ -130,12 +159,6 @@ func getTableSchema(conn *sql.DB, schema string, tableName string) ([]engine.Rec return result, nil } -func (p *ClickHousePlugin) Chat(config *engine.PluginConfig, schema string, model string, previousConversation string, query string) ([]*engine.ChatMessage, error) { - // Implement chat functionality similar to MySQL implementation - // You may need to adapt this based on ClickHouse specifics - return nil, fmt.Errorf("chat functionality not implemented for ClickHouse") -} - func NewClickHousePlugin() *engine.Plugin { return &engine.Plugin{ Type: engine.DatabaseType_ClickHouse, diff --git a/core/src/plugins/clickhouse/query.go b/core/src/plugins/clickhouse/query.go index 0e1fb0c6..690c3cc9 100644 --- a/core/src/plugins/clickhouse/query.go +++ b/core/src/plugins/clickhouse/query.go @@ -4,17 +4,23 @@ import ( "context" "database/sql" "fmt" + "github.com/clidey/whodb/core/src/engine" ) func (p *ClickHousePlugin) GetRows(config *engine.PluginConfig, schema string, storageUnit string, where string, pageSize int, pageOffset int) (*engine.GetRowsResult, error) { - query := fmt.Sprintf("SELECT * FROM %s.%s", schema, storageUnit) + baseQuery := fmt.Sprintf("FROM %s.%s", schema, storageUnit) if where != "" { - query += " WHERE " + where + baseQuery += " WHERE " + where } - query += fmt.Sprintf(" LIMIT %d OFFSET %d", pageSize, pageOffset) + query := fmt.Sprintf("SELECT * %s LIMIT %d OFFSET %d", baseQuery, pageSize, pageOffset) - return p.executeQuery(config, query) + result, err := p.executeQuery(config, query) + if err != nil { + return nil, err + } + + return result, nil } func (p *ClickHousePlugin) RawExecute(config *engine.PluginConfig, query string) (*engine.GetRowsResult, error) { diff --git a/core/src/plugins/elasticsearch/elasticsearch.go b/core/src/plugins/elasticsearch/elasticsearch.go index c1ce758b..470a49ee 100644 --- a/core/src/plugins/elasticsearch/elasticsearch.go +++ b/core/src/plugins/elasticsearch/elasticsearch.go @@ -97,15 +97,15 @@ func (p *ElasticSearchPlugin) GetRows(config *engine.PluginConfig, database, col query[key] = value } - var buf bytes.Buffer - if err := json.NewEncoder(&buf).Encode(query); err != nil { + var searchBuf bytes.Buffer + if err := json.NewEncoder(&searchBuf).Encode(query); err != nil { return nil, err } res, err := client.Search( client.Search.WithContext(context.Background()), client.Search.WithIndex(collection), - client.Search.WithBody(&buf), + client.Search.WithBody(&searchBuf), client.Search.WithTrackTotalHits(true), ) if err != nil { @@ -122,7 +122,10 @@ func (p *ElasticSearchPlugin) GetRows(config *engine.PluginConfig, database, col return nil, err } - hits := searchResult["hits"].(map[string]interface{})["hits"].([]interface{}) + hitsInfo := searchResult["hits"].(map[string]interface{}) + totalHits := int(hitsInfo["total"].(map[string]interface{})["value"].(float64)) + + hits := hitsInfo["hits"].([]interface{}) result := &engine.GetRowsResult{ Columns: []engine.Column{ {Name: "document", Type: "Document"}, @@ -142,6 +145,7 @@ func (p *ElasticSearchPlugin) GetRows(config *engine.PluginConfig, database, col result.Rows = append(result.Rows, []string{string(jsonBytes)}) } + result.TotalCount = totalHits return result, nil } diff --git a/core/src/plugins/mongodb/mongodb.go b/core/src/plugins/mongodb/mongodb.go index fd34b461..79625339 100644 --- a/core/src/plugins/mongodb/mongodb.go +++ b/core/src/plugins/mongodb/mongodb.go @@ -89,6 +89,11 @@ func (p *MongoDBPlugin) GetRows(config *engine.PluginConfig, database, collectio } } + totalCount, err := coll.CountDocuments(context.TODO(), bsonFilter) + if err != nil { + return nil, err + } + findOptions := options.Find() findOptions.SetLimit(int64(pageSize)) findOptions.SetSkip(int64(pageOffset)) @@ -124,6 +129,7 @@ func (p *MongoDBPlugin) GetRows(config *engine.PluginConfig, database, collectio }) } + result.TotalCount = int(totalCount) return result, nil } diff --git a/core/src/plugins/mysql/mysql.go b/core/src/plugins/mysql/mysql.go index 70d45b69..27b0d009 100644 --- a/core/src/plugins/mysql/mysql.go +++ b/core/src/plugins/mysql/mysql.go @@ -137,12 +137,32 @@ func getTableSchema(db *gorm.DB, schema string) (map[string][]engine.Record, err } func (p *MySQLPlugin) GetRows(config *engine.PluginConfig, schema string, storageUnit string, where string, pageSize int, pageOffset int) (*engine.GetRowsResult, error) { - query := fmt.Sprintf("SELECT * FROM `%v`.`%s`", schema, storageUnit) + db, err := DB(config) + if err != nil { + return nil, err + } + + baseQuery := fmt.Sprintf("FROM `%v`.`%s`", schema, storageUnit) if len(where) > 0 { - query = fmt.Sprintf("%v WHERE %v", query, where) + baseQuery = fmt.Sprintf("%v WHERE %v", baseQuery, where) + } + + countQuery := fmt.Sprintf("SELECT COUNT(*) %v", baseQuery) + var totalCount int + err = db.Raw(countQuery).Scan(&totalCount).Error + if err != nil { + return nil, err + } + + query := fmt.Sprintf("SELECT * %v LIMIT ? OFFSET ?", baseQuery) + + result, err := p.executeRawSQL(config, query, pageSize, pageOffset) + if err != nil { + return nil, err } - query = fmt.Sprintf("%v LIMIT ? OFFSET ?", query) - return p.executeRawSQL(config, query, pageSize, pageOffset) + + result.TotalCount = totalCount + return result, nil } func (p *MySQLPlugin) executeRawSQL(config *engine.PluginConfig, query string, params ...interface{}) (*engine.GetRowsResult, error) { diff --git a/core/src/plugins/postgres/postgres.go b/core/src/plugins/postgres/postgres.go index 2e5a6207..2225a909 100644 --- a/core/src/plugins/postgres/postgres.go +++ b/core/src/plugins/postgres/postgres.go @@ -167,17 +167,35 @@ func (p *PostgresPlugin) GetRows(config *engine.PluginConfig, schema string, sto if err != nil { return nil, err } - query := fmt.Sprintf("SELECT * FROM \"%v\".\"%s\"", schema, storageUnit) + + baseQuery := fmt.Sprintf("FROM \"%v\".\"%s\"", schema, storageUnit) if len(where) > 0 { - query = fmt.Sprintf("%v WHERE %v", query, where) + baseQuery = fmt.Sprintf("%v WHERE %v", baseQuery, where) } + + countQuery := fmt.Sprintf("SELECT COUNT(*) %v", baseQuery) + var totalCount int + err = db.Raw(countQuery).Scan(&totalCount).Error + if err != nil { + return nil, err + } + + query := fmt.Sprintf("SELECT * %v", baseQuery) sortKeyRes, err := getPrimaryKeyColumns(db, schema, storageUnit) if err == nil { quotedKeys := common.JoinWithQuotes(sortKeyRes) query = fmt.Sprintf("%v ORDER BY %v ASC", query, quotedKeys) } + query = fmt.Sprintf("%v LIMIT ? OFFSET ?", query) - return p.executeRawSQL(config, query, pageSize, pageOffset) + + result, err := p.executeRawSQL(config, query, pageSize, pageOffset) + if err != nil { + return nil, err + } + + result.TotalCount = totalCount + return result, nil } func (p *PostgresPlugin) executeRawSQL(config *engine.PluginConfig, query string, params ...interface{}) (*engine.GetRowsResult, error) { diff --git a/frontend/src/components/editor.tsx b/frontend/src/components/editor.tsx index ce8d988f..7be17b83 100644 --- a/frontend/src/components/editor.tsx +++ b/frontend/src/components/editor.tsx @@ -25,7 +25,7 @@ type ICodeEditorProps = { export const CodeEditor: FC = ({ value, setValue, - language = "sql", + language, onRun, defaultShowPreview = false, disabled, @@ -52,8 +52,6 @@ export const CodeEditor: FC = ({ return markdown(); case "sql": return sql(); - default: - return sql(); } })(); @@ -70,7 +68,7 @@ export const CodeEditor: FC = ({ }, }), basicSetup, - languageExtension, + languageExtension != null ? languageExtension : [], darkModeEnabled ? [oneDark, EditorView.theme({ ".cm-activeLine": { backgroundColor: "rgba(0,0,0,0.05) !important" }, ".cm-activeLineGutter": { backgroundColor: "rgba(0,0,0,0.05) !important" }, @@ -143,7 +141,7 @@ export const CodeEditor: FC = ({ return (
{children}
.cm-editor]:h-full [&>.cm-editor]:p-2 dark:[&>.cm-editor]:bg-[#252526] dark:[&_.cm-gutter]:bg-[#252526] transition-all opacity-100", { diff --git a/frontend/src/generated/graphql.tsx b/frontend/src/generated/graphql.tsx index 4ea5fba4..c72d66dd 100644 --- a/frontend/src/generated/graphql.tsx +++ b/frontend/src/generated/graphql.tsx @@ -222,6 +222,7 @@ export type RowsResult = { Columns: Array; DisableUpdate: Scalars['Boolean']['output']; Rows: Array>; + TotalCount: Scalars['Int']['output']; }; export type SettingsConfig = { @@ -367,7 +368,7 @@ export type GetStorageUnitRowsQueryVariables = Exact<{ }>; -export type GetStorageUnitRowsQuery = { __typename?: 'Query', Row: { __typename?: 'RowsResult', Rows: Array>, DisableUpdate: boolean, Columns: Array<{ __typename?: 'Column', Type: string, Name: string }> } }; +export type GetStorageUnitRowsQuery = { __typename?: 'Query', Row: { __typename?: 'RowsResult', Rows: Array>, DisableUpdate: boolean, TotalCount: number, Columns: Array<{ __typename?: 'Column', Type: string, Name: string }> } }; export type GetStorageUnitsQueryVariables = Exact<{ schema: Scalars['String']['input']; @@ -1021,6 +1022,7 @@ export const GetStorageUnitRowsDocument = gql` } Rows DisableUpdate + TotalCount } } `; diff --git a/frontend/src/pages/storage-unit/explore-storage-unit.tsx b/frontend/src/pages/storage-unit/explore-storage-unit.tsx index c8b55220..47db54da 100644 --- a/frontend/src/pages/storage-unit/explore-storage-unit.tsx +++ b/frontend/src/pages/storage-unit/explore-storage-unit.tsx @@ -14,7 +14,7 @@ import { Table } from "../../components/table"; import { graphqlClient } from "../../config/graphql-client"; import { InternalRoutes } from "../../config/routes"; import { - Column, DatabaseType, DeleteRowDocument, DeleteRowMutationResult, RecordInput, RowsResult, StorageUnit, + Column, DatabaseType, DeleteRowDocument, DeleteRowMutationResult, GetStorageUnitRowsQuery, GetStorageUnitsQuery, GetStorageUnitsQueryResult, RecordInput, RowsResult, StorageUnit, UpdateStorageUnitDocument, UpdateStorageUnitMutationResult, useAddRowMutation, useGetStorageUnitRowsLazyQuery } from "../../generated/graphql"; import { notify } from "../../store/function"; @@ -32,7 +32,7 @@ export const ExploreStorageUnit: FC = () => { const schema = useAppSelector(state => state.database.schema); const current = useAppSelector(state => state.auth.current); const navigate = useNavigate(); - const [rows, setRows] = useState(); + const [rows, setRows] = useState(); const [showAdd, setShowAdd] = useState(false); const [newRowForm, setNewRowForm] = useState([]); const [checkedRows, setCheckedRows] = useState>(new Set()); @@ -172,8 +172,8 @@ export const ExploreStorageUnit: FC = () => { }, [checkedRows, current, rows, schema, unitName]); const totalCount = useMemo(() => { - return unit?.Attributes.find(attribute => attribute.Key === "Count")?.Value ?? "unknown"; - }, [unit]); + return rows?.TotalCount?.toString() ?? unit?.Attributes.find(attribute => attribute.Key === "Count")?.Value ?? "unknown"; + }, [rows, unit]); const totalPages = useMemo(() => { if (!isNumeric(totalCount) || !isNumeric(pageSize)) { diff --git a/frontend/src/pages/storage-unit/get-storage-unit-rows.graphql b/frontend/src/pages/storage-unit/get-storage-unit-rows.graphql index 4c495818..6d0a4834 100644 --- a/frontend/src/pages/storage-unit/get-storage-unit-rows.graphql +++ b/frontend/src/pages/storage-unit/get-storage-unit-rows.graphql @@ -6,5 +6,6 @@ query GetStorageUnitRows($schema: String!, $storageUnit: String!, $where: String } Rows DisableUpdate + TotalCount } } \ No newline at end of file diff --git a/frontend/src/pages/storage-unit/storage-unit.tsx b/frontend/src/pages/storage-unit/storage-unit.tsx index 52f2145f..da536ed3 100644 --- a/frontend/src/pages/storage-unit/storage-unit.tsx +++ b/frontend/src/pages/storage-unit/storage-unit.tsx @@ -168,7 +168,7 @@ export const StorageUnitPage: FC = () => { return []; } let items: string[] = []; - + switch(current.Type) { case DatabaseType.MariaDb: items = [ @@ -180,6 +180,7 @@ export const StorageUnitPage: FC = () => { ]; break; case DatabaseType.MySql: + case DatabaseType.ClickHouse: items = [ "TINYINT", "SMALLINT", "MEDIUMINT", "INT", "INTEGER", "BIGINT", "FLOAT", "DOUBLE", "DECIMAL", "DATE", "DATETIME", "TIMESTAMP", "TIME", "YEAR", From f794749a0dab0e46e19e4d319e7e31bd77b0e4a7 Mon Sep 17 00:00:00 2001 From: Hemang Kandwal Date: Tue, 28 Jan 2025 20:35:13 +0530 Subject: [PATCH 2/2] feat(frontend): fix # offset based on page --- frontend/src/components/table.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/table.tsx b/frontend/src/components/table.tsx index b80eb837..c5a41bb9 100644 --- a/frontend/src/components/table.tsx +++ b/frontend/src/components/table.tsx @@ -420,11 +420,11 @@ export const Table: FC = ({ className, columns: actualColumns, rows all[columns[colIndex+1].accessor] = one; } return all; - }, { "#": (rowIndex+1).toString() } as Record); + }, { "#": (rowIndex+1+(currentPage-1)*actualRows.length).toString() } as Record); newRow.originalIndex = rowIndex; return newRow; })); - }, [actualColumns, actualRows]); + }, [actualColumns, actualRows, currentPage]); const sortedRows = useMemo(() => { if (!sortedColumn) {