diff --git a/README.md b/README.md
index 087c57f7..cc87518c 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,6 @@ Why am I developing an SQL client when there are a lot of thom on the market?-->
This is a roadmap with major features will come in near future.
-- Options to insert new database records.
- Improvements of query editor area.
- Multiple query tabs.
- Tables management (add/edit/delete).
diff --git a/src/main/libs/AntaresConnector.js b/src/main/libs/AntaresConnector.js
index e9d5b901..b4ba58c6 100644
--- a/src/main/libs/AntaresConnector.js
+++ b/src/main/libs/AntaresConnector.js
@@ -235,10 +235,10 @@ export class AntaresConnector {
for (const key in fields) {
if (fields[key] === null) continue;
fieldsList.push(key);
- valueList.push(typeof fields[key] === 'number' ? fields[key] : `"${fields[key]}"`);
+ valueList.push(fields[key]);
}
- insertRaw = ` (${fieldsList.join(',')}) VALUES (${valueList.join(',')}) `;
+ insertRaw = `(${fieldsList.join(', ')}) VALUES (${valueList.join(', ')}) `;
}
const groupByArray = this._query.groupBy.reduce(this._reducer, []);
diff --git a/src/main/models/Tables.js b/src/main/models/Tables.js
index 13d7bbe9..0e707814 100644
--- a/src/main/models/Tables.js
+++ b/src/main/models/Tables.js
@@ -51,12 +51,36 @@ export default class {
.run();
}
- static async insertTableRows (connection, params) { // Prepare every field like updateTableCell method
+ static async insertTableRows (connection, params) {
+ const insertObj = {};
+ console.log(params);
+ for (const key in params.row) {
+ const type = params.fields[key];
+ let escapedParam;
+
+ if (NUMBER.includes(type))
+ escapedParam = params.row[key];
+ else if ([...TEXT, ...LONG_TEXT].includes(type))
+ escapedParam = `"${sqlEscaper(params.row[key])}"`;
+ else if (BLOB.includes(type)) {
+ if (params.row[key]) {
+ const fileBlob = fs.readFileSync(params.row[key]);
+ escapedParam = `0x${fileBlob.toString('hex')}`;
+ }
+ else
+ escapedParam = '""';
+ }
+ else
+ escapedParam = `"${sqlEscaper(params.row[key])}"`;
+
+ insertObj[key] = escapedParam;
+ }
+
for (let i = 0; i < params.repeat; i++) {
await connection
.schema(params.schema)
.into(params.table)
- .insert(params.row)
+ .insert(insertObj)
.run();
}
}
diff --git a/src/renderer/components/ModalNewTableRow.vue b/src/renderer/components/ModalNewTableRow.vue
index aa6443f7..2fb9f17f 100644
--- a/src/renderer/components/ModalNewTableRow.vue
+++ b/src/renderer/components/ModalNewTableRow.vue
@@ -32,6 +32,14 @@
:disabled="fieldsToExclude.includes(field.name)"
:tabindex="key+1"
>
+
{
if (this.fieldsToExclude.includes(key))
delete rowToInsert[key];
+ if (typeof rowToInsert[key] === 'undefined')
+ delete rowToInsert[key];
+ });
+
+ const fieldTypes = {};
+ this.fields.forEach(field => {
+ fieldTypes[field.name] = field.type;
});
try {
@@ -183,7 +198,8 @@ export default {
schema: this.workspace.breadcrumbs.schema,
table: this.workspace.breadcrumbs.table,
row: rowToInsert,
- repeat: this.nInserts
+ repeat: this.nInserts,
+ fields: fieldTypes
});
if (status === 'success') {
@@ -249,6 +265,12 @@ export default {
this.fieldsToExclude = this.fieldsToExclude.filter(f => f !== field.name);
else
this.fieldsToExclude = [...this.fieldsToExclude, field.name];
+ },
+ filesChange (event, field) {
+ const { files } = event.target;
+ if (!files.length) return;
+
+ this.localRow[field] = files[0].path;
}
}
};
diff --git a/src/renderer/components/WorkspaceQueryTableRow.vue b/src/renderer/components/WorkspaceQueryTableRow.vue
index 5d64439c..e44766ac 100644
--- a/src/renderer/components/WorkspaceQueryTableRow.vue
+++ b/src/renderer/components/WorkspaceQueryTableRow.vue
@@ -47,7 +47,9 @@
@hide="hideEditorModal"
>
- {{ $t('word.edit') }} "{{ editingField }}"
+