mirror of
https://github.com/langgenius/dify.git
synced 2026-03-26 08:40:14 +08:00
fix: show columns for empty sqlite tables
This commit is contained in:
@ -210,8 +210,17 @@ export function useSQLiteDatabase(downloadUrl: string | undefined): UseSQLiteDat
|
||||
`SELECT * FROM "${safeName}"${resolvedLimit ? ` LIMIT ${resolvedLimit}` : ''}`,
|
||||
[],
|
||||
)
|
||||
let columns = result.columns
|
||||
if (columns.length === 0) {
|
||||
const columnResult = await client.sqlite3.execWithParams(
|
||||
db,
|
||||
`PRAGMA table_info("${safeName}")`,
|
||||
[],
|
||||
)
|
||||
columns = columnResult.rows.map(row => String(row[1]))
|
||||
}
|
||||
const data: SQLiteQueryResult = {
|
||||
columns: result.columns,
|
||||
columns,
|
||||
values: result.rows as SQLiteValue[][],
|
||||
}
|
||||
cacheRef.current.set(cacheKey, data)
|
||||
|
||||
Reference in New Issue
Block a user