Skip to content

Commit 6a5c93b

Browse files
committed
fix: fix all minor bugs
1 parent 348df81 commit 6a5c93b

File tree

12 files changed

+39
-21
lines changed

12 files changed

+39
-21
lines changed

release/app/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/libs/GenerateSqlFromPlan.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export default function generateSqlFromPlan(plan: SqlStatementPlan) {
3333
}
3434
} else if (plan.type === 'insert') {
3535
if (plan.values) {
36-
return qb('mysql').table(plan.table).insert(plan.values).toRawSQL();
36+
return qb('mysql')
37+
.table(plan.table)
38+
.insert(convertUnsupportedValue(plan.values))
39+
.toRawSQL();
3740
}
3841
}
3942

src/libs/SaveCSVFile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import xlsx from 'xlsx';
1+
import * as xlsx from 'xlsx';
22
import fs from 'fs';
33

44
export default function saveCsvFile(fileName: string, records: object[]) {

src/libs/SaveExcelFile.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import xlsx from 'xlsx';
1+
import * as xlsx from 'xlsx';
2+
import fs from 'fs';
23

34
export default function saveExcelFile(fileName: string, records: object[]) {
45
const workbook = xlsx.utils.book_new();
56
const worksheet = xlsx.utils.json_to_sheet(records);
67
xlsx.utils.book_append_sheet(workbook, worksheet);
8+
xlsx.set_fs(fs);
79
xlsx.writeFile(workbook, fileName);
810
}

src/renderer/components/ResizableTable/FullTextEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import CodeMirror from '@uiw/react-codemirror';
2+
import { EditorView } from 'codemirror';
23
import Modal from '../Modal';
3-
import { json } from '@codemirror/lang-json';
44
import Button from '../Button';
55
import useCodeEditorTheme from '../CodeEditor/useCodeEditorTheme';
66
import { useState } from 'react';
@@ -33,7 +33,7 @@ export default function FullTextEditor({
3333
readOnly={readOnly}
3434
maxHeight="50vh"
3535
theme={theme}
36-
extensions={[json()]}
36+
extensions={[EditorView.lineWrapping]}
3737
/>
3838
</Modal.Body>
3939
<Modal.Footer>

src/renderer/components/ResizableTable/TableCellSelect.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default function TableCellSelect({
3232
}}
3333
value={value ?? ''}
3434
>
35+
<option hidden></option>
3536
{items.map((item) => (
3637
<option key={item} value={item}>
3738
{item}

src/renderer/screens/DatabaseScreen/ExportModal/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,16 @@ export default function ExportModal({ data, onClose }: ExportModalProps) {
194194
window.electron
195195
.saveExcelFile(fileName, data.rows)
196196
.then(() => setStage('SUCCESS'))
197-
.catch(() => {
197+
.catch((e) => {
198+
console.error(e);
198199
setStage('ERROR');
199200
});
200201
} else if (format === 'csv') {
201202
window.electron
202203
.saveCsvFile(fileName, data.rows)
203204
.then(() => setStage('SUCCESS'))
204-
.catch(() => {
205+
.catch((e) => {
206+
console.error(e);
205207
setStage('ERROR');
206208
});
207209
} else {

src/renderer/screens/DatabaseScreen/QueryResultViewer/QueryResultAction.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export default function QueryResultAction({
5959
collector.getChanges()
6060
);
6161

62+
console.log(plans);
6263
const rawSql = plans.map((plan) => ({
6364
sql: generateSqlFromPlan(plan),
6465
}));

src/renderer/screens/DatabaseScreen/QueryResultViewer/QueryResultTable.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,19 @@ function QueryResultTable({ result, page, pageSize }: QueryResultTableProps) {
190190

191191
const renderCell = useCallback(
192192
(y: number, x: number) => {
193-
return (
194-
<TableCell
195-
key={data[y].rowIndex}
196-
value={data[y].data[result.headers[x].name]}
197-
header={result.headers[x]}
198-
col={x}
199-
row={data[y].rowIndex}
200-
readOnly={!updatableTables[result.headers[x]?.schema?.table || '']}
201-
/>
202-
);
193+
if (data[y]) {
194+
return (
195+
<TableCell
196+
key={data[y].rowIndex}
197+
value={data[y].data[result.headers[x].name]}
198+
header={result.headers[x]}
199+
col={x}
200+
row={data[y].rowIndex}
201+
readOnly={!updatableTables[result.headers[x]?.schema?.table || '']}
202+
/>
203+
);
204+
}
205+
return <></>;
203206
},
204207
[data, result, updatableTables, page, pageSize, newRowCount]
205208
);

src/renderer/screens/DatabaseScreen/QueryResultViewer/TableCell/TableCellEnum.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function TableCellStringEditor({
2323

2424
return (
2525
<TableCellSelect
26-
items={header.columnDefinition?.enumValues ?? []}
26+
items={[...(header.columnDefinition?.enumValues ?? [])]}
2727
readOnly={readOnly}
2828
onChange={setEditValue}
2929
onLostFocus={onLostFocus}

0 commit comments

Comments
 (0)