Fix sourceDevice column type in unprocessed
This commit is contained in:
parent
649d24b623
commit
96718464ef
4 changed files with 119 additions and 5 deletions
|
@ -34,7 +34,7 @@ export function updateToVersion(db: WritableDB, version: number): void {
|
|||
}
|
||||
|
||||
type TableRows = ReadonlyArray<
|
||||
Record<string, string | number | null | Record<string, unknown>>
|
||||
Record<string, string | number | Buffer | null | Record<string, unknown>>
|
||||
>;
|
||||
|
||||
export function insertData(
|
||||
|
@ -52,6 +52,9 @@ export function insertData(
|
|||
`
|
||||
).run(
|
||||
Object.values(row).map(v => {
|
||||
if (Buffer.isBuffer(v)) {
|
||||
return v;
|
||||
}
|
||||
if (v != null && typeof v === 'object') {
|
||||
return JSON.stringify(v);
|
||||
}
|
||||
|
@ -65,7 +68,7 @@ export function getTableData(db: ReadableDB, table: string): TableRows {
|
|||
return db
|
||||
.prepare(`SELECT * FROM ${table}`)
|
||||
.all()
|
||||
.map((row: Record<string, string | number | null>) => {
|
||||
.map((row: Record<string, string | number | Buffer | null>) => {
|
||||
const result: Record<
|
||||
string,
|
||||
string | number | null | Record<string, unknown>
|
||||
|
@ -79,7 +82,7 @@ export function getTableData(db: ReadableDB, table: string): TableRows {
|
|||
continue;
|
||||
}
|
||||
try {
|
||||
if (typeof value !== 'string') {
|
||||
if (typeof value !== 'string' || !value.trim().startsWith('{')) {
|
||||
throw new Error('skip');
|
||||
}
|
||||
result[key] = JSON.parse(value) as Record<string, unknown>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue