From 28ebae4525f35672acd6253b3022bdb8cdc1cbd1 Mon Sep 17 00:00:00 2001
From: James Barnett
Date: Wed, 28 Feb 2018 21:32:48 +0000
Subject: Update readme. Fix result parsing bug. Rearrange files
- Prefix query result fields with an underscore to avoid clashing with JS builtin property/function names which causes issues with Tabulator
- Move html files into their own dir
---
README.md | 43 ++++++++++++++++++++++-
editor-instance.html | 45 -------------------------
editor-instance.js | 19 +++++++++--
html/editor-instance.html | 45 +++++++++++++++++++++++++
html/index.html | 26 ++++++++++++++
html/new-connection.html | 73 ++++++++++++++++++++++++++++++++++++++++
html/query-executor-wrapper.html | 7 ++++
index.html | 26 --------------
instance-manager.js | 2 +-
main.js | 6 ++--
new-connection.html | 73 ----------------------------------------
query-executor-wrapper.html | 7 ----
styles/editor-instance.css | 15 +++++++++
13 files changed, 229 insertions(+), 158 deletions(-)
delete mode 100644 editor-instance.html
create mode 100644 html/editor-instance.html
create mode 100644 html/index.html
create mode 100644 html/new-connection.html
create mode 100644 html/query-executor-wrapper.html
delete mode 100644 index.html
delete mode 100644 new-connection.html
delete mode 100644 query-executor-wrapper.html
diff --git a/README.md b/README.md
index 52a6337..260cb70 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,42 @@
-# sql-plus-plus
\ No newline at end of file
+# SQL++
+[](https://travis-ci.org/jamesbarnett91/sql-plus-plus)
+
+A simple cross platform SQL editor and statement runner.
+Currently for Postgres only, but MySQL and Oracle support planned.
+
+
+
+
+
+# Features
+- Rich editor features. Syntax highlighting, autocomplete, bracket matching etc.
+- Cross platform. Linux (.deb), Windows and MacOS binaries available.
+- Simple editor interface. Doesn't have a huge array of GUI features like pgAdmin or Toad. For people who prefer a clean way to edit and run SQL.
+- Sortable and resizable query results table.
+
+# Installation
+Download one of the binary distributions from the releases page.
+Or, to run locally:
+```sh
+$ git clone https://github.com/jamesbarnett91/sql-plus-plus && cd sql-plus-plus
+$ npm install
+$ npm start
+```
+
+# Roadmap
+- [x] Store connection config
+- [x] Handle multiple simultaneous connections
+- [ ] Add schema tree view (listing tables>columns, packages, sequences etc.)
+- [ ] Load/Save .sql files
+- [ ] Improve autocomplete to be more schema aware
+- [ ] Support MySQL
+- [ ] Support Oracle
+- [ ] Save and display query history
+- [ ] CSV download of query results
+- [ ] 'Interpreter' mode. Run single queries with a CLI type interface (like Postgres psql and Oracle SQL*Plus)
+- [ ] Build .rpms
+
+# Note
+This is just a personal project, and a work in progress. There might be a few bugs in the result parsing, so don't rely on it for anything important unless you enjoy living on the edge.
+
+Connection details (including passwords) are stored encrypted, but the key is in the source code so it's only a basic level of obfuscation. I wouldn't connect to any prod databases with this.
\ No newline at end of file
diff --git a/editor-instance.html b/editor-instance.html
deleted file mode 100644
index 454c6ce..0000000
--- a/editor-instance.html
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
- SQL++
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/editor-instance.js b/editor-instance.js
index 8ed6674..6e2fd67 100644
--- a/editor-instance.js
+++ b/editor-instance.js
@@ -188,7 +188,7 @@ function handleResult(results) {
dataTable = $("#result-table").tabulator({
height: "100%",
columns: _mapColumnProperties(results),
- data: results.rows
+ data: _escapeRowFieldNames(results.rows)
});
_setExecutionStatusIndicator("OK");
@@ -198,12 +198,27 @@ function handleResult(results) {
function _mapColumnProperties(results) {
return results.fields.map((column) => {
return {
- field: column.name,
+ field: "_" + column.name, // "_" to match up to the output of _escapeRowFieldNames()
title: column.name
};
});
}
+/**
+ * Return the row object with all fields prefixed with an underscore.
+ * This avoids issues with Tabulator which doesn't like fields to have the same identifiers
+ * as built in JS properties/functions (e.g. 'length')
+ */
+function _escapeRowFieldNames(rows) {
+ return rows.map(row => {
+ let escapedRow = {}
+ Object.keys(row).forEach(key => {
+ escapedRow["_" + key] = row[key];
+ });
+ return escapedRow;
+ });
+}
+
function _resultTable() {
return $("#result-table");
}
diff --git a/html/editor-instance.html b/html/editor-instance.html
new file mode 100644
index 0000000..eaa2599
--- /dev/null
+++ b/html/editor-instance.html
@@ -0,0 +1,45 @@
+
+
+
+
+
+ SQL++
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/html/index.html b/html/index.html
new file mode 100644
index 0000000..b1997bf
--- /dev/null
+++ b/html/index.html
@@ -0,0 +1,26 @@
+
+
+
+
+ SQL++
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/html/new-connection.html b/html/new-connection.html
new file mode 100644
index 0000000..192c9b9
--- /dev/null
+++ b/html/new-connection.html
@@ -0,0 +1,73 @@
+
+
+
+
+ SQL++ - New connection
+
+
+
+
+
+
Add new connection
+
+
+
+
\ No newline at end of file
diff --git a/html/query-executor-wrapper.html b/html/query-executor-wrapper.html
new file mode 100644
index 0000000..ddc9ffc
--- /dev/null
+++ b/html/query-executor-wrapper.html
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/index.html b/index.html
deleted file mode 100644
index 2d8dbee..0000000
--- a/index.html
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-