mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
b4b2f3d0cf | |||
7a766f04e6 | |||
f6b77d1243 | |||
840241c3cc | |||
0f10c9e824 | |||
1e37f2a96f | |||
0d6137195d | |||
d26f168250 | |||
5efcad4d3f | |||
0a872e7023 | |||
0e425a9c6d | |||
434711a360 | |||
854472c7a3 | |||
9a7cd90d5c | |||
026400d242 | |||
4bd8cbbf6c | |||
1382bc9300 | |||
ae103e5477 | |||
6b0b8b19d7 | |||
475397ca34 | |||
7a62131cc7 | |||
c7663be338 | |||
496490b14a | |||
|
672573d8c2 | ||
d923453919 | |||
0435279604 | |||
79cef61fea | |||
dec334737f | |||
84c3692e95 | |||
5dc0b0bea4 | |||
19d16e46bb | |||
3baf6fa173 | |||
29e2d92b5b | |||
bebba64d06 | |||
9dfe7cca22 | |||
35ef070725 |
@@ -1,4 +1,4 @@
|
|||||||
name: Build/release
|
name: Build/release [linux]
|
||||||
|
|
||||||
on: push
|
on: push
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ jobs:
|
|||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, ubuntu-latest, windows-latest]
|
os: [ubuntu-latest]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out Git repository
|
- name: Check out Git repository
|
26
.github/workflows/build-mac.yml
vendored
Normal file
26
.github/workflows/build-mac.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Build/release [mac]
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [macos-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out Git repository
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Install Node.js, NPM and Yarn
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12
|
||||||
|
|
||||||
|
- name: Build/release Electron app
|
||||||
|
uses: samuelmeuli/action-electron-builder@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.github_token }}
|
||||||
|
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
26
.github/workflows/build-win.yml
vendored
Normal file
26
.github/workflows/build-win.yml
vendored
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
name: Build/release [windows]
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [windows-latest]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Check out Git repository
|
||||||
|
uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: Install Node.js, NPM and Yarn
|
||||||
|
uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12
|
||||||
|
|
||||||
|
- name: Build/release Electron app
|
||||||
|
uses: samuelmeuli/action-electron-builder@v1
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.github_token }}
|
||||||
|
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
|
51
CHANGELOG.md
51
CHANGELOG.md
@@ -2,6 +2,57 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
### [0.1.8](https://github.com/Fabio286/antares/compare/v0.1.7...v0.1.8) (2021-05-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* internal id not removed before row update ([0f10c9e](https://github.com/Fabio286/antares/commit/0f10c9e824b679cfebd8a31085236da3d38a7953))
|
||||||
|
* unable to add new ENUM fields ([1e37f2a](https://github.com/Fabio286/antares/commit/1e37f2a96f660a36f2739fea57ca298059e9c31a))
|
||||||
|
* unable to delete table rows ([0d61371](https://github.com/Fabio286/antares/commit/0d6137195da9e0e9afe68f6d3ebcd50e913a888e))
|
||||||
|
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* improved the way how field default value are handled ([7a766f0](https://github.com/Fabio286/antares/commit/7a766f04e668868e8844aac1d7d445bc2da21558))
|
||||||
|
|
||||||
|
### [0.1.7](https://github.com/Fabio286/antares/compare/v0.1.6...v0.1.7) (2021-05-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* row loses internal id after cell update ([854472c](https://github.com/Fabio286/antares/commit/854472c7a3d8442b1eede12f978cad5aa684094e))
|
||||||
|
* **MySQL:** connection loses schema in some conditions ([6b0b8b1](https://github.com/Fabio286/antares/commit/6b0b8b19d7176ef8647d6f401a33315f8732fdf3))
|
||||||
|
* issue with ENUM and SET fields on table filler modal ([475397c](https://github.com/Fabio286/antares/commit/475397ca34c5b7d8925e2d97d32216d5b80d8211))
|
||||||
|
* issue with ENUM and SET length when creating a new field ([7a62131](https://github.com/Fabio286/antares/commit/7a62131cc707aa1c98bb12513de76229472b7c38))
|
||||||
|
* multiple row select on sorted tables not work properly ([c7663be](https://github.com/Fabio286/antares/commit/c7663be338ccb5ff31e241e824593531ad95bd32))
|
||||||
|
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* **core:** increased connection pool size to improve performance ([ae103e5](https://github.com/Fabio286/antares/commit/ae103e5477ad190c541d0f29e277c41de6947063))
|
||||||
|
* **MySQL:** improved connections pool handling ([434711a](https://github.com/Fabio286/antares/commit/434711a360bd7539d2ec3adec92e7ccc96fa828e))
|
||||||
|
|
||||||
|
### [0.1.6](https://github.com/Fabio286/antares/compare/v0.1.5...v0.1.6) (2021-05-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **MySQL:** ENUM and SET fields support, closes [#61](https://github.com/Fabio286/antares/issues/61) ([bebba64](https://github.com/Fabio286/antares/commit/bebba64d06532990405763284e27cb768dc050f7))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* better detection and handling of field default type ([3baf6fa](https://github.com/Fabio286/antares/commit/3baf6fa1736a405c95fb02d17c11514861ca9e04))
|
||||||
|
* no quotes around strings in field default custom value ([29e2d92](https://github.com/Fabio286/antares/commit/29e2d92b5bf66ff9e80bb1fee1274967c4418601))
|
||||||
|
* **UI:** data type figure twice on type select ([9dfe7cc](https://github.com/Fabio286/antares/commit/9dfe7cca2234ce6de512bb4c21205c2217e7f765))
|
||||||
|
* support to mDNS/zeroconf in snap build, closes [#58](https://github.com/Fabio286/antares/issues/58) ([35ef070](https://github.com/Fabio286/antares/commit/35ef070725f5779923bf3ad428b44accddf22dbe))
|
||||||
|
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
* italian translation updated ([5dc0b0b](https://github.com/Fabio286/antares/commit/5dc0b0bea40f9d5a5944af2f1c5dc6ff3e60c396))
|
||||||
|
|
||||||
### [0.1.5](https://github.com/Fabio286/antares/compare/v0.1.4...v0.1.5) (2021-04-30)
|
### [0.1.5](https://github.com/Fabio286/antares/compare/v0.1.4...v0.1.5) (2021-04-30)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -83,7 +83,7 @@ This is a roadmap with major features will come in near future.
|
|||||||
#### • ARM
|
#### • ARM
|
||||||
|
|
||||||
- [ ] Windows
|
- [ ] Windows
|
||||||
- [ ] Linux
|
- [x] Linux
|
||||||
- [ ] MacOS
|
- [ ] MacOS
|
||||||
|
|
||||||
## Translations
|
## Translations
|
||||||
|
BIN
build/appx/LargeTile.png
Normal file
BIN
build/appx/LargeTile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
BIN
build/appx/SmallTile.png
Normal file
BIN
build/appx/SmallTile.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.4 KiB |
87
package.json
87
package.json
@@ -1,20 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "antares",
|
"name": "antares",
|
||||||
"productName": "Antares",
|
"productName": "Antares",
|
||||||
"version": "0.1.5",
|
"version": "0.1.8",
|
||||||
"description": "A cross-platform easy to use SQL client.",
|
"description": "A cross-platform easy to use SQL client.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": "https://github.com/Fabio286/antares.git",
|
"repository": "https://github.com/Fabio286/antares.git",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cross-env NODE_ENV=development electron-webpack dev",
|
"dev": "cross-env NODE_ENV=development electron-webpack dev",
|
||||||
"compile": "electron-webpack",
|
"compile": "electron-webpack",
|
||||||
"build": "cross-env NODE_ENV=production npm run compile && electron-builder",
|
"build": "cross-env NODE_ENV=production npm run compile",
|
||||||
"build:appx": "npm run build -- --win appx",
|
"build:local": "npm run build && electron-builder",
|
||||||
|
"build:appx": "npm run build:local -- --win appx",
|
||||||
"release": "standard-version",
|
"release": "standard-version",
|
||||||
"release:pre": "npm run release -- --prerelease alpha",
|
"release:pre": "npm run release -- --prerelease alpha",
|
||||||
"test": "npm run lint",
|
"test": "npm run lint",
|
||||||
"lint": "eslint . --ext .js,.vue && stylelint \"./src/**/*.{css,scss,sass,vue}\"",
|
"lint": "eslint . --ext .js,.vue && stylelint \"./src/**/*.{css,scss,sass,vue}\"",
|
||||||
"lint:fix": "eslint . --ext .js,.vue --fix && stylelint \"./src/**/*.{css,scss,sass,vue}\" --fix"
|
"lint:fix": "eslint . --ext .js,.vue --fix && stylelint \"./src/**/*.{css,scss,sass,vue}\" --fix",
|
||||||
|
"postinstall": "electron-builder install-app-deps"
|
||||||
},
|
},
|
||||||
"author": "Fabio Di Stasio <fabio286@gmail.com>",
|
"author": "Fabio Di Stasio <fabio286@gmail.com>",
|
||||||
"build": {
|
"build": {
|
||||||
@@ -26,24 +28,28 @@
|
|||||||
"portable"
|
"portable"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dmg": {
|
"mac": {
|
||||||
"contents": [
|
"target": {
|
||||||
{
|
"target": "default",
|
||||||
"x": 130,
|
"arch": [
|
||||||
"y": 220
|
"x64"
|
||||||
},
|
]
|
||||||
{
|
}
|
||||||
"x": 410,
|
|
||||||
"y": 220,
|
|
||||||
"type": "link",
|
|
||||||
"path": "/Applications"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"linux": {
|
"linux": {
|
||||||
"target": [
|
"target": [
|
||||||
"deb",
|
{
|
||||||
"AppImage"
|
"target": "deb",
|
||||||
|
"arch": "x64"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"target": "AppImage",
|
||||||
|
"arch": [
|
||||||
|
"x64",
|
||||||
|
"armv7l",
|
||||||
|
"arm64"
|
||||||
|
]
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"category": "Development"
|
"category": "Development"
|
||||||
},
|
},
|
||||||
@@ -59,6 +65,20 @@
|
|||||||
"identityName": "62514FabioDiStasio.AntaresSQLClient",
|
"identityName": "62514FabioDiStasio.AntaresSQLClient",
|
||||||
"publisher": "CN=1A2729ED-865C-41D2-9038-39AE2A63AA52",
|
"publisher": "CN=1A2729ED-865C-41D2-9038-39AE2A63AA52",
|
||||||
"applicationId": "FabioDiStasio.AntaresSQLClient"
|
"applicationId": "FabioDiStasio.AntaresSQLClient"
|
||||||
|
},
|
||||||
|
"dmg": {
|
||||||
|
"contents": [
|
||||||
|
{
|
||||||
|
"x": 130,
|
||||||
|
"y": 220
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"x": 410,
|
||||||
|
"y": 220,
|
||||||
|
"type": "link",
|
||||||
|
"path": "/Applications"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"electronWebpack": {
|
"electronWebpack": {
|
||||||
@@ -70,42 +90,41 @@
|
|||||||
"@electron/remote": "^1.1.0",
|
"@electron/remote": "^1.1.0",
|
||||||
"@mdi/font": "^5.9.55",
|
"@mdi/font": "^5.9.55",
|
||||||
"ace-builds": "^1.4.12",
|
"ace-builds": "^1.4.12",
|
||||||
"electron-log": "^4.3.0",
|
"electron-log": "^4.3.5",
|
||||||
"electron-store": "^8.0.0",
|
"electron-store": "^8.0.0",
|
||||||
"electron-updater": "^4.3.5",
|
"electron-updater": "^4.3.9",
|
||||||
"faker": "^5.3.1",
|
"faker": "^5.5.3",
|
||||||
"marked": "^2.0.2",
|
"marked": "^2.0.2",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"mysql2": "^2.2.5",
|
"mysql2": "^2.2.5",
|
||||||
"node-sql-parser": "^3.1.0",
|
|
||||||
"pg": "^8.5.1",
|
"pg": "^8.5.1",
|
||||||
"pgsql-ast-parser": "^7.0.2",
|
"pgsql-ast-parser": "^7.2.1",
|
||||||
"source-map-support": "^0.5.16",
|
"source-map-support": "^0.5.16",
|
||||||
"spectre.css": "^0.5.9",
|
"spectre.css": "^0.5.9",
|
||||||
"sql-formatter": "^4.0.2",
|
"sql-formatter": "^4.0.2",
|
||||||
"v-mask": "^2.2.4",
|
"v-mask": "^2.2.4",
|
||||||
"vue-i18n": "^8.22.4",
|
"vue-i18n": "^8.24.4",
|
||||||
"vuedraggable": "^2.24.3",
|
"vuedraggable": "^2.24.3",
|
||||||
"vuex": "^3.6.0"
|
"vuex": "^3.6.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/eslint-parser": "^7.13.14",
|
"@babel/eslint-parser": "^7.14.3",
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.2",
|
||||||
"electron": "^12.0.5",
|
"electron": "^12.0.9",
|
||||||
"electron-builder": "^22.9.1",
|
"electron-builder": "22.10.5",
|
||||||
"electron-devtools-installer": "^3.2.0",
|
"electron-devtools-installer": "^3.2.0",
|
||||||
"electron-webpack": "^2.8.2",
|
"electron-webpack": "^2.8.2",
|
||||||
"electron-webpack-vue": "^2.4.0",
|
"electron-webpack-vue": "^2.4.0",
|
||||||
"eslint": "^7.24.0",
|
"eslint": "^7.26.0",
|
||||||
"eslint-config-standard": "^16.0.2",
|
"eslint-config-standard": "^16.0.2",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
"eslint-plugin-import": "^2.22.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^5.1.0",
|
"eslint-plugin-promise": "^5.1.0",
|
||||||
"eslint-plugin-vue": "^7.9.0",
|
"eslint-plugin-vue": "^7.9.0",
|
||||||
"node-sass": "^5.0.0",
|
"sass": "^1.32.13",
|
||||||
"sass-loader": "^10.1.1",
|
"sass-loader": "^10.2.0",
|
||||||
"standard-version": "^9.2.0",
|
"standard-version": "^9.3.0",
|
||||||
"stylelint": "^13.12.0",
|
"stylelint": "^13.13.1",
|
||||||
"stylelint-config-standard": "^22.0.0",
|
"stylelint-config-standard": "^22.0.0",
|
||||||
"stylelint-scss": "^3.19.0",
|
"stylelint-scss": "^3.19.0",
|
||||||
"vue": "^2.6.12",
|
"vue": "^2.6.12",
|
||||||
|
@@ -14,6 +14,9 @@ confinement: strict
|
|||||||
architectures:
|
architectures:
|
||||||
- build-on: amd64
|
- build-on: amd64
|
||||||
compression: lzo
|
compression: lzo
|
||||||
|
layout:
|
||||||
|
/etc/nsswitch.conf:
|
||||||
|
bind-file: $SNAP/etc/nsswitch.conf
|
||||||
|
|
||||||
parts:
|
parts:
|
||||||
antares:
|
antares:
|
||||||
@@ -71,11 +74,28 @@ parts:
|
|||||||
cleanup:
|
cleanup:
|
||||||
after: [antares]
|
after: [antares]
|
||||||
plugin: nil
|
plugin: nil
|
||||||
build-snaps: [ gnome-3-28-1804 ]
|
build-snaps: [gnome-3-28-1804]
|
||||||
override-prime: |
|
override-prime: |
|
||||||
set -eux
|
set -eux
|
||||||
cd /snap/gnome-3-28-1804/current
|
cd /snap/gnome-3-28-1804/current
|
||||||
find . -type f,l -exec rm -f $SNAPCRAFT_PRIME/{} \;
|
find . -type f,l -exec rm -f $SNAPCRAFT_PRIME/{} \;
|
||||||
|
|
||||||
|
mdns-lookup:
|
||||||
|
# Make resolution of ".local" host names (Zero-Conf/mDNS/DNS-SD)
|
||||||
|
# working: Take the original nsswitch.conf file from the base
|
||||||
|
# Snap and add "mdns4_minimal [NOTFOUND=return]" to its "hosts:" line
|
||||||
|
# Also install corresponding mdns4_minimal plug-in
|
||||||
|
# See: https://forum.snapcraft.io/t/no-mdns-support-in-snaps-should-core-have-a-modified-nsswitch-conf/
|
||||||
|
plugin: nil
|
||||||
|
stage-packages:
|
||||||
|
- libnss-mdns
|
||||||
|
override-prime: |
|
||||||
|
set -eux
|
||||||
|
sed -Ee 's/^\s*hosts:(\s+)files/hosts:\1files mdns4_minimal \[NOTFOUND=return\]/' /snap/core18/current/etc/nsswitch.conf > $SNAPCRAFT_STAGE/etc/nsswitch.conf
|
||||||
|
snapcraftctl prime
|
||||||
|
prime:
|
||||||
|
- lib/$SNAPCRAFT_ARCH_TRIPLET/libnss_mdns4_minimal*
|
||||||
|
- etc/nsswitch.conf
|
||||||
|
|
||||||
apps:
|
apps:
|
||||||
antares:
|
antares:
|
||||||
@@ -93,4 +113,4 @@ apps:
|
|||||||
- opengl
|
- opengl
|
||||||
- pulseaudio
|
- pulseaudio
|
||||||
- removable-media
|
- removable-media
|
||||||
- unity7
|
- unity7
|
||||||
|
@@ -277,13 +277,6 @@ module.exports = [
|
|||||||
{
|
{
|
||||||
group: 'other',
|
group: 'other',
|
||||||
types: [
|
types: [
|
||||||
{
|
|
||||||
name: 'UNKNOWN',
|
|
||||||
length: false,
|
|
||||||
collation: false,
|
|
||||||
unsigned: false,
|
|
||||||
zerofill: false
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'ENUM',
|
name: 'ENUM',
|
||||||
length: true,
|
length: true,
|
||||||
@@ -299,5 +292,17 @@ module.exports = [
|
|||||||
zerofill: false
|
zerofill: false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
group: 'unknown',
|
||||||
|
types: [
|
||||||
|
{
|
||||||
|
name: 'UNKNOWN',
|
||||||
|
length: false,
|
||||||
|
collation: false,
|
||||||
|
unsigned: false,
|
||||||
|
zerofill: false
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@@ -71,7 +71,7 @@ export default connections => {
|
|||||||
const connection = ClientsFactory.getConnection({
|
const connection = ClientsFactory.getConnection({
|
||||||
client: conn.client,
|
client: conn.client,
|
||||||
params,
|
params,
|
||||||
poolSize: 1
|
poolSize: 5
|
||||||
});
|
});
|
||||||
|
|
||||||
await connection.connect();
|
await connection.connect();
|
||||||
|
@@ -128,7 +128,7 @@ export default connections => {
|
|||||||
if (!query) return;
|
if (!query) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await connections[uid].raw(query, { nest: true, details: true });
|
const result = await connections[uid].raw(query, { nest: true, details: true, schema });
|
||||||
|
|
||||||
return { status: 'success', response: result };
|
return { status: 'success', response: result };
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import mysql from 'mysql2';
|
import mysql from 'mysql2/promise';
|
||||||
import { AntaresCore } from '../AntaresCore';
|
import { AntaresCore } from '../AntaresCore';
|
||||||
import dataTypes from 'common/data-types/mysql';
|
import dataTypes from 'common/data-types/mysql';
|
||||||
|
|
||||||
@@ -102,8 +102,10 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async connect () {
|
async connect () {
|
||||||
|
delete this._params.application_name;
|
||||||
|
|
||||||
if (!this._poolSize)
|
if (!this._poolSize)
|
||||||
this._connection = mysql.createConnection(this._params);
|
this._connection = await mysql.createConnection(this._params);
|
||||||
else {
|
else {
|
||||||
this._connection = mysql.createPool({
|
this._connection = mysql.createPool({
|
||||||
...this._params,
|
...this._params,
|
||||||
@@ -307,25 +309,67 @@ export class MySQLClient extends AntaresCore {
|
|||||||
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
.orderBy({ ORDINAL_POSITION: 'ASC' })
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
|
const { rows: fields } = await this.raw(`SHOW CREATE TABLE ${schema}.${table}`);
|
||||||
|
|
||||||
|
const remappedFields = fields.map(row => {
|
||||||
|
let n = 0;
|
||||||
|
return row['Create Table']
|
||||||
|
.split('')
|
||||||
|
.reduce((acc, curr) => {
|
||||||
|
if (curr === ')') n--;
|
||||||
|
if (n !== 0) acc += curr;
|
||||||
|
if (curr === '(') n++;
|
||||||
|
return acc;
|
||||||
|
}, '')
|
||||||
|
.replaceAll('\n', '')
|
||||||
|
.split(',')
|
||||||
|
.map(f => {
|
||||||
|
const fieldArr = f.trim().split(' ');
|
||||||
|
const nameAndType = fieldArr.slice(0, 2);
|
||||||
|
|
||||||
|
if (!nameAndType[0].includes('`')) return false;
|
||||||
|
|
||||||
|
const details = fieldArr.slice(2).join(' ');
|
||||||
|
const defaultValue = details.includes('DEFAULT') ? details.match(/(?<=DEFAULT ).*?$/gs)[0] : null;
|
||||||
|
const typeAndLength = nameAndType[1].replace(')', '').split('(');
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: nameAndType[0].replaceAll('`', ''),
|
||||||
|
type: typeAndLength[0].toUpperCase(),
|
||||||
|
length: typeAndLength[1] ? typeAndLength[1] : null,
|
||||||
|
default: defaultValue
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
|
.reduce((acc, curr) => {
|
||||||
|
acc[curr.name] = curr;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
})[0];
|
||||||
|
|
||||||
return rows.map(field => {
|
return rows.map(field => {
|
||||||
let numLength = field.COLUMN_TYPE.match(/int\(([^)]+)\)/);
|
let numLength = field.COLUMN_TYPE.match(/int\(([^)]+)\)/);
|
||||||
numLength = numLength ? +numLength.pop() : null;
|
numLength = numLength ? +numLength.pop() : null;
|
||||||
|
const enumValues = /(enum|set)/.test(field.COLUMN_TYPE)
|
||||||
|
? field.COLUMN_TYPE.match(/\(([^)]+)\)/)[0].slice(1, -1)
|
||||||
|
: null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: field.COLUMN_NAME,
|
name: field.COLUMN_NAME,
|
||||||
key: field.COLUMN_KEY.toLowerCase(),
|
key: field.COLUMN_KEY.toLowerCase(),
|
||||||
type: field.DATA_TYPE.toUpperCase(),
|
type: remappedFields[field.COLUMN_NAME].type,
|
||||||
schema: field.TABLE_SCHEMA,
|
schema: field.TABLE_SCHEMA,
|
||||||
table: field.TABLE_NAME,
|
table: field.TABLE_NAME,
|
||||||
numPrecision: field.NUMERIC_PRECISION,
|
numPrecision: field.NUMERIC_PRECISION,
|
||||||
numLength,
|
numLength,
|
||||||
|
enumValues,
|
||||||
datePrecision: field.DATETIME_PRECISION,
|
datePrecision: field.DATETIME_PRECISION,
|
||||||
charLength: field.CHARACTER_MAXIMUM_LENGTH,
|
charLength: field.CHARACTER_MAXIMUM_LENGTH,
|
||||||
nullable: field.IS_NULLABLE.includes('YES'),
|
nullable: field.IS_NULLABLE.includes('YES'),
|
||||||
unsigned: field.COLUMN_TYPE.includes('unsigned'),
|
unsigned: field.COLUMN_TYPE.includes('unsigned'),
|
||||||
zerofill: field.COLUMN_TYPE.includes('zerofill'),
|
zerofill: field.COLUMN_TYPE.includes('zerofill'),
|
||||||
order: field.ORDINAL_POSITION,
|
order: field.ORDINAL_POSITION,
|
||||||
default: field.COLUMN_DEFAULT,
|
default: remappedFields[field.COLUMN_NAME].default,
|
||||||
charset: field.CHARACTER_SET_NAME,
|
charset: field.CHARACTER_SET_NAME,
|
||||||
collation: field.COLLATION_NAME,
|
collation: field.COLLATION_NAME,
|
||||||
autoIncrement: field.EXTRA.includes('auto_increment'),
|
autoIncrement: field.EXTRA.includes('auto_increment'),
|
||||||
@@ -484,7 +528,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async dropView (params) {
|
async dropView (params) {
|
||||||
const sql = `DROP VIEW \`${params.view}\``;
|
const sql = `DROP VIEW \`${this._schema}\`.\`${params.view}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,10 +540,10 @@ export class MySQLClient extends AntaresCore {
|
|||||||
*/
|
*/
|
||||||
async alterView (params) {
|
async alterView (params) {
|
||||||
const { view } = params;
|
const { view } = params;
|
||||||
let sql = `ALTER ALGORITHM = ${view.algorithm}${view.definer ? ` DEFINER=${view.definer}` : ''} SQL SECURITY ${view.security} VIEW \`${view.oldName}\` AS ${view.sql} ${view.updateOption ? `WITH ${view.updateOption} CHECK OPTION` : ''}`;
|
let sql = `ALTER ALGORITHM = ${view.algorithm}${view.definer ? ` DEFINER=${view.definer}` : ''} SQL SECURITY ${view.security} VIEW \`${this._schema}\`.\`${view.oldName}\` AS ${view.sql} ${view.updateOption ? `WITH ${view.updateOption} CHECK OPTION` : ''}`;
|
||||||
|
|
||||||
if (view.name !== view.oldName)
|
if (view.name !== view.oldName)
|
||||||
sql += `; RENAME TABLE \`${view.oldName}\` TO \`${view.name}\``;
|
sql += `; RENAME TABLE \`${this._schema}\`.\`${view.oldName}\` TO \`${this._schema}\`.\`${view.name}\``;
|
||||||
|
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
@@ -511,7 +555,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async createView (view) {
|
async createView (view) {
|
||||||
const sql = `CREATE ALGORITHM = ${view.algorithm} ${view.definer ? `DEFINER=${view.definer} ` : ''}SQL SECURITY ${view.security} VIEW \`${view.name}\` AS ${view.sql} ${view.updateOption ? `WITH ${view.updateOption} CHECK OPTION` : ''}`;
|
const sql = `CREATE ALGORITHM = ${view.algorithm} ${view.definer ? `DEFINER=${view.definer} ` : ''}SQL SECURITY ${view.security} VIEW \`${this._schema}\`.\`${view.name}\` AS ${view.sql} ${view.updateOption ? `WITH ${view.updateOption} CHECK OPTION` : ''}`;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -544,7 +588,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async dropTrigger (params) {
|
async dropTrigger (params) {
|
||||||
const sql = `DROP TRIGGER \`${params.trigger}\``;
|
const sql = `DROP TRIGGER \`${this._schema}\`.\`${params.trigger}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -577,7 +621,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async createTrigger (trigger) {
|
async createTrigger (trigger) {
|
||||||
const sql = `CREATE ${trigger.definer ? `DEFINER=${trigger.definer} ` : ''}TRIGGER \`${trigger.name}\` ${trigger.event1} ${trigger.event2} ON \`${trigger.table}\` FOR EACH ROW ${trigger.sql}`;
|
const sql = `CREATE ${trigger.definer ? `DEFINER=${trigger.definer} ` : ''}TRIGGER \`${this._schema}\`.\`${trigger.name}\` ${trigger.event1} ${trigger.event2} ON \`${trigger.table}\` FOR EACH ROW ${trigger.sql}`;
|
||||||
return await this.raw(sql, { split: false });
|
return await this.raw(sql, { split: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -651,7 +695,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async dropRoutine (params) {
|
async dropRoutine (params) {
|
||||||
const sql = `DROP PROCEDURE \`${params.routine}\``;
|
const sql = `DROP PROCEDURE \`${this._schema}\`.\`${params.routine}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +735,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
}, []).join(',')
|
}, []).join(',')
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const sql = `CREATE ${routine.definer ? `DEFINER=${routine.definer} ` : ''}PROCEDURE \`${routine.name}\`(${parameters})
|
const sql = `CREATE ${routine.definer ? `DEFINER=${routine.definer} ` : ''}PROCEDURE \`${this._schema}\`.\`${routine.name}\`(${parameters})
|
||||||
LANGUAGE SQL
|
LANGUAGE SQL
|
||||||
${routine.deterministic ? 'DETERMINISTIC' : 'NOT DETERMINISTIC'}
|
${routine.deterministic ? 'DETERMINISTIC' : 'NOT DETERMINISTIC'}
|
||||||
${routine.dataAccess}
|
${routine.dataAccess}
|
||||||
@@ -778,7 +822,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async dropFunction (params) {
|
async dropFunction (params) {
|
||||||
const sql = `DROP FUNCTION \`${params.func}\``;
|
const sql = `DROP FUNCTION \`${this._schema}\`.\`${params.func}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,7 +862,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
|
|
||||||
const body = func.returns ? func.sql : 'BEGIN\n RETURN 0;\nEND';
|
const body = func.returns ? func.sql : 'BEGIN\n RETURN 0;\nEND';
|
||||||
|
|
||||||
const sql = `CREATE ${func.definer ? `DEFINER=${func.definer} ` : ''}FUNCTION \`${func.name}\`(${parameters}) RETURNS ${func.returns || 'SMALLINT'}${func.returnsLength ? `(${func.returnsLength})` : ''}
|
const sql = `CREATE ${func.definer ? `DEFINER=${func.definer} ` : ''}FUNCTION \`${this._schema}\`.\`${func.name}\`(${parameters}) RETURNS ${func.returns || 'SMALLINT'}${func.returnsLength ? `(${func.returnsLength})` : ''}
|
||||||
LANGUAGE SQL
|
LANGUAGE SQL
|
||||||
${func.deterministic ? 'DETERMINISTIC' : 'NOT DETERMINISTIC'}
|
${func.deterministic ? 'DETERMINISTIC' : 'NOT DETERMINISTIC'}
|
||||||
${func.dataAccess}
|
${func.dataAccess}
|
||||||
@@ -870,7 +914,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async dropEvent (params) {
|
async dropEvent (params) {
|
||||||
const sql = `DROP EVENT \`${params.scheduler}\``;
|
const sql = `DROP EVENT \`${this._schema}\`.\`${params.scheduler}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,13 +930,13 @@ export class MySQLClient extends AntaresCore {
|
|||||||
if (scheduler.execution === 'EVERY' && scheduler.every[0].includes('-'))
|
if (scheduler.execution === 'EVERY' && scheduler.every[0].includes('-'))
|
||||||
scheduler.every[0] = `'${scheduler.every[0]}'`;
|
scheduler.every[0] = `'${scheduler.every[0]}'`;
|
||||||
|
|
||||||
const sql = `ALTER ${scheduler.definer ? ` DEFINER=${scheduler.definer}` : ''} EVENT \`${scheduler.oldName}\`
|
const sql = `ALTER ${scheduler.definer ? ` DEFINER=${scheduler.definer}` : ''} EVENT \`${this._schema}\`.\`${scheduler.oldName}\`
|
||||||
ON SCHEDULE
|
ON SCHEDULE
|
||||||
${scheduler.execution === 'EVERY'
|
${scheduler.execution === 'EVERY'
|
||||||
? `EVERY ${scheduler.every.join(' ')}${scheduler.starts ? ` STARTS '${scheduler.starts}'` : ''}${scheduler.ends ? ` ENDS '${scheduler.ends}'` : ''}`
|
? `EVERY ${scheduler.every.join(' ')}${scheduler.starts ? ` STARTS '${scheduler.starts}'` : ''}${scheduler.ends ? ` ENDS '${scheduler.ends}'` : ''}`
|
||||||
: `AT '${scheduler.at}'`}
|
: `AT '${scheduler.at}'`}
|
||||||
ON COMPLETION${!scheduler.preserve ? ' NOT' : ''} PRESERVE
|
ON COMPLETION${!scheduler.preserve ? ' NOT' : ''} PRESERVE
|
||||||
${scheduler.name !== scheduler.oldName ? `RENAME TO \`${scheduler.name}\`` : ''}
|
${scheduler.name !== scheduler.oldName ? `RENAME TO \`${this._schema}\`.\`${scheduler.name}\`` : ''}
|
||||||
${scheduler.state}
|
${scheduler.state}
|
||||||
COMMENT '${scheduler.comment}'
|
COMMENT '${scheduler.comment}'
|
||||||
DO ${scheduler.sql}`;
|
DO ${scheduler.sql}`;
|
||||||
@@ -907,7 +951,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async createEvent (scheduler) {
|
async createEvent (scheduler) {
|
||||||
const sql = `CREATE ${scheduler.definer ? ` DEFINER=${scheduler.definer}` : ''} EVENT \`${scheduler.name}\`
|
const sql = `CREATE ${scheduler.definer ? ` DEFINER=${scheduler.definer}` : ''} EVENT \`${this._schema}\`.\`${scheduler.name}\`
|
||||||
ON SCHEDULE
|
ON SCHEDULE
|
||||||
${scheduler.execution === 'EVERY'
|
${scheduler.execution === 'EVERY'
|
||||||
? `EVERY ${scheduler.every.join(' ')}${scheduler.starts ? ` STARTS '${scheduler.starts}'` : ''}${scheduler.ends ? ` ENDS '${scheduler.ends}'` : ''}`
|
? `EVERY ${scheduler.every.join(' ')}${scheduler.starts ? ` STARTS '${scheduler.starts}'` : ''}${scheduler.ends ? ` ENDS '${scheduler.ends}'` : ''}`
|
||||||
@@ -1044,7 +1088,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
engine
|
engine
|
||||||
} = params;
|
} = params;
|
||||||
|
|
||||||
const sql = `CREATE TABLE \`${name}\` (\`${name}_ID\` INT NULL) COMMENT='${comment}', COLLATE='${collation}', ENGINE=${engine}`;
|
const sql = `CREATE TABLE \`${this._schema}\`.\`${name}\` (\`${name}_ID\` INT NULL) COMMENT='${comment}', COLLATE='${collation}', ENGINE=${engine}`;
|
||||||
|
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1122,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
// ADD FIELDS
|
// ADD FIELDS
|
||||||
additions.forEach(addition => {
|
additions.forEach(addition => {
|
||||||
const typeInfo = this._getTypeInfo(addition.type);
|
const typeInfo = this._getTypeInfo(addition.type);
|
||||||
const length = typeInfo.length ? addition.numLength || addition.charLength || addition.datePrecision : false;
|
const length = typeInfo.length ? addition.enumValues || addition.numLength || addition.charLength || addition.datePrecision : false;
|
||||||
|
|
||||||
alterColumns.push(`ADD COLUMN \`${addition.name}\`
|
alterColumns.push(`ADD COLUMN \`${addition.name}\`
|
||||||
${addition.type.toUpperCase()}${length ? `(${length})` : ''}
|
${addition.type.toUpperCase()}${length ? `(${length})` : ''}
|
||||||
@@ -1116,7 +1160,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
// CHANGE FIELDS
|
// CHANGE FIELDS
|
||||||
changes.forEach(change => {
|
changes.forEach(change => {
|
||||||
const typeInfo = this._getTypeInfo(change.type);
|
const typeInfo = this._getTypeInfo(change.type);
|
||||||
const length = typeInfo.length ? change.numLength || change.charLength || change.datePrecision : false;
|
const length = typeInfo.length ? change.enumValues || change.numLength || change.charLength || change.datePrecision : false;
|
||||||
|
|
||||||
alterColumns.push(`CHANGE COLUMN \`${change.orgName}\` \`${change.name}\`
|
alterColumns.push(`CHANGE COLUMN \`${change.orgName}\` \`${change.name}\`
|
||||||
${change.type.toUpperCase()}${length ? `(${length})` : ''}
|
${change.type.toUpperCase()}${length ? `(${length})` : ''}
|
||||||
@@ -1178,7 +1222,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
sql += alterColumns.join(', ');
|
sql += alterColumns.join(', ');
|
||||||
|
|
||||||
// RENAME
|
// RENAME
|
||||||
if (options.name) sql += `; RENAME TABLE \`${table}\` TO \`${options.name}\``;
|
if (options.name) sql += `; RENAME TABLE \`${this._schema}\`.\`${table}\` TO \`${this._schema}\`.\`${options.name}\``;
|
||||||
|
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
@@ -1190,7 +1234,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async truncateTable (params) {
|
async truncateTable (params) {
|
||||||
const sql = `TRUNCATE TABLE \`${params.table}\``;
|
const sql = `TRUNCATE TABLE \`${this._schema}\`.\`${params.table}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1201,7 +1245,7 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async dropTable (params) {
|
async dropTable (params) {
|
||||||
const sql = `DROP TABLE \`${params.table}\``;
|
const sql = `DROP TABLE \`${this._schema}\`.\`${params.table}\``;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1269,18 +1313,24 @@ export class MySQLClient extends AntaresCore {
|
|||||||
* @memberof MySQLClient
|
* @memberof MySQLClient
|
||||||
*/
|
*/
|
||||||
async raw (sql, args) {
|
async raw (sql, args) {
|
||||||
|
if (process.env.NODE_ENV === 'development') this._logger(sql);// TODO: replace BLOB content with a placeholder
|
||||||
|
|
||||||
args = {
|
args = {
|
||||||
nest: false,
|
nest: false,
|
||||||
details: false,
|
details: false,
|
||||||
split: true,
|
split: true,
|
||||||
...args
|
...args
|
||||||
};
|
};
|
||||||
|
|
||||||
const nestTables = args.nest ? '.' : false;
|
const nestTables = args.nest ? '.' : false;
|
||||||
const resultsArr = [];
|
const resultsArr = [];
|
||||||
let paramsArr = [];
|
let paramsArr = [];
|
||||||
const queries = args.split ? sql.split(/((?:[^;'"]*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*')[^;'"]*)+)|;/gm) : [sql];
|
const queries = args.split ? sql.split(/((?:[^;'"]*(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*')[^;'"]*)+)|;/gm) : [sql];
|
||||||
|
const isPool = typeof this._connection.getConnection === 'function';
|
||||||
|
const connection = isPool ? await this._connection.getConnection() : this._connection;
|
||||||
|
|
||||||
if (process.env.NODE_ENV === 'development') this._logger(sql);// TODO: replace BLOB content with a placeholder
|
if (args.schema)
|
||||||
|
await connection.query(`USE \`${args.schema}\``);
|
||||||
|
|
||||||
for (const query of queries) {
|
for (const query of queries) {
|
||||||
if (!query) continue;
|
if (!query) continue;
|
||||||
@@ -1289,87 +1339,85 @@ export class MySQLClient extends AntaresCore {
|
|||||||
let keysArr = [];
|
let keysArr = [];
|
||||||
|
|
||||||
const { rows, report, fields, keys, duration } = await new Promise((resolve, reject) => {
|
const { rows, report, fields, keys, duration } = await new Promise((resolve, reject) => {
|
||||||
this._connection.query({ sql: query, nestTables }, async (err, response, fields) => {
|
connection.query({ sql: query, nestTables }).then(async ([response, fields]) => {
|
||||||
timeStop = new Date();
|
timeStop = new Date();
|
||||||
const queryResult = response;
|
const queryResult = response;
|
||||||
|
|
||||||
if (err)
|
let remappedFields = fields
|
||||||
reject(err);
|
? fields.map(field => {
|
||||||
else {
|
if (!field || Array.isArray(field))
|
||||||
let remappedFields = fields
|
return false;
|
||||||
? fields.map(field => {
|
|
||||||
if (!field || Array.isArray(field))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const type = this._getType(field);
|
const type = this._getType(field);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: field.orgName,
|
||||||
|
alias: field.name,
|
||||||
|
orgName: field.orgName,
|
||||||
|
schema: field.schema,
|
||||||
|
table: field.table,
|
||||||
|
tableAlias: field.table,
|
||||||
|
orgTable: field.orgTable,
|
||||||
|
type: type.name,
|
||||||
|
length: type.length
|
||||||
|
};
|
||||||
|
}).filter(Boolean)
|
||||||
|
: [];
|
||||||
|
|
||||||
|
if (args.details) {
|
||||||
|
let cachedTable;
|
||||||
|
|
||||||
|
if (remappedFields.length) {
|
||||||
|
paramsArr = remappedFields.map(field => {
|
||||||
|
if (field.orgTable) cachedTable = field.orgTable;// Needed for some queries on information_schema
|
||||||
return {
|
return {
|
||||||
name: field.orgName,
|
table: field.orgTable || cachedTable,
|
||||||
alias: field.name,
|
schema: field.schema || 'INFORMATION_SCHEMA'
|
||||||
orgName: field.orgName,
|
|
||||||
schema: field.schema,
|
|
||||||
table: field.table,
|
|
||||||
tableAlias: field.table,
|
|
||||||
orgTable: field.orgTable,
|
|
||||||
type: type.name,
|
|
||||||
length: type.length
|
|
||||||
};
|
};
|
||||||
}).filter(Boolean)
|
}).filter((val, i, arr) => arr.findIndex(el => el.schema === val.schema && el.table === val.table) === i);
|
||||||
: [];
|
|
||||||
|
|
||||||
if (args.details) {
|
for (const paramObj of paramsArr) {
|
||||||
let cachedTable;
|
if (!paramObj.table || !paramObj.schema) continue;
|
||||||
|
|
||||||
if (remappedFields.length) {
|
try { // Column details
|
||||||
paramsArr = remappedFields.map(field => {
|
const response = await this.getTableColumns(paramObj);
|
||||||
if (field.orgTable) cachedTable = field.orgTable;// Needed for some queries on information_schema
|
remappedFields = remappedFields.map(field => {
|
||||||
return {
|
const detailedField = response.find(f => f.name === field.name);
|
||||||
table: field.orgTable || cachedTable,
|
if (detailedField && field.orgTable === paramObj.table && field.schema === paramObj.schema)
|
||||||
schema: field.schema || 'INFORMATION_SCHEMA'
|
field = { ...field, ...detailedField };
|
||||||
};
|
return field;
|
||||||
}).filter((val, i, arr) => arr.findIndex(el => el.schema === val.schema && el.table === val.table) === i);
|
});
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
|
||||||
for (const paramObj of paramsArr) {
|
try { // Key usage (foreign keys)
|
||||||
if (!paramObj.table || !paramObj.schema) continue;
|
const response = await this.getKeyUsage(paramObj);
|
||||||
|
keysArr = keysArr ? [...keysArr, ...response] : response;
|
||||||
try { // Column details
|
}
|
||||||
const response = await this.getTableColumns(paramObj);
|
catch (err) {
|
||||||
remappedFields = remappedFields.map(field => {
|
reject(err);
|
||||||
const detailedField = response.find(f => f.name === field.name);
|
|
||||||
if (detailedField && field.orgTable === paramObj.table && field.schema === paramObj.schema)
|
|
||||||
field = { ...detailedField, ...field };
|
|
||||||
return field;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
try { // Key usage (foreign keys)
|
|
||||||
const response = await this.getKeyUsage(paramObj);
|
|
||||||
keysArr = keysArr ? [...keysArr, ...response] : response;
|
|
||||||
}
|
|
||||||
catch (err) {
|
|
||||||
reject(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve({
|
|
||||||
duration: timeStop - timeStart,
|
|
||||||
rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? [] : queryResult : false,
|
|
||||||
report: !Array.isArray(queryResult) ? queryResult : false,
|
|
||||||
fields: remappedFields,
|
|
||||||
keys: keysArr
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
resolve({
|
||||||
|
duration: timeStop - timeStart,
|
||||||
|
rows: Array.isArray(queryResult) ? queryResult.some(el => Array.isArray(el)) ? [] : queryResult : false,
|
||||||
|
report: !Array.isArray(queryResult) ? queryResult : false,
|
||||||
|
fields: remappedFields,
|
||||||
|
keys: keysArr
|
||||||
|
});
|
||||||
|
}).catch(reject);
|
||||||
});
|
});
|
||||||
|
|
||||||
resultsArr.push({ rows, report, fields, keys, duration });
|
resultsArr.push({ rows, report, fields, keys, duration });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPool) connection.release();
|
||||||
|
|
||||||
return resultsArr.length === 1 ? resultsArr[0] : resultsArr;
|
return resultsArr.length === 1 ? resultsArr[0] : resultsArr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -816,97 +816,6 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
return await this.raw(sql, { split: false });
|
return await this.raw(sql, { split: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* SHOW CREATE EVENT
|
|
||||||
*
|
|
||||||
* @returns {Array.<Object>} view informations
|
|
||||||
* @memberof PostgreSQLClient
|
|
||||||
*/
|
|
||||||
// async getEventInformations ({ schema, scheduler }) {
|
|
||||||
// const sql = `SHOW CREATE EVENT \`${schema}\`.\`${scheduler}\``;
|
|
||||||
// const results = await this.raw(sql);
|
|
||||||
|
|
||||||
// return results.rows.map(row => {
|
|
||||||
// const schedule = row['Create Event'];
|
|
||||||
// const execution = schedule.includes('EVERY') ? 'EVERY' : 'ONCE';
|
|
||||||
// const every = execution === 'EVERY' ? row['Create Event'].match(/(?<=EVERY )(\s*([^\s]+)){0,2}/gs)[0].replaceAll('\'', '').split(' ') : [];
|
|
||||||
// const starts = execution === 'EVERY' && schedule.includes('STARTS') ? schedule.match(/(?<=STARTS ').*?(?='\s)/gs)[0] : '';
|
|
||||||
// const ends = execution === 'EVERY' && schedule.includes('ENDS') ? schedule.match(/(?<=ENDS ').*?(?='\s)/gs)[0] : '';
|
|
||||||
// const at = execution === 'ONCE' && schedule.includes('AT') ? schedule.match(/(?<=AT ').*?(?='\s)/gs)[0] : '';
|
|
||||||
|
|
||||||
// return {
|
|
||||||
// definer: row['Create Event'].match(/(?<=DEFINER=).*?(?=\s)/gs)[0],
|
|
||||||
// sql: row['Create Event'].match(/(?<=DO )(.*)/gs)[0],
|
|
||||||
// name: row.Event,
|
|
||||||
// comment: row['Create Event'].match(/(?<=COMMENT ').*?(?=')/gs) ? row['Create Event'].match(/(?<=COMMENT ').*?(?=')/gs)[0] : '',
|
|
||||||
// state: row['Create Event'].includes('ENABLE') ? 'ENABLE' : row['Create Event'].includes('DISABLE ON SLAVE') ? 'DISABLE ON SLAVE' : 'DISABLE',
|
|
||||||
// preserve: row['Create Event'].includes('ON COMPLETION PRESERVE'),
|
|
||||||
// execution,
|
|
||||||
// every,
|
|
||||||
// starts,
|
|
||||||
// ends,
|
|
||||||
// at
|
|
||||||
// };
|
|
||||||
// })[0];
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DROP EVENT
|
|
||||||
*
|
|
||||||
* @returns {Array.<Object>} parameters
|
|
||||||
* @memberof PostgreSQLClient
|
|
||||||
*/
|
|
||||||
// async dropEvent (params) {
|
|
||||||
// const sql = `DROP EVENT \`${params.scheduler}\``;
|
|
||||||
// return await this.raw(sql);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ALTER EVENT
|
|
||||||
*
|
|
||||||
* @returns {Array.<Object>} parameters
|
|
||||||
* @memberof PostgreSQLClient
|
|
||||||
*/
|
|
||||||
// async alterEvent (params) {
|
|
||||||
// const { scheduler } = params;
|
|
||||||
|
|
||||||
// if (scheduler.execution === 'EVERY' && scheduler.every[0].includes('-'))
|
|
||||||
// scheduler.every[0] = `'${scheduler.every[0]}'`;
|
|
||||||
|
|
||||||
// const sql = `ALTER ${scheduler.definer ? ` DEFINER=${scheduler.definer}` : ''} EVENT \`${scheduler.oldName}\`
|
|
||||||
// ON SCHEDULE
|
|
||||||
// ${scheduler.execution === 'EVERY'
|
|
||||||
// ? `EVERY ${scheduler.every.join(' ')}${scheduler.starts ? ` STARTS '${scheduler.starts}'` : ''}${scheduler.ends ? ` ENDS '${scheduler.ends}'` : ''}`
|
|
||||||
// : `AT '${scheduler.at}'`}
|
|
||||||
// ON COMPLETION${!scheduler.preserve ? ' NOT' : ''} PRESERVE
|
|
||||||
// ${scheduler.name !== scheduler.oldName ? `RENAME TO \`${scheduler.name}\`` : ''}
|
|
||||||
// ${scheduler.state}
|
|
||||||
// COMMENT '${scheduler.comment}'
|
|
||||||
// DO ${scheduler.sql}`;
|
|
||||||
|
|
||||||
// return await this.raw(sql, { split: false });
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CREATE EVENT
|
|
||||||
*
|
|
||||||
* @returns {Array.<Object>} parameters
|
|
||||||
* @memberof PostgreSQLClient
|
|
||||||
*/
|
|
||||||
// async createEvent (scheduler) {
|
|
||||||
// const sql = `CREATE ${scheduler.definer ? ` DEFINER=${scheduler.definer}` : ''} EVENT \`${scheduler.name}\`
|
|
||||||
// ON SCHEDULE
|
|
||||||
// ${scheduler.execution === 'EVERY'
|
|
||||||
// ? `EVERY ${scheduler.every.join(' ')}${scheduler.starts ? ` STARTS '${scheduler.starts}'` : ''}${scheduler.ends ? ` ENDS '${scheduler.ends}'` : ''}`
|
|
||||||
// : `AT '${scheduler.at}'`}
|
|
||||||
// ON COMPLETION${!scheduler.preserve ? ' NOT' : ''} PRESERVE
|
|
||||||
// ${scheduler.state}
|
|
||||||
// COMMENT '${scheduler.comment}'
|
|
||||||
// DO ${scheduler.sql}`;
|
|
||||||
|
|
||||||
// return await this.raw(sql, { split: false });
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SELECT * FROM pg_collation
|
* SELECT * FROM pg_collation
|
||||||
*
|
*
|
||||||
@@ -1250,8 +1159,8 @@ export class PostgreSQLClient extends AntaresCore {
|
|||||||
...args
|
...args
|
||||||
};
|
};
|
||||||
|
|
||||||
if (args.nest && this._schema !== 'public')
|
if (args.schema && args.schema !== 'public')
|
||||||
await this.use(this._schema);
|
await this.use(args.schema);
|
||||||
|
|
||||||
const resultsArr = [];
|
const resultsArr = [];
|
||||||
let paramsArr = [];
|
let paramsArr = [];
|
||||||
|
@@ -66,6 +66,21 @@
|
|||||||
:type="inputProps().type"
|
:type="inputProps().type"
|
||||||
:disabled="!isChecked"
|
:disabled="!isChecked"
|
||||||
>
|
>
|
||||||
|
<select
|
||||||
|
v-else-if="enumArray"
|
||||||
|
v-model="selectedValue"
|
||||||
|
class="form-select"
|
||||||
|
:disabled="!isChecked"
|
||||||
|
@change="onChange"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
v-for="val in enumArray"
|
||||||
|
:key="val"
|
||||||
|
:value="val"
|
||||||
|
>
|
||||||
|
{{ val }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
<input
|
<input
|
||||||
v-else
|
v-else
|
||||||
ref="formInput"
|
ref="formInput"
|
||||||
@@ -121,7 +136,8 @@ export default {
|
|||||||
selectedMethod: '',
|
selectedMethod: '',
|
||||||
selectedValue: '',
|
selectedValue: '',
|
||||||
debounceTimeout: null,
|
debounceTimeout: null,
|
||||||
methodParams: {}
|
methodParams: {},
|
||||||
|
enumArray: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -150,8 +166,14 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
fieldObj () {
|
fieldObj () {
|
||||||
if (this.fieldObj)
|
if (this.fieldObj) {
|
||||||
this.selectedValue = this.fieldObj.value;
|
if (Array.isArray(this.fieldObj.value)) {
|
||||||
|
this.enumArray = this.fieldObj.value;
|
||||||
|
this.selectedValue = this.fieldObj.value[0];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
this.selectedValue = this.fieldObj.value;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
selectedGroup () {
|
selectedGroup () {
|
||||||
if (this.fakerMethods.length)
|
if (this.fakerMethods.length)
|
||||||
|
@@ -51,7 +51,8 @@ export default {
|
|||||||
}),
|
}),
|
||||||
isValidDefault () {
|
isValidDefault () {
|
||||||
if (!this.foreignList.length) return true;
|
if (!this.foreignList.length) return true;
|
||||||
return this.value === null || this.foreignList.some(foreign => foreign.foreign_column.toString() === this.value.toString());
|
if (this.value === null) return false;
|
||||||
|
return this.foreignList.some(foreign => foreign.foreign_column.toString() === this.value.toString());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created () {
|
async created () {
|
||||||
@@ -65,7 +66,7 @@ export default {
|
|||||||
try { // Field data
|
try { // Field data
|
||||||
const { status, response } = await Tables.getTableColumns(params);
|
const { status, response } = await Tables.getTableColumns(params);
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
const textField = response.find(field => [...TEXT, ...LONG_TEXT].includes(field.type));
|
const textField = response.find(field => [...TEXT, ...LONG_TEXT].includes(field.type) && field.name !== this.keyUsage.refField);
|
||||||
foreignDesc = textField ? textField.name : false;
|
foreignDesc = textField ? textField.name : false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -250,10 +250,15 @@ export default {
|
|||||||
if (field.default === 'NULL') fieldDefault = null;
|
if (field.default === 'NULL') fieldDefault = null;
|
||||||
else {
|
else {
|
||||||
if ([...NUMBER, ...FLOAT].includes(field.type))
|
if ([...NUMBER, ...FLOAT].includes(field.type))
|
||||||
fieldDefault = +field.default;
|
fieldDefault = Number.isNaN(+field.default) ? null : +field.default;
|
||||||
|
|
||||||
if ([...TEXT, ...LONG_TEXT].includes(field.type))
|
if ([...TEXT, ...LONG_TEXT].includes(field.type)) {
|
||||||
fieldDefault = field.default ? field.default.substring(1, field.default.length - 1) : '';
|
fieldDefault = field.default
|
||||||
|
? field.default.includes('\'')
|
||||||
|
? field.default.split('\'')[1]
|
||||||
|
: field.default
|
||||||
|
: '';
|
||||||
|
}
|
||||||
|
|
||||||
if ([...TIME, ...DATE].includes(field.type))
|
if ([...TIME, ...DATE].includes(field.type))
|
||||||
fieldDefault = field.default;
|
fieldDefault = field.default;
|
||||||
@@ -269,6 +274,9 @@ export default {
|
|||||||
fieldDefault = moment().format(`YYYY-MM-DD HH:mm:ss${datePrecision}`);
|
fieldDefault = moment().format(`YYYY-MM-DD HH:mm:ss${datePrecision}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field.enumValues)
|
||||||
|
fieldDefault = field.enumValues.replaceAll('\'', '').split(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
rowObj[field.name] = { value: fieldDefault };
|
rowObj[field.name] = { value: fieldDefault };
|
||||||
|
@@ -233,6 +233,20 @@ export default {
|
|||||||
const { status, response } = await Tables.getTableColumns(params);
|
const { status, response } = await Tables.getTableColumns(params);
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
this.originalFields = response.map(field => {
|
this.originalFields = response.map(field => {
|
||||||
|
if (field.autoIncrement)
|
||||||
|
field.defaultType = 'autoincrement';
|
||||||
|
else if (field.default === null)
|
||||||
|
field.defaultType = 'noval';
|
||||||
|
else if (field.default === 'NULL')
|
||||||
|
field.defaultType = 'null';
|
||||||
|
else if (field.default.match(/^\s*(\w+)\s*\((.*)\)$/))
|
||||||
|
field.defaultType = 'expression';
|
||||||
|
else {
|
||||||
|
field.defaultType = 'custom';
|
||||||
|
if (isNaN(field.default) && !field.default.includes('\''))
|
||||||
|
field.default = `'${field.default}'`;
|
||||||
|
}
|
||||||
|
|
||||||
return { ...field, _id: uidGen() };
|
return { ...field, _id: uidGen() };
|
||||||
});
|
});
|
||||||
this.localFields = JSON.parse(JSON.stringify(this.originalFields));
|
this.localFields = JSON.parse(JSON.stringify(this.originalFields));
|
||||||
|
@@ -96,8 +96,22 @@
|
|||||||
class="cell-content"
|
class="cell-content"
|
||||||
@dblclick="editON($event, localLength, 'length')"
|
@dblclick="editON($event, localLength, 'length')"
|
||||||
>
|
>
|
||||||
{{ localLength }}
|
<span v-if="localRow.enumValues">
|
||||||
|
{{ localRow.enumValues }}
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
{{ localLength }}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
<input
|
||||||
|
v-else-if="localRow.enumValues"
|
||||||
|
ref="editField"
|
||||||
|
v-model="editingContent"
|
||||||
|
type="text"
|
||||||
|
autofocus
|
||||||
|
class="editable-field px-2"
|
||||||
|
@blur="editOFF"
|
||||||
|
>
|
||||||
<input
|
<input
|
||||||
v-else
|
v-else
|
||||||
ref="editField"
|
ref="editField"
|
||||||
@@ -381,10 +395,12 @@ export default {
|
|||||||
isInDataTypes () {
|
isInDataTypes () {
|
||||||
let typeNames = [];
|
let typeNames = [];
|
||||||
for (const group of this.dataTypes) {
|
for (const group of this.dataTypes) {
|
||||||
typeNames = group.types.reduce((acc, curr) => {
|
const groupTypeNames = group.types.reduce((acc, curr) => {
|
||||||
acc.push(curr.name);
|
acc.push(curr.name);
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
typeNames = [...groupTypeNames, ...typeNames];
|
||||||
}
|
}
|
||||||
return typeNames.includes(this.row.type);
|
return typeNames.includes(this.row.type);
|
||||||
}
|
}
|
||||||
@@ -433,37 +449,35 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.defaultValue.onUpdate = this.localRow.onUpdate;
|
this.defaultValue.onUpdate = this.localRow.onUpdate;
|
||||||
|
this.defaultValue.type = this.localRow.defaultType;
|
||||||
if (this.localRow.autoIncrement)
|
if (this.defaultValue.type === 'custom') {
|
||||||
this.defaultValue.type = 'autoincrement';
|
this.defaultValue.custom = this.localRow.default
|
||||||
else if (this.localRow.default === null)
|
? this.localRow.default.includes('\'')
|
||||||
this.defaultValue.type = 'noval';
|
? this.localRow.default.split('\'')[1]
|
||||||
else if (this.localRow.default === 'NULL')
|
: this.localRow.default
|
||||||
this.defaultValue.type = 'null';
|
: '';
|
||||||
else if (this.localRow.default.match(/^'.*'$/g)) {
|
|
||||||
this.defaultValue.type = 'custom';
|
|
||||||
this.defaultValue.custom = this.localRow.default.replace(/(^')|('$)/g, '');
|
|
||||||
}
|
}
|
||||||
else if (!isNaN(this.localRow.default.replace(/[:.-\s]/g, ''))) {
|
if (this.defaultValue.type === 'expression')
|
||||||
this.defaultValue.type = 'custom';
|
|
||||||
this.defaultValue.custom = this.localRow.default;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.defaultValue.type = 'expression';
|
|
||||||
this.defaultValue.expression = this.localRow.default;
|
this.defaultValue.expression = this.localRow.default;
|
||||||
}
|
|
||||||
},
|
},
|
||||||
editON (event, content, field) {
|
editON (event, content, field) {
|
||||||
if (field === 'length') {
|
if (field === 'length') {
|
||||||
if (['integer', 'float', 'binary', 'spatial'].includes(this.fieldType.group)) this.editingField = 'numLength';
|
if (['integer', 'float', 'binary', 'spatial'].includes(this.fieldType.group)) this.editingField = 'numLength';
|
||||||
if (['string', 'other'].includes(this.fieldType.group)) this.editingField = 'charLength';
|
else if (['string', 'unknown'].includes(this.fieldType.group)) this.editingField = 'charLength';
|
||||||
if (['time'].includes(this.fieldType.group)) this.editingField = 'datePrecision';
|
else if (['other'].includes(this.fieldType.group)) this.editingField = 'enumValues';
|
||||||
|
else if (['time'].includes(this.fieldType.group)) this.editingField = 'datePrecision';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.editingField = field;
|
this.editingField = field;
|
||||||
|
|
||||||
this.editingContent = content;
|
if (this.localRow.enumValues && field === 'length') {
|
||||||
this.originalContent = content;
|
this.editingContent = this.localRow.enumValues;
|
||||||
|
this.originalContent = this.localRow.enumValues;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.editingContent = content;
|
||||||
|
this.originalContent = content;
|
||||||
|
}
|
||||||
|
|
||||||
const obj = { [field]: true };
|
const obj = { [field]: true };
|
||||||
this.isInlineEditor = { ...this.isInlineEditor, ...obj };
|
this.isInlineEditor = { ...this.isInlineEditor, ...obj };
|
||||||
@@ -488,11 +502,13 @@ export default {
|
|||||||
this.localRow.numLength = null;
|
this.localRow.numLength = null;
|
||||||
this.localRow.charLength = null;
|
this.localRow.charLength = null;
|
||||||
this.localRow.datePrecision = null;
|
this.localRow.datePrecision = null;
|
||||||
|
this.localRow.enumValues = '';
|
||||||
|
|
||||||
if (this.fieldType.length) {
|
if (this.fieldType.length) {
|
||||||
if (['integer', 'float', 'binary', 'spatial'].includes(this.fieldType.group)) this.localRow.numLength = 11;
|
if (['integer', 'float', 'binary', 'spatial'].includes(this.fieldType.group)) this.localRow.numLength = 11;
|
||||||
if (['string', 'other'].includes(this.fieldType.group)) this.localRow.charLength = 15;
|
if (['string'].includes(this.fieldType.group)) this.localRow.charLength = 15;
|
||||||
if (['time'].includes(this.fieldType.group)) this.localRow.datePrecision = 0;
|
if (['time'].includes(this.fieldType.group)) this.localRow.datePrecision = 0;
|
||||||
|
if (['other'].includes(this.fieldType.group)) this.localRow.enumValues = '\'valA\',\'valB\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.fieldType.collation)
|
if (!this.fieldType.collation)
|
||||||
@@ -519,7 +535,7 @@ export default {
|
|||||||
break;
|
break;
|
||||||
case 'custom':
|
case 'custom':
|
||||||
this.localRow.autoIncrement = false;
|
this.localRow.autoIncrement = false;
|
||||||
this.localRow.default = `'${this.defaultValue.custom}'`;
|
this.localRow.default = Number.isNaN(+this.defaultValue.custom) ? `'${this.defaultValue.custom}'` : this.defaultValue.custom;
|
||||||
break;
|
break;
|
||||||
case 'expression':
|
case 'expression':
|
||||||
this.localRow.autoIncrement = false;
|
this.localRow.autoIncrement = false;
|
||||||
|
@@ -319,8 +319,6 @@ export default {
|
|||||||
},
|
},
|
||||||
updateField (payload, row) {
|
updateField (payload, row) {
|
||||||
const orgRow = this.localResults.find(lr => lr._id === row._id);
|
const orgRow = this.localResults.find(lr => lr._id === row._id);
|
||||||
delete row._id;
|
|
||||||
delete orgRow._id;
|
|
||||||
|
|
||||||
Object.keys(orgRow).forEach(key => { // remap the row
|
Object.keys(orgRow).forEach(key => { // remap the row
|
||||||
if (orgRow[key] instanceof Date && moment(orgRow[key]).isValid()) { // if datetime
|
if (orgRow[key] instanceof Date && moment(orgRow[key]).isValid()) { // if datetime
|
||||||
@@ -370,7 +368,6 @@ export default {
|
|||||||
},
|
},
|
||||||
setNull () {
|
setNull () {
|
||||||
const row = this.localResults.find(row => this.selectedRows.includes(row._id));
|
const row = this.localResults.find(row => this.selectedRows.includes(row._id));
|
||||||
delete row._id;
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
primary: this.primaryField.name,
|
primary: this.primaryField.name,
|
||||||
@@ -408,15 +405,15 @@ export default {
|
|||||||
this.selectedRows.push(row);
|
this.selectedRows.push(row);
|
||||||
else {
|
else {
|
||||||
const lastID = this.selectedRows.slice(-1)[0];
|
const lastID = this.selectedRows.slice(-1)[0];
|
||||||
const lastIndex = this.localResults.findIndex(el => el._id === lastID);
|
const lastIndex = this.sortedResults.findIndex(el => el._id === lastID);
|
||||||
const clickedIndex = this.localResults.findIndex(el => el._id === row);
|
const clickedIndex = this.sortedResults.findIndex(el => el._id === row);
|
||||||
if (lastIndex > clickedIndex) {
|
if (lastIndex > clickedIndex) {
|
||||||
for (let i = clickedIndex; i < lastIndex; i++)
|
for (let i = clickedIndex; i < lastIndex; i++)
|
||||||
this.selectedRows.push(this.localResults[i]._id);
|
this.selectedRows.push(this.sortedResults[i]._id);
|
||||||
}
|
}
|
||||||
else if (lastIndex < clickedIndex) {
|
else if (lastIndex < clickedIndex) {
|
||||||
for (let i = clickedIndex; i > lastIndex; i--)
|
for (let i = clickedIndex; i > lastIndex; i--)
|
||||||
this.selectedRows.push(this.localResults[i]._id);
|
this.selectedRows.push(this.sortedResults[i]._id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,6 +432,8 @@ export default {
|
|||||||
sort (field) {
|
sort (field) {
|
||||||
if (!this.isSortable) return;
|
if (!this.isSortable) return;
|
||||||
|
|
||||||
|
this.selectedRows = [];
|
||||||
|
|
||||||
if (this.mode === 'query')
|
if (this.mode === 'query')
|
||||||
field = `${this.getTable(this.resultsetIndex)}.${field}`;
|
field = `${this.getTable(this.resultsetIndex)}.${field}`;
|
||||||
|
|
||||||
|
@@ -43,6 +43,16 @@
|
|||||||
<option>true</option>
|
<option>true</option>
|
||||||
<option>false</option>
|
<option>false</option>
|
||||||
</select>
|
</select>
|
||||||
|
<select
|
||||||
|
v-else-if="enumArray"
|
||||||
|
v-model="editingContent"
|
||||||
|
class="form-select small-select editable-field"
|
||||||
|
@blur="editOFF"
|
||||||
|
>
|
||||||
|
<option v-for="value in enumArray" :key="value">
|
||||||
|
{{ value }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
<input
|
<input
|
||||||
v-else
|
v-else
|
||||||
ref="editField"
|
ref="editField"
|
||||||
@@ -336,6 +346,11 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
},
|
||||||
|
enumArray () {
|
||||||
|
if (this.fields[this.editingField].enumValues)
|
||||||
|
return this.fields[this.editingField].enumValues.replaceAll('\'', '').split(',');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@@ -39,7 +39,73 @@ module.exports = {
|
|||||||
data: 'Dati',
|
data: 'Dati',
|
||||||
properties: 'Proprietà',
|
properties: 'Proprietà',
|
||||||
insert: 'Inserisci',
|
insert: 'Inserisci',
|
||||||
connecting: 'Connessione in corso'
|
connecting: 'Connessione in corso',
|
||||||
|
name: 'Nome',
|
||||||
|
collation: 'Confronto',
|
||||||
|
clear: 'Scarta',
|
||||||
|
options: 'Opzioni',
|
||||||
|
autoRefresh: 'Auto-aggiorna',
|
||||||
|
indexes: 'Indici',
|
||||||
|
foreignKeys: 'Chiavi esterne',
|
||||||
|
length: 'Lunghezza',
|
||||||
|
unsigned: 'Senza segno',
|
||||||
|
default: 'Default',
|
||||||
|
comment: 'Commento',
|
||||||
|
key: 'Chiave | Chiavi',
|
||||||
|
order: 'Ordine',
|
||||||
|
expression: 'Espressione',
|
||||||
|
autoIncrement: 'Auto Incremento',
|
||||||
|
engine: 'Motore',
|
||||||
|
field: 'Campo | Campi',
|
||||||
|
approximately: 'Approssimativamente',
|
||||||
|
total: 'Totali',
|
||||||
|
table: 'Tabella',
|
||||||
|
discard: 'Scarta',
|
||||||
|
stay: 'Resta',
|
||||||
|
author: 'Autore',
|
||||||
|
light: 'Chiaro',
|
||||||
|
dark: 'Scuro',
|
||||||
|
autoCompletion: 'Auto Completamento',
|
||||||
|
application: 'Applicazione',
|
||||||
|
editor: 'Editor',
|
||||||
|
view: 'Vista',
|
||||||
|
definer: 'Definer',
|
||||||
|
algorithm: 'Algoritmo',
|
||||||
|
trigger: 'Trigger | Triggers',
|
||||||
|
storedRoutine: 'Stored routine | Stored routines',
|
||||||
|
scheduler: 'Scheduler | Schedulers',
|
||||||
|
event: 'Evento',
|
||||||
|
parameters: 'Parametri',
|
||||||
|
function: 'Funzione | Funzioni',
|
||||||
|
deterministic: 'Deterministico',
|
||||||
|
context: 'Contesto',
|
||||||
|
export: 'Esporta',
|
||||||
|
returns: 'Ritorna',
|
||||||
|
timing: 'Temporizzazione',
|
||||||
|
state: 'Stato',
|
||||||
|
execution: 'Esecuzione',
|
||||||
|
starts: 'Inizia',
|
||||||
|
ends: 'Finisce',
|
||||||
|
ssl: 'SSL',
|
||||||
|
privateKey: 'Chiave privata',
|
||||||
|
certificate: 'Certificato',
|
||||||
|
caCertificate: 'Certificato CA',
|
||||||
|
ciphers: 'Ciphers',
|
||||||
|
upload: 'Carica',
|
||||||
|
browse: 'Sfoglia',
|
||||||
|
faker: 'Faker',
|
||||||
|
content: 'Contenuto',
|
||||||
|
cut: 'Taglia',
|
||||||
|
copy: 'Copia',
|
||||||
|
paste: 'Incolla',
|
||||||
|
tools: 'Strumenti',
|
||||||
|
variables: 'Variabili',
|
||||||
|
processes: 'Processi',
|
||||||
|
database: 'Database',
|
||||||
|
scratchpad: 'Blocco appunti',
|
||||||
|
array: 'Array',
|
||||||
|
changelog: 'Changelog',
|
||||||
|
format: 'Formatta'
|
||||||
},
|
},
|
||||||
message: {
|
message: {
|
||||||
appWelcome: 'Benvenuto in Antares SQL Client!',
|
appWelcome: 'Benvenuto in Antares SQL Client!',
|
||||||
@@ -71,6 +137,243 @@ module.exports = {
|
|||||||
addNewRow: 'Aggiungi nuova riga',
|
addNewRow: 'Aggiungi nuova riga',
|
||||||
numberOfInserts: 'Numero di insert',
|
numberOfInserts: 'Numero di insert',
|
||||||
openNewTab: 'Apri nuova scheda',
|
openNewTab: 'Apri nuova scheda',
|
||||||
affectedRows: 'Righe interessate'
|
affectedRows: 'Righe interessate',
|
||||||
|
createNewDatabase: 'Crea nuovo database',
|
||||||
|
databaseName: 'Nome database',
|
||||||
|
serverDefault: 'Default del server',
|
||||||
|
deleteDatabase: 'Cancella database',
|
||||||
|
editDatabase: 'Modifica database',
|
||||||
|
clearChanges: 'Scarta modifiche',
|
||||||
|
addNewField: 'Aggiungi nuovo campo',
|
||||||
|
manageIndexes: 'Gestisci indici',
|
||||||
|
manageForeignKeys: 'Gestisci chiavi esterne',
|
||||||
|
allowNull: 'Permetti NULL',
|
||||||
|
zeroFill: 'Riempimento con zero',
|
||||||
|
customValue: 'Varore personalizzato',
|
||||||
|
onUpdate: 'All\'aggiornamento',
|
||||||
|
deleteField: 'Cancella campo',
|
||||||
|
createNewIndex: 'Crea nuovo indice',
|
||||||
|
addToIndex: 'Aggiungi a indice',
|
||||||
|
createNewTable: 'Crea nuova tabella',
|
||||||
|
emptyTable: 'Svuota tabella',
|
||||||
|
deleteTable: 'Cancella tabella',
|
||||||
|
emptyCorfirm: 'Confermi di voler svuotare',
|
||||||
|
unsavedChanges: 'Modifiche non salvate',
|
||||||
|
discardUnsavedChanges: 'Hai modifiche non salvate. Lasciando questa scheda le modifiche saranno scartate.',
|
||||||
|
thereAreNoIndexes: 'Non ci sono indici',
|
||||||
|
thereAreNoForeign: 'Non ci sono chiavi esterne',
|
||||||
|
createNewForeign: 'Crea nuova chiave esterna',
|
||||||
|
referenceTable: 'Tabella di rif.',
|
||||||
|
referenceField: 'Campo di rif.',
|
||||||
|
foreignFields: 'Campi esterni',
|
||||||
|
invalidDefault: 'Default non valido',
|
||||||
|
onDelete: 'All\'eliminazione',
|
||||||
|
applicationTheme: 'Tema applicazione',
|
||||||
|
editorTheme: 'Tema editor',
|
||||||
|
wrapLongLines: 'A capo righe lunghe',
|
||||||
|
selectStatement: 'Dichiarazione select',
|
||||||
|
triggerStatement: 'Dichiarazione trigger',
|
||||||
|
sqlSecurity: 'Sicurezza SQL',
|
||||||
|
updateOption: 'Update option',
|
||||||
|
deleteView: 'Elimina vista',
|
||||||
|
createNewView: 'Crea nuova vista',
|
||||||
|
deleteTrigger: 'Elimina trigger',
|
||||||
|
createNewTrigger: 'Crea nuovo trigger',
|
||||||
|
currentUser: 'Utente attuale',
|
||||||
|
routineBody: 'Corpo della routine',
|
||||||
|
dataAccess: 'Accesso dati',
|
||||||
|
thereAreNoParameters: 'Non ci sono parametri',
|
||||||
|
createNewParameter: 'Crea nuovo parametro',
|
||||||
|
createNewRoutine: 'Crea nuova stored routine',
|
||||||
|
deleteRoutine: 'Elimina stored routine',
|
||||||
|
functionBody: 'Corpo della funzione',
|
||||||
|
createNewFunction: 'Crea nuova funzione',
|
||||||
|
deleteFunction: 'Elimina funzione',
|
||||||
|
schedulerBody: 'Corpo dello scheduler',
|
||||||
|
createNewScheduler: 'Crea nuovo scheduler',
|
||||||
|
deleteScheduler: 'Elimina scheduler',
|
||||||
|
preserveOnCompletion: 'Preserva al completamento',
|
||||||
|
enableSsl: 'Abilita SSL',
|
||||||
|
manualValue: 'Valore manuale',
|
||||||
|
tableFiller: 'Riempitore Tabella',
|
||||||
|
fakeDataLanguage: 'Lingua dati falsi',
|
||||||
|
searchForElements: 'Cerca elementi',
|
||||||
|
selectAll: 'Seleziona tutto',
|
||||||
|
queryDuration: 'Durata query',
|
||||||
|
includeBetaUpdates: 'Includi aggiornamenti beta',
|
||||||
|
setNull: 'Imposta NULL',
|
||||||
|
processesList: 'Lista processi',
|
||||||
|
processInfo: 'Info processo',
|
||||||
|
manageUsers: 'Gestisci utenti',
|
||||||
|
createNewSchema: 'Crea nuovo schema',
|
||||||
|
schemaName: 'Nome schema',
|
||||||
|
editSchema: 'Modifica schema',
|
||||||
|
deleteSchema: 'Elimina schema',
|
||||||
|
markdownSupported: 'Markdown supportato',
|
||||||
|
plantATree: 'Pianta un albero'
|
||||||
|
},
|
||||||
|
faker: {
|
||||||
|
address: 'Indirizzo',
|
||||||
|
commerce: 'Commercio',
|
||||||
|
company: 'Compagnia',
|
||||||
|
database: 'Database',
|
||||||
|
date: 'Data',
|
||||||
|
finance: 'Finanza',
|
||||||
|
git: 'Git',
|
||||||
|
hacker: 'Hacker',
|
||||||
|
internet: 'Internet',
|
||||||
|
lorem: 'Lorem',
|
||||||
|
name: 'Nome',
|
||||||
|
music: 'Musica',
|
||||||
|
phone: 'Telefono',
|
||||||
|
random: 'Casuale',
|
||||||
|
system: 'Sistema',
|
||||||
|
time: 'Tempo',
|
||||||
|
vehicle: 'Veicolo',
|
||||||
|
zipCode: 'Codice zip',
|
||||||
|
zipCodeByState: 'Codice zip per stato',
|
||||||
|
city: 'Città',
|
||||||
|
cityPrefix: 'Prefisso città',
|
||||||
|
citySuffix: 'Suffisso città',
|
||||||
|
streetName: 'Nome strada',
|
||||||
|
streetAddress: 'Indirizzo strada',
|
||||||
|
streetSuffix: 'Suffisso strada',
|
||||||
|
streetPrefix: 'Prefisso strada',
|
||||||
|
secondaryAddress: 'Indirizzo secondario',
|
||||||
|
county: 'Contea',
|
||||||
|
country: 'Nazione',
|
||||||
|
countryCode: 'Codice nazione',
|
||||||
|
state: 'Stato',
|
||||||
|
stateAbbr: 'Abbreviazione stato',
|
||||||
|
latitude: 'Latitudine',
|
||||||
|
longitude: 'Longitudine',
|
||||||
|
direction: 'Direzione',
|
||||||
|
cardinalDirection: 'Direzione cardinale',
|
||||||
|
ordinalDirection: 'Direzione ordinale',
|
||||||
|
nearbyGPSCoordinate: 'Coordinate GPS vicine',
|
||||||
|
timeZone: 'Time zone',
|
||||||
|
color: 'Colore',
|
||||||
|
department: 'Dipartimento',
|
||||||
|
productName: 'Nome prodotto',
|
||||||
|
price: 'Prezzo',
|
||||||
|
productAdjective: 'Aggettivo prodotto',
|
||||||
|
productMaterial: 'Materiale prodotto',
|
||||||
|
product: 'Prodotto',
|
||||||
|
productDescription: 'Descrizione prodotto',
|
||||||
|
suffixes: 'Suffissi',
|
||||||
|
companyName: 'Nome compagnia',
|
||||||
|
companySuffix: 'Suffisso compagnia',
|
||||||
|
catchPhrase: 'Slogan',
|
||||||
|
bs: 'BS',
|
||||||
|
catchPhraseAdjective: 'Aggettivo slogan',
|
||||||
|
catchPhraseDescriptor: 'Descrittore slogan',
|
||||||
|
catchPhraseNoun: 'Sostantivo slogan',
|
||||||
|
bsAdjective: 'Aggettivo BS',
|
||||||
|
bsBuzz: 'Buzz BS',
|
||||||
|
bsNoun: 'Sostantivo BS',
|
||||||
|
column: 'Colonna',
|
||||||
|
type: 'Tipo',
|
||||||
|
collation: 'Confronto',
|
||||||
|
engine: 'Motore',
|
||||||
|
past: 'Passato',
|
||||||
|
future: 'Futuro',
|
||||||
|
between: 'Tra',
|
||||||
|
recent: 'Recente',
|
||||||
|
soon: 'Presto',
|
||||||
|
month: 'Mese',
|
||||||
|
weekday: 'Giorno della settimana',
|
||||||
|
account: 'Account',
|
||||||
|
accountName: 'Nome account',
|
||||||
|
routingNumber: 'Numero di instradamento',
|
||||||
|
mask: 'Maschera',
|
||||||
|
amount: 'Ammontare',
|
||||||
|
transactionType: 'Tipo transazione',
|
||||||
|
currencyCode: 'Codice valuta',
|
||||||
|
currencyName: 'Nome valuta',
|
||||||
|
currencySymbol: 'Simbolo valuta',
|
||||||
|
bitcoinAddress: 'Indirizzo Bitcoin',
|
||||||
|
litecoinAddress: 'Indirizzo Litecoin',
|
||||||
|
creditCardNumber: 'Numero carta di credito',
|
||||||
|
creditCardCVV: 'CVV carta di credito',
|
||||||
|
ethereumAddress: 'Indirizzo Ethereum',
|
||||||
|
iban: 'Iban',
|
||||||
|
bic: 'Bic',
|
||||||
|
transactionDescription: 'Descrizione transazione',
|
||||||
|
branch: 'Ramo',
|
||||||
|
commitEntry: 'Commit entry',
|
||||||
|
commitMessage: 'Messaggio di commit',
|
||||||
|
commitSha: 'SHA del commit',
|
||||||
|
shortSha: 'SHA breve',
|
||||||
|
abbreviation: 'Abbreviazione',
|
||||||
|
adjective: 'Aggettivo',
|
||||||
|
noun: 'Sostantivo',
|
||||||
|
verb: 'Verbo',
|
||||||
|
ingverb: 'Ingverb',
|
||||||
|
phrase: 'Frase',
|
||||||
|
avatar: 'Avatar',
|
||||||
|
email: 'Email',
|
||||||
|
exampleEmail: 'Email di esempio',
|
||||||
|
userName: 'Username',
|
||||||
|
protocol: 'Protocollo',
|
||||||
|
url: 'Url',
|
||||||
|
domainName: 'Nome dominio',
|
||||||
|
domainSuffix: 'Suffisso dominio',
|
||||||
|
domainWord: 'Parola dominio',
|
||||||
|
ip: 'Ip',
|
||||||
|
ipv6: 'Ipv6',
|
||||||
|
userAgent: 'User agent',
|
||||||
|
mac: 'Mac',
|
||||||
|
password: 'Password',
|
||||||
|
word: 'Parola',
|
||||||
|
words: 'Parole',
|
||||||
|
sentence: 'Sentenza',
|
||||||
|
slug: 'Slug',
|
||||||
|
sentences: 'Sentenze',
|
||||||
|
paragraph: 'Paragrafo',
|
||||||
|
paragraphs: 'Paragrafi',
|
||||||
|
text: 'Testo',
|
||||||
|
lines: 'Righe',
|
||||||
|
genre: 'Genere',
|
||||||
|
firstName: 'Nome',
|
||||||
|
lastName: 'Cognome',
|
||||||
|
middleName: 'Secondo nome',
|
||||||
|
findName: 'Nome completo',
|
||||||
|
jobTitle: 'Titolo di lavoro',
|
||||||
|
gender: 'Genere',
|
||||||
|
prefix: 'Prefisso',
|
||||||
|
suffix: 'Suffisso',
|
||||||
|
title: 'Titolo',
|
||||||
|
jobDescriptor: 'Descrittore del lavoro',
|
||||||
|
jobArea: 'Area di lavoro',
|
||||||
|
jobType: 'Tipo di lavoro',
|
||||||
|
phoneNumber: 'Numero di telefono',
|
||||||
|
phoneNumberFormat: 'Formato numeri di telefono',
|
||||||
|
phoneFormats: 'Formati di telefono',
|
||||||
|
number: 'Numero',
|
||||||
|
float: 'Float',
|
||||||
|
arrayElement: 'Elemento array',
|
||||||
|
arrayElements: 'Elementi array',
|
||||||
|
objectElement: 'Elemento object',
|
||||||
|
uuid: 'Uuid',
|
||||||
|
boolean: 'Booleano',
|
||||||
|
image: 'Immagine',
|
||||||
|
locale: 'Localizzazione',
|
||||||
|
alpha: 'Alfabetico',
|
||||||
|
alphaNumeric: 'Alfanumerico',
|
||||||
|
hexaDecimal: 'Esadecimale',
|
||||||
|
fileName: 'Nome file',
|
||||||
|
commonFileName: 'Nome file comune',
|
||||||
|
mimeType: 'Mime type',
|
||||||
|
commonFileType: 'Tipo file comune',
|
||||||
|
commonFileExt: 'Estensione file comune',
|
||||||
|
fileType: 'Tipo file',
|
||||||
|
fileExt: 'Estensione file',
|
||||||
|
directoryPath: 'Percorso directory',
|
||||||
|
filePath: 'Percorso file',
|
||||||
|
semver: 'Semver',
|
||||||
|
manufacturer: 'Produttore',
|
||||||
|
model: 'Modello',
|
||||||
|
fuel: 'Carburante',
|
||||||
|
vin: 'Vin'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -19,6 +19,7 @@ export default class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static updateTableCell (params) {
|
static updateTableCell (params) {
|
||||||
|
delete params.row._id;
|
||||||
return ipcRenderer.invoke('update-table-cell', params);
|
return ipcRenderer.invoke('update-table-cell', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user