Compare commits
273 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be9df93a7e | |||
| 8ff30e426e | |||
| 7cdbef609e | |||
| f6195a468d | |||
| c23bf72d55 | |||
| c02441402b | |||
| b9a8764b55 | |||
| a2374c1981 | |||
| 9cfd5af704 | |||
| a6f473b8ed | |||
| e0a74402cb | |||
| c6e57b278e | |||
| e63f1f8f09 | |||
| 57da9c9885 | |||
| e6a3acf4c2 | |||
| 537869e862 | |||
| ae2ff7b3b1 | |||
| 1db01dbdb1 | |||
| 7988438dc7 | |||
| 3b32823f94 | |||
| 3370c754f2 | |||
| 2d84e5a611 | |||
| 8d5f73849e | |||
| 7a5019164a | |||
| f5733ea2d7 | |||
| 92e13220d8 | |||
| 2a5fdd852a | |||
| 7759fd862f | |||
| ca5dd0ac30 | |||
| 18be29fd88 | |||
| 6ea54a5b0a | |||
| 5d294f6236 | |||
| 5544b6291b | |||
| bf4841bca4 | |||
| 358a641449 | |||
| 7e1ceb69ae | |||
| 939f04ae62 | |||
| 2fc2ac491c | |||
| 20a5a50516 | |||
| 0932f4c537 | |||
| c46c9a4e16 | |||
| a20b4b3339 | |||
| dc302f89c7 | |||
| f5a2d142e2 | |||
| 1020a5820b | |||
| deb13505b8 | |||
| 71c06e31f7 | |||
| a203480a72 | |||
| c0fcd681be | |||
| 7402bb6823 | |||
| 35d791bee4 | |||
| ad4a599800 | |||
| 33db85f03b | |||
| ec5d05fc26 | |||
| face7ecdb5 | |||
| 6035319035 | |||
| e698da71fb | |||
| b466de781a | |||
| e5d583310d | |||
| f72dbf19c2 | |||
| 10538a04b4 | |||
| d71452a397 | |||
| 3f45bfcdd0 | |||
| 545e9863b6 | |||
| a37f2a5240 | |||
| d6b4c0a96b | |||
| d56e917b3f | |||
| 860c811504 | |||
| c93e8c35ec | |||
| 5278e5da0c | |||
| e7e3c307fc | |||
| e9af85038e | |||
| bf04721e36 | |||
| a810dc4204 | |||
| faad82fc34 | |||
| b8ae53db7d | |||
| 1571295ab6 | |||
| d3cc3a92c1 | |||
| 381dc6a535 | |||
| 6b9df571af | |||
| 897547371e | |||
| bf85a922ca | |||
| 00525f6b81 | |||
| 6dd27eb34f | |||
| 0b30386fee | |||
| 1f7f0ea8a2 | |||
| 0ae0cee766 | |||
| 4cbc7f3ae5 | |||
| f1cd0ab689 | |||
| 7f367a1f84 | |||
| 5405b9bf72 | |||
| 75f75d95a6 | |||
| ae5c539e31 | |||
| e7797cedc1 | |||
| f3c3ddd73a | |||
| c201f06103 | |||
| 111a3a678f | |||
| 51c4964003 | |||
| 5fac064a48 | |||
| e84f45ae39 | |||
| 7e119d40a4 | |||
| 22b47d1066 | |||
| ac0ea6a937 | |||
| ed7bfe0c21 | |||
| 55cac14ecf | |||
| 691635c5d1 | |||
| 9209a2d7d3 | |||
| 05b044d965 | |||
| e231a3a41a | |||
| 216614a4b1 | |||
| ae19d14951 | |||
| 7f639361b8 | |||
| ba706b85d3 | |||
| 3b91d921e8 | |||
| 660555d664 | |||
| 3550710f23 | |||
| 1429c29537 | |||
| 95113490f1 | |||
| 1eafdb944a | |||
| a32cd0b2ae | |||
| 249fbf3f96 | |||
| 64877af64a | |||
| ff94e46179 | |||
| 921bd4613a | |||
| 6f4a49ea97 | |||
| 9029fccad4 | |||
| edf3a072c5 | |||
| 0fde8c49a7 | |||
| 767c835a8e | |||
| 38f0223dc0 | |||
| ec707b5af3 | |||
| 462d5e3187 | |||
| 5cc4c07941 | |||
| 20de78f88a | |||
| a63d70ca7e | |||
| 672d6b88b2 | |||
| add1612c92 | |||
| 96b964e609 | |||
| 6b40190097 | |||
| f5b0bc5605 | |||
| 64a58252e5 | |||
| 46571684f6 | |||
| 710022539b | |||
| bc75d559b0 | |||
| a82ee5cc65 | |||
| 6647dd16f8 | |||
| 6f4e1e07f7 | |||
| 5cd951a9c1 | |||
| f492a215b4 | |||
| bbd2d74a28 | |||
| 2b697e21ba | |||
| 3a4e4ecbdc | |||
| 05cbb915d6 | |||
| 26a2bb75fa | |||
| 71b0bb78ec | |||
| 4e4eb39a19 | |||
| b6399c8271 | |||
| eb4a764407 | |||
| 27188eb2c5 | |||
| 57a997adc3 | |||
| a72a03cc3a | |||
| bb185d9e9f | |||
| 0298660714 | |||
| 8bf1dbb10d | |||
| 8e5ef98a7c | |||
| 72bd536aec | |||
| 1a4009a6b2 | |||
| e40357c052 | |||
| 222ea07cf2 | |||
| 6b3f398de3 | |||
| d796fa7ff4 | |||
| 6fdfd8717f | |||
| 81cea4c0f2 | |||
| 6a64633650 | |||
| 21702f1593 | |||
| 32ddb9c4c7 | |||
| 10fc62ceb7 | |||
| d3018a3136 | |||
| f9bcbd588b | |||
| 5c7d2bfd85 | |||
| 788f0ebf77 | |||
| 0eca5dd95d | |||
| 47322b0bbb | |||
| 518a05a6f0 | |||
| 352e426e17 | |||
| 666122f265 | |||
| 61e32f6d95 | |||
| 7aabc8f0be | |||
| a66dc03b99 | |||
| cf5ecb3150 | |||
| 46c365c5cd | |||
| ea76751e4a | |||
| 0bef3f8e71 | |||
| c26c9fae12 | |||
| 446c615bb8 | |||
| c516873541 | |||
| d4326de087 | |||
| eca966bb90 | |||
| 262b4732e3 | |||
| 7f9a30f568 | |||
| a89d2e1365 | |||
| fcd6f6c8fc | |||
| 8313d7f9f1 | |||
| 3a12601103 | |||
| 926949dc89 | |||
| 6b155083ef | |||
| 2b2ecac3ab | |||
| 35e9ff607d | |||
| ae037834f2 | |||
| 3ac24436ba | |||
| 2ca17e826c | |||
| 4fb6128499 | |||
| c359332746 | |||
| 1cd8e8e376 | |||
| 48ec2bdac8 | |||
| 2283e91532 | |||
| 647894ad60 | |||
| 574573abbb | |||
| a735a03cd7 | |||
| 83881a0dac | |||
| c04c6bbd2c | |||
| 42bbbc7ff4 | |||
| 1ecffeda71 | |||
| 92992d1e95 | |||
| bc9df9750f | |||
| 27e70e8031 | |||
| c823b8d19a | |||
| 170ff77eec | |||
| c241f5c562 | |||
| e06d964de4 | |||
| dfdb86de6f | |||
| a37b74f693 | |||
| 398d9f15df | |||
| ab7c2d7a31 | |||
| 090549ff91 | |||
| 10330c6597 | |||
| da2fe6a891 | |||
| 01b88221c5 | |||
| 46d25710b8 | |||
| a40ec7e66b | |||
| c8d2031d24 | |||
| 4f838e0ae3 | |||
| c7cc1b7611 | |||
| bf67a5f13d | |||
| e6bbe66873 | |||
| 1a930acf0a | |||
| a497467137 | |||
| b463416633 | |||
| ccf6240d65 | |||
| 5ccc12019d | |||
| f57fa9aee9 | |||
| 80e841a43d | |||
| fd6df055c0 | |||
| 669d0b9dac | |||
| b9f9501e67 | |||
| 4b1c021871 | |||
| 1f79627dbe | |||
| dc18be07ce | |||
| c6cd865663 | |||
| 86186072ed | |||
| 1216bcf9bf | |||
| 788ea70d32 | |||
| 18de37c4e4 | |||
| aeb81bd97f | |||
| a68660f1ab | |||
| 5abfa85a0e | |||
| 794f43d9ae | |||
| 5db8f11fd6 | |||
| 598674a7e0 | |||
| af17eceb27 | |||
| 90946c582d | |||
| d619e0f961 | |||
| 2c0b76fb3f |
@@ -12,7 +12,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-12, windows-2022, ubuntu-22.04]
|
||||
os: [macos-14, windows-2022, ubuntu-22.04]
|
||||
# os: [macOS-10.15]
|
||||
|
||||
steps:
|
||||
|
||||
@@ -15,7 +15,7 @@ jobs:
|
||||
# os: [windows-2022]
|
||||
# os: [ubuntu-22.04]
|
||||
# os: [windows-2022, ubuntu-22.04]
|
||||
os: [macos-12, windows-2022, ubuntu-22.04]
|
||||
os: [macos-14, windows-2022, ubuntu-22.04]
|
||||
# os: [macOS-10.15]
|
||||
|
||||
steps:
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# os: [ubuntu-22.04, windows-2016]
|
||||
os: [macos-12, windows-2022, ubuntu-22.04]
|
||||
os: [macos-14, windows-2022, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- name: Context
|
||||
@@ -123,6 +123,7 @@ jobs:
|
||||
cp ../dbgate-merged/app/dist/*win_arm64.zip artifacts/dbgate-premium-windows-latest-arm64.zip || true
|
||||
cp ../dbgate-merged/app/dist/*-mac_universal.dmg artifacts/dbgate-premium-latest.dmg || true
|
||||
cp ../dbgate-merged/app/dist/*-mac_x64.dmg artifacts/dbgate-premium-latest-x64.dmg || true
|
||||
cp ../dbgate-merged/app/dist/*-mac_arm64.dmg artifacts/dbgate-premium-latest-arm64.dmg || true
|
||||
|
||||
mv ../dbgate-merged/app/dist/*.exe artifacts/ || true
|
||||
mv ../dbgate-merged/app/dist/*.zip artifacts/ || true
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# os: [ubuntu-22.04, windows-2016]
|
||||
os: [macos-12, windows-2022, ubuntu-22.04]
|
||||
os: [macos-14, windows-2022, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- name: Context
|
||||
@@ -98,6 +98,7 @@ jobs:
|
||||
cp app/dist/*win_arm64.zip artifacts/dbgate-windows-latest-arm64.zip || true
|
||||
cp app/dist/*-mac_universal.dmg artifacts/dbgate-latest.dmg || true
|
||||
cp app/dist/*-mac_x64.dmg artifacts/dbgate-latest-x64.dmg || true
|
||||
cp app/dist/*-mac_arm64.dmg artifacts/dbgate-latest-arm64.dmg || true
|
||||
|
||||
mv app/dist/*.exe artifacts/ || true
|
||||
mv app/dist/*.zip artifacts/ || true
|
||||
|
||||
@@ -4,7 +4,7 @@ on:
|
||||
push:
|
||||
tags:
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+-premium-beta.[0-9]+'
|
||||
# - 'v[0-9]+.[0-9]+.[0-9]+-premium-beta.[0-9]+'
|
||||
- 'v[0-9]+.[0-9]+.[0-9]+-packer-beta.[0-9]+'
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -68,6 +68,12 @@ jobs:
|
||||
cd dbgate-merged
|
||||
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
|
||||
|
||||
- name: Remove dbmodel - should be not published
|
||||
run: |
|
||||
cd ..
|
||||
cd dbgate-merged
|
||||
rm -rf packages/dbmodel
|
||||
|
||||
- name: yarn install
|
||||
run: |
|
||||
cd ..
|
||||
|
||||
@@ -12,16 +12,27 @@ jobs:
|
||||
container: node:18
|
||||
|
||||
steps:
|
||||
- name: Context
|
||||
env:
|
||||
GITHUB_CONTEXT: ${{ toJson(github) }}
|
||||
run: echo "$GITHUB_CONTEXT"
|
||||
- name: Install dependencies for cypress
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install -y xvfb libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libnss3 libxss1 libasound2 libxtst6
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
- name: yarn install
|
||||
run: |
|
||||
yarn install
|
||||
- name: Build packer dist for cypress
|
||||
run: |
|
||||
yarn prepare:packer
|
||||
- name: yarn install cypress
|
||||
run: |
|
||||
cd e2e-tests
|
||||
yarn install
|
||||
- name: Run Cypress tests
|
||||
run: |
|
||||
cd e2e-tests
|
||||
yarn test:ci
|
||||
- name: Integration tests
|
||||
run: |
|
||||
cd integration-tests
|
||||
@@ -84,5 +95,10 @@ jobs:
|
||||
env:
|
||||
CLICKHOUSE_ADMIN_PASSWORD: Pwd2020Db
|
||||
|
||||
oracle:
|
||||
image: gvenzl/oracle-xe:21-slim
|
||||
env:
|
||||
ORACLE_PASSWORD: Pwd2020Db
|
||||
|
||||
# cockroachdb:
|
||||
# image: cockroachdb/cockroach
|
||||
|
||||
+44
-2
@@ -8,11 +8,53 @@ Builds:
|
||||
- linux - application for linux
|
||||
- win - application for Windows
|
||||
|
||||
### Not published
|
||||
### 6.1.0
|
||||
- ADDED: Fulltext search in DB model and connections, highlight searched names
|
||||
- ADDED: Tab preview mode configuration #963
|
||||
- CHANGED: Single-click to open server connection/database + ability to configure this #959
|
||||
- ADDED: Option to align numbers to right in data grid #957
|
||||
- FIXED: Cursor Becomes Stuck When Escaping "Case" #954
|
||||
- ADDED: Postgres GEOGRAPHY types are shown on map, event when executing query #948
|
||||
- FIXED: Error displaying CLOB and NCLOB in Oracle
|
||||
- FIXED: Analysing of foreign keys in Postgres and MS SQL, when the same FKS are used across different schemas
|
||||
- ADDED: Support of views, procedures, functions to Oracle. Added integration tests for Oracle
|
||||
- ADDED: Display "No rows" message, quick add new row
|
||||
- ADDED: Choose default database from list
|
||||
- ADDED: Default database is automatically selected on connect
|
||||
- ADDED: Apple-Silicon-only build for Mac #949
|
||||
- ADDED: Display comment into tables and column list #755
|
||||
|
||||
### 6.0.0
|
||||
- ADDED: Order or filter the indexes for huge tables #922
|
||||
- ADDED: Empty string filters
|
||||
- CHANGED: (Premium) Workflow for new installation (used in Docker and AWS distribution)
|
||||
|
||||
- ADDED: Show stored procedure and function parameters (MySQL, PostgreSQL, SQL Server, MariaDB) #348
|
||||
- FIXED: Selected database has changed when closing database grouped tab #983
|
||||
- ADDED: Add line break option to editor #823
|
||||
- ADDED: Order or filter the indexes for huge tables #922
|
||||
- ADDED: Preview mode for the top bar tab like vscode #767
|
||||
- ADDED: Keyboard navigatioon between connections, databases and tables
|
||||
- FIXED: Fixed some issues in connection search
|
||||
- FIXED: Schema selection in Export does not provide all schemas #924
|
||||
- CHANGED: Standardized Window menu in MacOS app
|
||||
- FIXED: Typecast ::date is treated as a parameter #925
|
||||
- FIXED: App crashes when trying to 'Open Structure' in a readonly connection #926
|
||||
- FIXED: Selected database has changed when closing database grouped tab #938
|
||||
- CHANGED: (Premium) Query designer and Query perspective designer moved to Premium editioin
|
||||
- CHANGED: (Premium) Compare database tool - many improvements, moved to Premium edition
|
||||
- ADDED: (Premium) Export DB model - exporting model to YAML folder, JSON or SQL folder
|
||||
- CHANGED: Model deployer - many improvements, support of rename missing objects
|
||||
- ADDED: (Premium) Premium NPM distribution
|
||||
- CHANGED: (Premium) Amazon Redshift driver moved to Premium edition
|
||||
- ADDED: Generated API documentation https://dbgate.org/docs/apidoc.html
|
||||
- ADDED: NPM distribution now supports all dbgate database connectors, many improvements NPM packages
|
||||
- CHANGED: Optimalized size of NPM plugins (eg. dbgate-plugin-mssql from 1.34 MB to 71 kB)
|
||||
- CHANGED: Unsaved connections are now shown in "Recent and unsaved" folder after disconnect
|
||||
- FIXED: Correctly show focused control, as defined by UX standards
|
||||
- ADDED: Data duplicator - weak references
|
||||
- ADDED: View JSON detail of log messages from export/import jobs and query executions
|
||||
- ADDED: Rename procedure/function context menu
|
||||
- ADDED: Show SQL quick view
|
||||
|
||||
### 5.5.6
|
||||
- FIXED: DbGate process consumes 100% after UI closed - Mac, Linux (#917, #915)
|
||||
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dbgate",
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"private": true,
|
||||
"author": "Jan Prochazka <jenasoft.database@gmail.com>",
|
||||
"description": "Opensource database administration tool",
|
||||
@@ -38,7 +38,8 @@
|
||||
"target": "default",
|
||||
"arch": [
|
||||
"universal",
|
||||
"x64"
|
||||
"x64",
|
||||
"arm64"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ function commandItem(item) {
|
||||
}
|
||||
|
||||
function buildMenu() {
|
||||
let template = _cloneDeepWith(mainMenuDefinition({ editMenu: true }), item => {
|
||||
let template = _cloneDeepWith(mainMenuDefinition({ editMenu: true, isMac: isMac() }), item => {
|
||||
if (item.divider) {
|
||||
return { type: 'separator' };
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = ({ editMenu }) => [
|
||||
module.exports = ({ editMenu, isMac }) => [
|
||||
{
|
||||
label: 'File',
|
||||
submenu: [
|
||||
@@ -24,20 +24,6 @@ module.exports = ({ editMenu }) => [
|
||||
{ command: 'app.disconnect', hideDisabled: true, skipInApp: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'Window',
|
||||
submenu: [
|
||||
{ command: 'tabs.closeTab', hideDisabled: false },
|
||||
{ command: 'tabs.closeAll', hideDisabled: false },
|
||||
{ command: 'tabs.closeTabsWithCurrentDb', hideDisabled: false },
|
||||
{ command: 'tabs.closeTabsButCurrentDb', hideDisabled: false },
|
||||
{ divider: true },
|
||||
{ command: 'app.zoomIn', hideDisabled: true },
|
||||
{ command: 'app.zoomOut', hideDisabled: true },
|
||||
{ command: 'app.zoomReset', hideDisabled: true },
|
||||
],
|
||||
},
|
||||
|
||||
editMenu
|
||||
? {
|
||||
label: 'Edit',
|
||||
@@ -75,6 +61,15 @@ module.exports = ({ editMenu }) => [
|
||||
{ divider: true },
|
||||
{ command: 'theme.changeTheme', hideDisabled: true },
|
||||
{ command: 'settings.show' },
|
||||
{ divider: true },
|
||||
{ command: 'tabs.closeTab', hideDisabled: false },
|
||||
{ command: 'tabs.closeAll', hideDisabled: false },
|
||||
{ command: 'tabs.closeTabsWithCurrentDb', hideDisabled: false },
|
||||
{ command: 'tabs.closeTabsButCurrentDb', hideDisabled: false },
|
||||
{ divider: true },
|
||||
{ command: 'app.zoomIn', hideDisabled: true },
|
||||
{ command: 'app.zoomOut', hideDisabled: true },
|
||||
{ command: 'app.zoomReset', hideDisabled: true },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -94,6 +89,14 @@ module.exports = ({ editMenu }) => [
|
||||
{ command: 'app.resetSettings', hideDisabled: true },
|
||||
],
|
||||
},
|
||||
...(isMac
|
||||
? [
|
||||
{
|
||||
role: 'window',
|
||||
submenu: [{ role: 'minimize' }, { role: 'zoom' }, { type: 'separator' }, { role: 'front' }],
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Help',
|
||||
submenu: [
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
const directory = process.argv[2];
|
||||
const fs = require('fs');
|
||||
|
||||
const volatilePackages = require('./volatilePackages');
|
||||
const apiPackageJson = JSON.parse(fs.readFileSync(`packages/api/package.json`, { encoding: 'utf-8' }));
|
||||
|
||||
const dependencies = {};
|
||||
const optionalDependencies = {};
|
||||
for (const pkg of volatilePackages) {
|
||||
if (pkg == 'msnodesqlv8' && process.platform != 'win32') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (apiPackageJson.dependencies[pkg]) {
|
||||
dependencies[pkg] = apiPackageJson.dependencies[pkg];
|
||||
}
|
||||
if (apiPackageJson.optionalDependencies?.[pkg]) {
|
||||
optionalDependencies[pkg] = apiPackageJson.optionalDependencies[pkg];
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(
|
||||
`${directory}/package.json`,
|
||||
JSON.stringify(
|
||||
{
|
||||
dependencies,
|
||||
optionalDependencies,
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
'utf-8'
|
||||
);
|
||||
@@ -19,6 +19,7 @@ const volatilePackages = [
|
||||
'activedirectory2',
|
||||
'axios',
|
||||
'ssh2',
|
||||
'wkx',
|
||||
];
|
||||
|
||||
module.exports = volatilePackages;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
const { defineConfig } = require('cypress');
|
||||
const killPort = require('kill-port');
|
||||
const { clearTestingData } = require('./e2eTestTools');
|
||||
const waitOn = require('wait-on');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
module.exports = defineConfig({
|
||||
e2e: {
|
||||
setupNodeEvents(on, config) {
|
||||
// implement node event listeners here
|
||||
|
||||
on('before:spec', async details => {
|
||||
await clearTestingData();
|
||||
|
||||
if (config.isInteractive) {
|
||||
await killPort(3000);
|
||||
serverProcess = exec('yarn start');
|
||||
await waitOn({ resources: ['http://localhost:3000'] });
|
||||
serverProcess.stdout.on('data', data => {
|
||||
console.log(data.toString());
|
||||
});
|
||||
serverProcess.stderr.on('data', data => {
|
||||
console.error(data.toString());
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
describe('Initialization', () => {
|
||||
it('successfully loads', () => {
|
||||
cy.visit('http://localhost:3000');
|
||||
cy.contains('Database not selected');
|
||||
});
|
||||
|
||||
it('adds connection', () => {
|
||||
const runOnCI = Cypress.env('runOnCI');
|
||||
|
||||
cy.visit('http://localhost:3000');
|
||||
// cy.get('[data-testid=ConnectionList_buttonNewConnection]').click();
|
||||
cy.get('[data-testid=ConnectionDriverFields_connectionType]').select('MySQL');
|
||||
cy.get('[data-testid=ConnectionDriverFields_user]').clear().type('root');
|
||||
cy.get('[data-testid=ConnectionDriverFields_password]').clear().type('Pwd2020Db');
|
||||
if (runOnCI) {
|
||||
cy.get('[data-testid=ConnectionDriverFields_server]').clear().type('mysql');
|
||||
} else {
|
||||
cy.get('[data-testid=ConnectionDriverFields_port]').clear().type('16004');
|
||||
}
|
||||
cy.get('[data-testid=ConnectionDriverFields_displayName]').clear().type('test-mysql-1');
|
||||
cy.get('[data-testid=ConnectionTab_buttonSave]').click();
|
||||
cy.get('[data-testid=ConnectionTab_buttonConnect]').click();
|
||||
cy.contains('performance_schema');
|
||||
});
|
||||
|
||||
// it('import chinook DB', () => {
|
||||
// cy.visit('http://localhost:3000');
|
||||
// cy.get('[data-testid=ConnectionTab_buttonConnect]').click();
|
||||
// });
|
||||
|
||||
});
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "Using fixtures to represent data",
|
||||
"email": "hello@cypress.io",
|
||||
"body": "Fixtures are a great way to mock data for responses to routes"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// ***********************************************
|
||||
// This example commands.js shows you how to
|
||||
// create various custom commands and overwrite
|
||||
// existing commands.
|
||||
//
|
||||
// For more comprehensive examples of custom
|
||||
// commands please read more here:
|
||||
// https://on.cypress.io/custom-commands
|
||||
// ***********************************************
|
||||
//
|
||||
//
|
||||
// -- This is a parent command --
|
||||
// Cypress.Commands.add('login', (email, password) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a child command --
|
||||
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This is a dual command --
|
||||
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
||||
//
|
||||
//
|
||||
// -- This will overwrite an existing command --
|
||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||
@@ -0,0 +1,20 @@
|
||||
// ***********************************************************
|
||||
// This example support/e2e.js is processed and
|
||||
// loaded automatically before your test files.
|
||||
//
|
||||
// This is a great place to put global configuration and
|
||||
// behavior that modifies Cypress.
|
||||
//
|
||||
// You can change the location of this file or turn off
|
||||
// automatically serving support files with the
|
||||
// 'supportFile' configuration option.
|
||||
//
|
||||
// You can read more here:
|
||||
// https://on.cypress.io/configuration
|
||||
// ***********************************************************
|
||||
|
||||
// Import commands.js using ES2015 syntax:
|
||||
import './commands'
|
||||
|
||||
// Alternatively you can use CommonJS syntax:
|
||||
// require('./commands')
|
||||
@@ -0,0 +1,18 @@
|
||||
version: '3'
|
||||
services:
|
||||
postgres:
|
||||
image: postgres
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_PASSWORD: Pwd2020Db
|
||||
ports:
|
||||
- 16000:5432
|
||||
|
||||
mariadb:
|
||||
image: mariadb
|
||||
command: --default-authentication-plugin=mysql_native_password
|
||||
restart: always
|
||||
ports:
|
||||
- 16004:3306
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=Pwd2020Db
|
||||
@@ -0,0 +1,29 @@
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
|
||||
const baseDir = path.join(os.homedir(), '.dbgate');
|
||||
|
||||
// function createTimeStamp() {
|
||||
// const now = new Date();
|
||||
// const year = now.getFullYear();
|
||||
// const month = String(now.getMonth() + 1).padStart(2, '0'); // měsíc je 0-indexovaný
|
||||
// const day = String(now.getDate()).padStart(2, '0');
|
||||
// const hours = String(now.getHours()).padStart(2, '0');
|
||||
// const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||
// const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||
|
||||
// // Poskládáme datum a čas do názvu souboru
|
||||
// const ts = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
|
||||
// return ts;
|
||||
// }
|
||||
|
||||
function clearTestingData() {
|
||||
if (fs.existsSync(path.join(baseDir, 'connections-e2etests.jsonl'))) {
|
||||
fs.unlinkSync(path.join(baseDir, 'connections-e2etests.jsonl'));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
clearTestingData,
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "e2e-tests",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"license": "GPL",
|
||||
"devDependencies": {
|
||||
"axios": "^1.7.9",
|
||||
"cross-env": "^7.0.3",
|
||||
"cypress": "^13.16.1",
|
||||
"kill-port": "^2.0.1",
|
||||
"start-server-and-test": "^2.0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"cy:open": "cypress open --config experimentalInteractiveRunEvents=true",
|
||||
"cy:run": "cypress run",
|
||||
"cy:run:ci": "cypress run --env runOnCI=true",
|
||||
"start": "cd .. && node packer/build/bundle.js --listen-api --run-e2e-tests",
|
||||
"test:ci": "start-server-and-test start http://localhost:3000 cy:run:ci",
|
||||
"test": "start-server-and-test start http://localhost:3000 cy:run"
|
||||
}
|
||||
}
|
||||
+1363
File diff suppressed because it is too large
Load Diff
@@ -3,9 +3,15 @@ const _ = require('lodash');
|
||||
const fp = require('lodash/fp');
|
||||
const { testWrapper } = require('../tools');
|
||||
const engines = require('../engines');
|
||||
const { getAlterDatabaseScript, extendDatabaseInfo, generateDbPairingId } = require('dbgate-tools');
|
||||
const {
|
||||
getAlterDatabaseScript,
|
||||
extendDatabaseInfo,
|
||||
generateDbPairingId,
|
||||
formatQueryWithoutParams,
|
||||
runCommandOnDriver,
|
||||
} = require('dbgate-tools');
|
||||
|
||||
const initSql = ['CREATE TABLE t1 (id int primary key)', 'CREATE TABLE t2 (id int primary key)'];
|
||||
const initSql = ['CREATE TABLE ~t1 (~id int primary key)', 'CREATE TABLE ~t2 (~id int primary key)'];
|
||||
|
||||
function flatSource(engineCond = x => !x.skipReferences) {
|
||||
return _.flatten(
|
||||
@@ -16,13 +22,14 @@ function flatSource(engineCond = x => !x.skipReferences) {
|
||||
}
|
||||
|
||||
async function testDatabaseDiff(conn, driver, mangle, createObject = null) {
|
||||
await driver.query(conn, `create table t1 (id int not null primary key)`);
|
||||
await runCommandOnDriver(conn, driver, `create table ~t1 (~id int not null primary key)`);
|
||||
|
||||
await driver.query(
|
||||
await runCommandOnDriver(
|
||||
conn,
|
||||
`create table t2 (
|
||||
id int not null primary key,
|
||||
t1_id int null references t1(id)
|
||||
driver,
|
||||
`create table ~t2 (
|
||||
~id int not null primary key,
|
||||
~t1_id int null references ~t1(~id)
|
||||
)`
|
||||
);
|
||||
|
||||
@@ -63,7 +70,7 @@ describe('Alter database', () => {
|
||||
db => {
|
||||
_.remove(db[type], x => x.pureName == 'obj1');
|
||||
},
|
||||
object.create1
|
||||
formatQueryWithoutParams(driver, object.create1)
|
||||
);
|
||||
expect(db[type].length).toEqual(0);
|
||||
})
|
||||
@@ -72,9 +79,9 @@ describe('Alter database', () => {
|
||||
test.each(flatSource(x => x.supportRenameSqlObject))(
|
||||
'Rename object - %s - %s',
|
||||
testWrapper(async (conn, driver, type, object, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
|
||||
|
||||
await driver.query(conn, object.create1, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.create1);
|
||||
|
||||
const structure = extendDatabaseInfo(await driver.analyseFull(conn));
|
||||
|
||||
|
||||
@@ -4,7 +4,12 @@ const fp = require('lodash/fp');
|
||||
const { testWrapper } = require('../tools');
|
||||
const engines = require('../engines');
|
||||
const crypto = require('crypto');
|
||||
const { getAlterTableScript, extendDatabaseInfo, generateDbPairingId } = require('dbgate-tools');
|
||||
const {
|
||||
getAlterTableScript,
|
||||
extendDatabaseInfo,
|
||||
generateDbPairingId,
|
||||
formatQueryWithoutParams,
|
||||
} = require('dbgate-tools');
|
||||
|
||||
function pickImportantTableInfo(engine, table) {
|
||||
const props = ['columnName', 'defaultValue'];
|
||||
@@ -15,7 +20,10 @@ function pickImportantTableInfo(engine, table) {
|
||||
columns: table.columns
|
||||
.filter(x => x.columnName != 'rowid')
|
||||
.map(fp.pick(props))
|
||||
.map(props => _.omitBy(props, x => x == null)),
|
||||
.map(props => _.omitBy(props, x => x == null))
|
||||
.map(props =>
|
||||
_.omitBy(props, (v, k) => k == 'defaultValue' && v == 'NULL' && engine.setNullDefaultInsteadOfDrop)
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,27 +33,36 @@ function checkTableStructure(engine, t1, t2) {
|
||||
}
|
||||
|
||||
async function testTableDiff(engine, conn, driver, mangle) {
|
||||
await driver.query(conn, `create table t0 (id int not null primary key)`);
|
||||
await driver.query(conn, formatQueryWithoutParams(driver, `create table ~t0 (~id int not null primary key)`));
|
||||
|
||||
await driver.query(
|
||||
conn,
|
||||
`create table t1 (
|
||||
col_pk int not null primary key,
|
||||
col_std int,
|
||||
col_def int default 12,
|
||||
${engine.skipReferences ? '' : 'col_fk int references t0(id),'}
|
||||
col_idx int,
|
||||
col_uq int ${engine.skipUnique ? '' : 'unique'} ,
|
||||
col_ref int ${engine.skipUnique ? '' : 'unique'}
|
||||
formatQueryWithoutParams(
|
||||
driver,
|
||||
`create table ~t1 (
|
||||
~col_pk int not null primary key,
|
||||
~col_std int,
|
||||
~col_def int default 12,
|
||||
${engine.skipReferences ? '' : '~col_fk int references ~t0(~id),'}
|
||||
~col_idx int,
|
||||
~col_uq int ${engine.skipUnique ? '' : 'unique'} ,
|
||||
~col_ref int ${engine.skipUnique ? '' : 'unique'}
|
||||
)`
|
||||
)
|
||||
);
|
||||
|
||||
if (!engine.skipIndexes) {
|
||||
await driver.query(conn, `create index idx1 on t1(col_idx)`);
|
||||
await driver.query(conn, formatQueryWithoutParams(driver, `create index ~idx1 on ~t1(~col_idx)`));
|
||||
}
|
||||
|
||||
if (!engine.skipReferences) {
|
||||
await driver.query(conn, `create table t2 (id int not null primary key, fkval int null references t1(col_ref))`);
|
||||
await driver.query(
|
||||
conn,
|
||||
formatQueryWithoutParams(
|
||||
driver,
|
||||
`create table ~t2 (~id int not null primary key, ~fkval int null references ~t1(~col_ref))`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const tget = x => x.tables.find(y => y.pureName == 't1');
|
||||
@@ -175,5 +192,4 @@ describe('Alter table', () => {
|
||||
// });
|
||||
// })
|
||||
// );
|
||||
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ const engines = require('../engines');
|
||||
const stream = require('stream');
|
||||
const { testWrapper } = require('../tools');
|
||||
const dataDuplicator = require('dbgate-api/src/shell/dataDuplicator');
|
||||
const { runCommandOnDriver } = require('dbgate-tools');
|
||||
const { runCommandOnDriver, runQueryOnDriver } = require('dbgate-tools');
|
||||
|
||||
describe('Data duplicator', () => {
|
||||
test.each(engines.filter(x => !x.skipDataDuplicator).map(engine => [engine.label, engine]))(
|
||||
@@ -84,10 +84,10 @@ describe('Data duplicator', () => {
|
||||
],
|
||||
});
|
||||
|
||||
const res1 = await driver.query(conn, `select count(*) as cnt from t1`);
|
||||
const res1 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`));
|
||||
expect(res1.rows[0].cnt.toString()).toEqual('6');
|
||||
|
||||
const res2 = await driver.query(conn, `select count(*) as cnt from t2`);
|
||||
const res2 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t2`));
|
||||
expect(res2.rows[0].cnt.toString()).toEqual('6');
|
||||
})
|
||||
);
|
||||
@@ -145,13 +145,15 @@ describe('Data duplicator', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const res1 = await driver.query(conn, `select count(*) as cnt from t1`);
|
||||
const res1 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`));
|
||||
expect(res1.rows[0].cnt.toString()).toEqual('1');
|
||||
|
||||
const res2 = await driver.query(conn, `select count(*) as cnt from t2`);
|
||||
const res2 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t2`));
|
||||
expect(res2.rows[0].cnt.toString()).toEqual('2');
|
||||
|
||||
const res3 = await driver.query(conn, `select count(*) as cnt from t2 where valfk is not null`);
|
||||
const res3 = await runQueryOnDriver(conn, driver, dmp =>
|
||||
dmp.put(`select count(*) as ~cnt from ~t2 where ~valfk is not null`)
|
||||
);
|
||||
expect(res3.rows[0].cnt.toString()).toEqual('1');
|
||||
})
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@ const tableWriter = require('dbgate-api/src/shell/tableWriter');
|
||||
const copyStream = require('dbgate-api/src/shell/copyStream');
|
||||
const importDatabase = require('dbgate-api/src/shell/importDatabase');
|
||||
const fakeObjectReader = require('dbgate-api/src/shell/fakeObjectReader');
|
||||
const { runQueryOnDriver } = require('dbgate-tools');
|
||||
|
||||
function createImportStream() {
|
||||
const pass = new stream.PassThrough({
|
||||
@@ -37,7 +38,7 @@ describe('DB Import', () => {
|
||||
});
|
||||
await copyStream(reader, writer);
|
||||
|
||||
const res = await driver.query(conn, `select count(*) as cnt from t1`);
|
||||
const res = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`));
|
||||
expect(res.rows[0].cnt.toString()).toEqual('6');
|
||||
})
|
||||
);
|
||||
@@ -65,10 +66,10 @@ describe('DB Import', () => {
|
||||
});
|
||||
await copyStream(reader2, writer2);
|
||||
|
||||
const res1 = await driver.query(conn, `select count(*) as cnt from t1`);
|
||||
const res1 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t1`));
|
||||
expect(res1.rows[0].cnt.toString()).toEqual('6');
|
||||
|
||||
const res2 = await driver.query(conn, `select count(*) as cnt from t2`);
|
||||
const res2 = await runQueryOnDriver(conn, driver, dmp => dmp.put(`select count(*) as ~cnt from ~t2`));
|
||||
expect(res2.rows[0].cnt.toString()).toEqual('6');
|
||||
})
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ const { testWrapper, testWrapperPrepareOnly } = require('../tools');
|
||||
const _ = require('lodash');
|
||||
const engines = require('../engines');
|
||||
const deployDb = require('dbgate-api/src/shell/deployDb');
|
||||
const { databaseInfoFromYamlModel } = require('dbgate-tools');
|
||||
const { databaseInfoFromYamlModel, runQueryOnDriver, formatQueryWithoutParams } = require('dbgate-tools');
|
||||
const generateDeploySql = require('dbgate-api/src/shell/generateDeploySql');
|
||||
const connectUtility = require('dbgate-api/src/utility/connectUtility');
|
||||
|
||||
@@ -69,6 +69,29 @@ function checkStructure(
|
||||
}
|
||||
}
|
||||
|
||||
// function convertObjectText(text, driver) {
|
||||
// if (!text) return undefined;
|
||||
// text = formatQueryWithoutParams(driver, text);
|
||||
// if (driver.dialect.requireFromDual && text.startsWith('create view ') && !text.includes('from')) {
|
||||
// text = text + ' from dual';
|
||||
// }
|
||||
// return text;
|
||||
// }
|
||||
|
||||
// function convertModelToEngine(model, driver) {
|
||||
// return model.map(x => ({
|
||||
// ...x,
|
||||
// text: convertObjectText(x.text, driver),
|
||||
// }));
|
||||
// }
|
||||
|
||||
function convertModelToEngine(model, driver) {
|
||||
return model.map(x => ({
|
||||
...x,
|
||||
text: x.text ? formatQueryWithoutParams(driver, x.text) : undefined,
|
||||
}));
|
||||
}
|
||||
|
||||
async function testDatabaseDeploy(engine, conn, driver, dbModelsYaml, options) {
|
||||
const { testEmptyLastScript, finalCheckAgainstModel, markDeleted, allowDropStatements } = options || {};
|
||||
let index = 0;
|
||||
@@ -83,13 +106,13 @@ async function testDatabaseDeploy(engine, conn, driver, dbModelsYaml, options) {
|
||||
|
||||
for (const loadedDbModel of dbModelsYaml) {
|
||||
if (_.isString(loadedDbModel)) {
|
||||
await driver.script(conn, loadedDbModel);
|
||||
await driver.script(conn, formatQueryWithoutParams(driver, loadedDbModel));
|
||||
} else {
|
||||
const { sql, isEmpty } = await generateDeploySql({
|
||||
systemConnection: conn.isPreparedOnly ? undefined : conn,
|
||||
connection: conn.isPreparedOnly ? conn : undefined,
|
||||
driver,
|
||||
loadedDbModel,
|
||||
loadedDbModel: convertModelToEngine(loadedDbModel, driver),
|
||||
dbdiffOptionsExtra,
|
||||
});
|
||||
console.debug('Generated deploy script:', sql);
|
||||
@@ -106,7 +129,7 @@ async function testDatabaseDeploy(engine, conn, driver, dbModelsYaml, options) {
|
||||
systemConnection: conn.isPreparedOnly ? undefined : conn,
|
||||
connection: conn.isPreparedOnly ? conn : undefined,
|
||||
driver,
|
||||
loadedDbModel,
|
||||
loadedDbModel: convertModelToEngine(loadedDbModel, driver),
|
||||
dbdiffOptionsExtra,
|
||||
});
|
||||
}
|
||||
@@ -117,7 +140,12 @@ async function testDatabaseDeploy(engine, conn, driver, dbModelsYaml, options) {
|
||||
const dbhan = conn.isPreparedOnly ? await connectUtility(driver, conn, 'read') : conn;
|
||||
const structure = await driver.analyseFull(dbhan);
|
||||
if (conn.isPreparedOnly) await driver.close(dbhan);
|
||||
checkStructure(engine, structure, finalCheckAgainstModel ?? _.findLast(dbModelsYaml, x => _.isArray(x)), options);
|
||||
checkStructure(
|
||||
engine,
|
||||
structure,
|
||||
convertModelToEngine(finalCheckAgainstModel ?? _.findLast(dbModelsYaml, x => _.isArray(x)), driver),
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
describe('Deploy database', () => {
|
||||
@@ -339,7 +367,7 @@ describe('Deploy database', () => {
|
||||
],
|
||||
]);
|
||||
|
||||
const res = await driver.query(conn, `select count(*) as cnt from t1`);
|
||||
const res = await runQueryOnDriver(conn, driver, `select count(*) as ~cnt from ~t1`);
|
||||
expect(res.rows[0].cnt.toString()).toEqual('3');
|
||||
})
|
||||
);
|
||||
@@ -386,7 +414,7 @@ describe('Deploy database', () => {
|
||||
],
|
||||
]);
|
||||
|
||||
const res = await driver.query(conn, `select val from t1 where id = 2`);
|
||||
const res = await runQueryOnDriver(conn, driver, `select ~val from ~t1 where ~id = 2`);
|
||||
expect(res.rows[0].val.toString()).toEqual('5');
|
||||
})
|
||||
);
|
||||
@@ -414,8 +442,8 @@ describe('Deploy database', () => {
|
||||
],
|
||||
]);
|
||||
|
||||
await driver.query(conn, `insert into t1 (id) values (1)`);
|
||||
const res = await driver.query(conn, ` select val from t1 where id = 1`);
|
||||
await runQueryOnDriver(conn, driver, `insert into ~t1 (~id) values (1)`);
|
||||
const res = await runQueryOnDriver(conn, driver, ` select ~val from ~t1 where ~id = 1`);
|
||||
expect(res.rows[0].val.toString().substring(0, 2)).toEqual('20');
|
||||
})
|
||||
);
|
||||
@@ -438,7 +466,7 @@ describe('Deploy database', () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
'insert into t1 (id, val) values (1, 1); insert into t1 (id) values (2)',
|
||||
'insert into ~t1 (~id, ~val) values (1, 1); insert into ~t1 (~id) values (2)',
|
||||
[
|
||||
{
|
||||
name: 't1.table.yaml',
|
||||
@@ -452,16 +480,16 @@ describe('Deploy database', () => {
|
||||
},
|
||||
},
|
||||
],
|
||||
'insert into t1 (id) values (3);',
|
||||
'insert into ~t1 (~id) values (3);',
|
||||
]);
|
||||
|
||||
const res1 = await driver.query(conn, `select val from t1 where id = 1`);
|
||||
const res1 = await runQueryOnDriver(conn, driver, `select ~val from ~t1 where ~id = 1`);
|
||||
expect(res1.rows[0].val).toEqual(1);
|
||||
|
||||
const res2 = await driver.query(conn, `select val from t1 where id = 2`);
|
||||
const res2 = await runQueryOnDriver(conn, driver, `select ~val from ~t1 where ~id = 2`);
|
||||
expect(res2.rows[0].val).toEqual(20);
|
||||
|
||||
const res3 = await driver.query(conn, `select val from t1 where id = 3`);
|
||||
const res3 = await runQueryOnDriver(conn, driver, `select ~val from ~t1 where ~id = 3`);
|
||||
expect(res2.rows[0].val).toEqual(20);
|
||||
})
|
||||
);
|
||||
@@ -525,17 +553,17 @@ describe('Deploy database', () => {
|
||||
|
||||
const V1 = {
|
||||
name: 'v1.view.sql',
|
||||
text: 'create view v1 as select * from t1',
|
||||
text: 'create view ~v1 as select * from ~t1',
|
||||
};
|
||||
|
||||
const V1_VARIANT2 = {
|
||||
name: 'v1.view.sql',
|
||||
text: 'create view v1 as select 1 as c1',
|
||||
text: 'create view ~v1 as select ~id + ~id ~idsum from ~t1',
|
||||
};
|
||||
|
||||
const V1_DELETED = {
|
||||
name: '_deleted_v1.view.sql',
|
||||
text: 'create view _deleted_v1 as select * from t1',
|
||||
text: 'create view ~_deleted_v1 as select * from ~t1',
|
||||
};
|
||||
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
@@ -682,15 +710,15 @@ describe('Deploy database', () => {
|
||||
[
|
||||
{
|
||||
name: '1.predeploy.sql',
|
||||
text: 'create table t1 (id int primary key); insert into t1 (id) values (1);',
|
||||
text: 'create table ~t1 (~id int primary key); insert into ~t1 (~id) values (1);',
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
const res1 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM t1');
|
||||
const res1 = await runQueryOnDriver(conn, driver, 'SELECT COUNT(*) AS ~cnt FROM ~t1');
|
||||
expect(res1.rows[0].cnt == 1).toBeTruthy();
|
||||
|
||||
const res2 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM dbgate_deploy_journal');
|
||||
const res2 = await runQueryOnDriver(conn, driver, 'SELECT COUNT(*) AS ~cnt FROM ~dbgate_deploy_journal');
|
||||
expect(res2.rows[0].cnt == 1).toBeTruthy();
|
||||
})
|
||||
);
|
||||
@@ -702,48 +730,53 @@ describe('Deploy database', () => {
|
||||
[
|
||||
{
|
||||
name: 't1.uninstall.sql',
|
||||
text: 'drop table t1',
|
||||
text: 'drop table ~t1',
|
||||
},
|
||||
{
|
||||
name: 't1.install.sql',
|
||||
text: 'create table t1 (id int primary key); insert into t1 (id) values (1)',
|
||||
text: 'create table ~t1 (~id int primary key); insert into ~t1 (~id) values (1)',
|
||||
},
|
||||
{
|
||||
name: 't2.once.sql',
|
||||
text: 'create table t2 (id int primary key); insert into t2 (id) values (1)',
|
||||
text: 'create table ~t2 (~id int primary key); insert into ~t2 (~id) values (1)',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
name: 't1.uninstall.sql',
|
||||
text: 'drop table t1',
|
||||
text: 'drop table ~t1',
|
||||
},
|
||||
{
|
||||
name: 't1.install.sql',
|
||||
text: 'create table t1 (id int primary key, val int); insert into t1 (id, val) values (1, 11)',
|
||||
text: 'create table ~t1 (~id int primary key, ~val int); insert into ~t1 (~id, ~val) values (1, 11)',
|
||||
},
|
||||
{
|
||||
name: 't2.once.sql',
|
||||
text: 'insert into t2 (id) values (2)',
|
||||
text: 'insert into ~t2 (~id) values (2)',
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
const res1 = await driver.query(conn, 'SELECT val from t1 where id = 1');
|
||||
const res1 = await runQueryOnDriver(conn, driver, 'SELECT ~val from ~t1 where ~id = 1');
|
||||
expect(res1.rows[0].val == 11).toBeTruthy();
|
||||
|
||||
const res2 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM t2');
|
||||
const res2 = await runQueryOnDriver(conn, driver, 'SELECT COUNT(*) AS ~cnt FROM ~t2');
|
||||
expect(res2.rows[0].cnt == 1).toBeTruthy();
|
||||
|
||||
const res3 = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM dbgate_deploy_journal');
|
||||
const res3 = await runQueryOnDriver(conn, driver, 'SELECT COUNT(*) AS ~cnt FROM ~dbgate_deploy_journal');
|
||||
expect(res3.rows[0].cnt == 3).toBeTruthy();
|
||||
|
||||
const res4 = await driver.query(conn, "SELECT run_count from dbgate_deploy_journal where name = 't2.once.sql'");
|
||||
const res4 = await runQueryOnDriver(
|
||||
conn,
|
||||
driver,
|
||||
"SELECT ~run_count from ~dbgate_deploy_journal where ~name = 't2.once.sql'"
|
||||
);
|
||||
expect(res4.rows[0].run_count == 1).toBeTruthy();
|
||||
|
||||
const res5 = await driver.query(
|
||||
const res5 = await runQueryOnDriver(
|
||||
conn,
|
||||
"SELECT run_count from dbgate_deploy_journal where name = 't1.install.sql'"
|
||||
driver,
|
||||
"SELECT ~run_count from ~dbgate_deploy_journal where ~name = 't1.install.sql'"
|
||||
);
|
||||
expect(res5.rows[0].run_count == 2).toBeTruthy();
|
||||
})
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const { testWrapper } = require('../tools');
|
||||
const engines = require('../engines');
|
||||
const _ = require('lodash');
|
||||
const { formatQueryWithoutParams, runCommandOnDriver } = require('dbgate-tools');
|
||||
|
||||
const initSql = ['CREATE TABLE t1 (id int primary key)', 'CREATE TABLE t2 (id int primary key)'];
|
||||
const initSql = ['CREATE TABLE ~t1 (~id int primary key)', 'CREATE TABLE ~t2 (~id int primary key)'];
|
||||
|
||||
function flatSource() {
|
||||
return _.flatten(
|
||||
@@ -10,6 +11,14 @@ function flatSource() {
|
||||
);
|
||||
}
|
||||
|
||||
function flatSourceParameters() {
|
||||
return _.flatten(
|
||||
engines.map(engine =>
|
||||
(engine.parameters || []).map(parameter => [engine.label, parameter.testName, parameter, engine])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const obj1Match = expect.objectContaining({
|
||||
pureName: 'obj1',
|
||||
});
|
||||
@@ -26,9 +35,9 @@ describe('Object analyse', () => {
|
||||
test.each(flatSource())(
|
||||
'Full analysis - %s - %s',
|
||||
testWrapper(async (conn, driver, type, object, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
|
||||
|
||||
await driver.query(conn, object.create1, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.create1);
|
||||
const structure = await driver.analyseFull(conn);
|
||||
|
||||
expect(structure[type].length).toEqual(1);
|
||||
@@ -39,11 +48,11 @@ describe('Object analyse', () => {
|
||||
test.each(flatSource())(
|
||||
'Incremental analysis - add - %s - %s',
|
||||
testWrapper(async (conn, driver, type, object, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
|
||||
|
||||
await driver.query(conn, object.create2, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.create2);
|
||||
const structure1 = await driver.analyseFull(conn);
|
||||
await driver.query(conn, object.create1, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.create1);
|
||||
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||
|
||||
expect(structure2[type].length).toEqual(2);
|
||||
@@ -54,12 +63,12 @@ describe('Object analyse', () => {
|
||||
test.each(flatSource())(
|
||||
'Incremental analysis - drop - %s - %s',
|
||||
testWrapper(async (conn, driver, type, object, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
|
||||
|
||||
await driver.query(conn, object.create1, { discardResult: true });
|
||||
await driver.query(conn, object.create2, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.create1);
|
||||
await runCommandOnDriver(conn, driver, object.create2);
|
||||
const structure1 = await driver.analyseFull(conn);
|
||||
await driver.query(conn, object.drop2, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.drop2);
|
||||
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||
|
||||
expect(structure2[type].length).toEqual(1);
|
||||
@@ -70,15 +79,15 @@ describe('Object analyse', () => {
|
||||
test.each(flatSource())(
|
||||
'Create SQL - add - %s - %s',
|
||||
testWrapper(async (conn, driver, type, object, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
|
||||
|
||||
await driver.query(conn, object.create1, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.create1);
|
||||
const structure1 = await driver.analyseFull(conn);
|
||||
await driver.query(conn, object.drop1, { discardResult: true });
|
||||
await runCommandOnDriver(conn, driver, object.drop1);
|
||||
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||
expect(structure2[type].length).toEqual(0);
|
||||
|
||||
await driver.query(conn, structure1[type][0].createSql, { discardResult: true });
|
||||
await driver.script(conn, structure1[type][0].createSql);
|
||||
|
||||
const structure3 = await driver.analyseIncremental(conn, structure2);
|
||||
|
||||
@@ -86,4 +95,45 @@ describe('Object analyse', () => {
|
||||
expect(structure3[type][0]).toEqual(type.includes('views') ? view1Match : obj1Match);
|
||||
})
|
||||
);
|
||||
|
||||
test.each(flatSourceParameters())(
|
||||
'Test parameters simple analyse - %s - %s',
|
||||
testWrapper(async (conn, driver, testName, parameter, engine) => {
|
||||
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
|
||||
for (const sql of engine.parametersOtherSql) await runCommandOnDriver(conn, driver, sql);
|
||||
|
||||
await runCommandOnDriver(conn, driver, parameter.create);
|
||||
const structure = await driver.analyseFull(conn);
|
||||
|
||||
const parameters = structure[parameter.objectTypeField].find(x => x.pureName == 'obj1').parameters;
|
||||
|
||||
expect(parameters.length).toEqual(parameter.list.length);
|
||||
for (let i = 0; i < parameters.length; i += 1) {
|
||||
expect(parameters[i]).toEqual(expect.objectContaining(parameter.list[i]));
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
test.each(flatSourceParameters())(
|
||||
'Test parameters create SQL - %s - %s',
|
||||
testWrapper(async (conn, driver, testName, parameter, engine) => {
|
||||
for (const sql of initSql) await runCommandOnDriver(conn, driver, sql);
|
||||
for (const sql of engine.parametersOtherSql) await runCommandOnDriver(conn, driver, sql);
|
||||
|
||||
await runCommandOnDriver(conn, driver, parameter.create);
|
||||
const structure1 = await driver.analyseFull(conn);
|
||||
await runCommandOnDriver(conn, driver, parameter.drop);
|
||||
|
||||
const obj = structure1[parameter.objectTypeField].find(x => x.pureName == 'obj1');
|
||||
await driver.script(conn, obj.createSql, { discardResult: true });
|
||||
|
||||
const structure2 = await driver.analyseFull(conn);
|
||||
const parameters = structure2[parameter.objectTypeField].find(x => x.pureName == 'obj1').parameters;
|
||||
|
||||
expect(parameters.length).toEqual(parameter.list.length);
|
||||
for (let i = 0; i < parameters.length; i += 1) {
|
||||
expect(parameters[i]).toEqual(expect.objectContaining(parameter.list[i]));
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
const engines = require('../engines');
|
||||
const { splitQuery } = require('dbgate-query-splitter');
|
||||
const { testWrapper } = require('../tools');
|
||||
const { runQueryOnDriver, runCommandOnDriver, formatQueryWithoutParams } = require('dbgate-tools');
|
||||
|
||||
const initSql = [
|
||||
'CREATE TABLE t1 (id int primary key)',
|
||||
'INSERT INTO t1 (id) VALUES (1)',
|
||||
'INSERT INTO t1 (id) VALUES (2)',
|
||||
'CREATE TABLE ~t1 (~id int primary key)',
|
||||
'INSERT INTO ~t1 (~id) VALUES (1)',
|
||||
'INSERT INTO ~t1 (~id) VALUES (2)',
|
||||
];
|
||||
|
||||
expect.extend({
|
||||
@@ -51,7 +52,7 @@ class StreamHandler {
|
||||
function executeStreamItem(driver, conn, sql) {
|
||||
return new Promise(resolve => {
|
||||
const handler = new StreamHandler(resolve);
|
||||
driver.stream(conn, sql, handler);
|
||||
driver.stream(conn, formatQueryWithoutParams(driver, sql), handler);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -68,9 +69,11 @@ describe('Query', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Simple query - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) {
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(sql));
|
||||
}
|
||||
|
||||
const res = await driver.query(conn, 'SELECT id FROM t1 ORDER BY id');
|
||||
const res = await runQueryOnDriver(conn, driver, dmp => dmp.put('SELECT ~id FROM ~t1 ORDER BY ~id'));
|
||||
expect(res.columns).toEqual([
|
||||
expect.objectContaining({
|
||||
columnName: 'id',
|
||||
@@ -91,8 +94,11 @@ describe('Query', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Simple stream query - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
const results = await executeStream(driver, conn, 'SELECT id FROM t1 ORDER BY id');
|
||||
for (const sql of initSql) {
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(sql));
|
||||
}
|
||||
|
||||
const results = await executeStream(driver, conn, 'SELECT ~id FROM ~t1 ORDER BY ~id');
|
||||
expect(results.length).toEqual(1);
|
||||
const res = results[0];
|
||||
|
||||
@@ -104,11 +110,14 @@ describe('Query', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'More queries - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) {
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(sql));
|
||||
}
|
||||
|
||||
const results = await executeStream(
|
||||
driver,
|
||||
conn,
|
||||
'SELECT id FROM t1 ORDER BY id; SELECT id FROM t1 ORDER BY id DESC'
|
||||
'SELECT ~id FROM ~t1 ORDER BY ~id; SELECT ~id FROM ~t1 ORDER BY ~id DESC'
|
||||
);
|
||||
expect(results.length).toEqual(2);
|
||||
|
||||
@@ -128,7 +137,7 @@ describe('Query', () => {
|
||||
const results = await executeStream(
|
||||
driver,
|
||||
conn,
|
||||
'CREATE TABLE t1 (id int primary key); INSERT INTO t1 (id) VALUES (1); INSERT INTO t1 (id) VALUES (2); SELECT id FROM t1 ORDER BY id; '
|
||||
'CREATE TABLE ~t1 (~id int primary key); INSERT INTO ~t1 (~id) VALUES (1); INSERT INTO ~t1 (~id) VALUES (2); SELECT ~id FROM ~t1 ORDER BY ~id; '
|
||||
);
|
||||
expect(results.length).toEqual(1);
|
||||
|
||||
@@ -144,7 +153,7 @@ describe('Query', () => {
|
||||
const results = await executeStream(
|
||||
driver,
|
||||
conn,
|
||||
'CREATE TABLE t1 (id int); INSERT INTO t1 (id) VALUES (1); INSERT INTO t1 (id) VALUES (2) '
|
||||
'CREATE TABLE ~t1 (~id int); INSERT INTO ~t1 (~id) VALUES (1); INSERT INTO ~t1 (~id) VALUES (2) '
|
||||
);
|
||||
expect(results.length).toEqual(0);
|
||||
})
|
||||
@@ -153,16 +162,57 @@ describe('Query', () => {
|
||||
test.each(engines.filter(x => !x.skipDataModifications).map(engine => [engine.label, engine]))(
|
||||
'Save data query - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
for (const sql of initSql) await driver.query(conn, sql, { discardResult: true });
|
||||
for (const sql of initSql) {
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(sql));
|
||||
}
|
||||
|
||||
await driver.script(
|
||||
conn,
|
||||
'INSERT INTO t1 (id) VALUES (3);INSERT INTO t1 (id) VALUES (4);UPDATE t1 SET id=10 WHERE id=1;DELETE FROM t1 WHERE id=2;',
|
||||
formatQueryWithoutParams(
|
||||
driver,
|
||||
'INSERT INTO ~t1 (~id) VALUES (3);INSERT INTO ~t1 (~id) VALUES (4);UPDATE ~t1 SET ~id=10 WHERE ~id=1;DELETE FROM ~t1 WHERE ~id=2;'
|
||||
),
|
||||
{ discardResult: true }
|
||||
);
|
||||
const res = await driver.query(conn, 'SELECT COUNT(*) AS cnt FROM t1');
|
||||
const res = await runQueryOnDriver(conn, driver, dmp => dmp.put('SELECT COUNT(*) AS ~cnt FROM ~t1'));
|
||||
// console.log(res);
|
||||
expect(res.rows[0].cnt == 3).toBeTruthy();
|
||||
})
|
||||
);
|
||||
|
||||
test.each(engines.filter(x => !x.skipDataDuplicator).map(engine => [engine.label, engine]))(
|
||||
'Select scope identity - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await runCommandOnDriver(conn, driver, dmp =>
|
||||
dmp.createTable({
|
||||
pureName: 't1',
|
||||
columns: [
|
||||
{ columnName: 'id', dataType: 'int', notNull: true, autoIncrement: true },
|
||||
{ columnName: 'val', dataType: 'varchar(50)' },
|
||||
],
|
||||
primaryKey: {
|
||||
columns: [{ columnName: 'id' }],
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
const structure = await driver.analyseFull(conn);
|
||||
const table = structure.tables.find(x => x.pureName == 't1');
|
||||
|
||||
let res;
|
||||
if (driver.dialect.requireStandaloneSelectForScopeIdentity) {
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put("INSERT INTO ~t1 (~val) VALUES ('aaa')"));
|
||||
res = await runQueryOnDriver(conn, driver, dmp => dmp.selectScopeIdentity(table));
|
||||
} else {
|
||||
res = await runQueryOnDriver(conn, driver, dmp => {
|
||||
dmp.putCmd("INSERT INTO ~t1 (~val) VALUES ('aaa')");
|
||||
dmp.selectScopeIdentity(table);
|
||||
});
|
||||
}
|
||||
const row = res.rows[0];
|
||||
const keys = Object.keys(row);
|
||||
expect(keys.length).toEqual(1);
|
||||
expect(row[keys[0]] == 1).toBeTruthy();
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('Schema tests', () => {
|
||||
});
|
||||
|
||||
describe('Base analyser test', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
test.each(engines.filter(x => !x.skipIncrementalAnalysis).map(engine => [engine.label, engine]))(
|
||||
'Structure without change - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await baseStructure(conn, driver);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
const { runCommandOnDriver } = require('dbgate-tools');
|
||||
const engines = require('../engines');
|
||||
const { testWrapper } = require('../tools');
|
||||
|
||||
const t1Sql = 'CREATE TABLE t1 (id int not null primary key, val1 varchar(50))';
|
||||
const ix1Sql = 'CREATE index ix1 ON t1(val1, id)';
|
||||
const t1Sql = 'CREATE TABLE ~t1 (~id int not null primary key, ~val1 varchar(50))';
|
||||
const ix1Sql = 'CREATE index ~ix1 ON ~t1(~val1, ~id)';
|
||||
const t2Sql = engine =>
|
||||
`CREATE TABLE t2 (id int not null primary key, val2 varchar(50) ${engine.skipUnique ? '' : 'unique'})`;
|
||||
const t3Sql = 'CREATE TABLE t3 (id int not null primary key, valfk int, foreign key (valfk) references t2(id))';
|
||||
const t4Sql = 'CREATE TABLE t4 (id int not null primary key, valdef int not null default 12)';
|
||||
`CREATE TABLE ~t2 (~id int not null primary key, ~val2 varchar(50) ${engine.skipUnique ? '' : 'unique'})`;
|
||||
const t3Sql = 'CREATE TABLE ~t3 (~id int not null primary key, ~valfk int, foreign key (~valfk) references ~t2(~id))';
|
||||
const t4Sql = 'CREATE TABLE ~t4 (~id int not null primary key, ~valdef int default 12 not null)';
|
||||
// const fkSql = 'ALTER TABLE t3 ADD FOREIGN KEY (valfk) REFERENCES t2(id)'
|
||||
|
||||
const txMatch = (engine, tname, vcolname, nextcol, defaultValue) =>
|
||||
@@ -15,7 +16,7 @@ const txMatch = (engine, tname, vcolname, nextcol, defaultValue) =>
|
||||
columns: [
|
||||
expect.objectContaining({
|
||||
columnName: 'id',
|
||||
dataType: expect.stringMatching(/int.*/i),
|
||||
dataType: expect.stringMatching(/int.*|number/i),
|
||||
...(engine.skipNullability ? {} : { notNull: true }),
|
||||
}),
|
||||
expect.objectContaining({
|
||||
@@ -59,9 +60,10 @@ describe('Table analyse', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Table structure - full analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t1Sql);
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t1Sql));
|
||||
|
||||
const structure = await driver.analyseFull(conn);
|
||||
console.log(JSON.stringify(structure, null, 2));
|
||||
|
||||
expect(structure.tables.length).toEqual(1);
|
||||
expect(structure.tables[0]).toEqual(t1Match(engine));
|
||||
@@ -71,13 +73,13 @@ describe('Table analyse', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Table add - incremental analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t2Sql(engine));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t2Sql(engine)));
|
||||
|
||||
const structure1 = await driver.analyseFull(conn);
|
||||
expect(structure1.tables.length).toEqual(1);
|
||||
expect(structure1.tables[0]).toEqual(t2Match(engine));
|
||||
|
||||
await driver.query(conn, t1Sql);
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t1Sql));
|
||||
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||
|
||||
expect(structure2.tables.length).toEqual(2);
|
||||
@@ -89,14 +91,14 @@ describe('Table analyse', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Table remove - incremental analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t1Sql);
|
||||
await driver.query(conn, t2Sql(engine));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t1Sql));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t2Sql(engine)));
|
||||
const structure1 = await driver.analyseFull(conn);
|
||||
expect(structure1.tables.length).toEqual(2);
|
||||
expect(structure1.tables.find(x => x.pureName == 't1')).toEqual(t1Match(engine));
|
||||
expect(structure1.tables.find(x => x.pureName == 't2')).toEqual(t2Match(engine));
|
||||
|
||||
await driver.query(conn, 'DROP TABLE t2');
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put('DROP TABLE ~t2'));
|
||||
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||
|
||||
expect(structure2.tables.length).toEqual(1);
|
||||
@@ -107,15 +109,14 @@ describe('Table analyse', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Table change - incremental analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t1Sql);
|
||||
await driver.query(conn, t2Sql(engine));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t1Sql));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t2Sql(engine)));
|
||||
const structure1 = await driver.analyseFull(conn);
|
||||
|
||||
if (engine.dbSnapshotBySeconds) await new Promise(resolve => setTimeout(resolve, 1100));
|
||||
|
||||
await driver.query(
|
||||
conn,
|
||||
`ALTER TABLE t2 ADD ${engine.alterTableAddColumnSyntax ? 'COLUMN' : ''} nextcol varchar(50)`
|
||||
await runCommandOnDriver(conn, driver, dmp =>
|
||||
dmp.put(`ALTER TABLE ~t2 ADD ${engine.alterTableAddColumnSyntax ? 'COLUMN' : ''} ~nextcol varchar(50)`)
|
||||
);
|
||||
const structure2 = await driver.analyseIncremental(conn, structure1);
|
||||
|
||||
@@ -130,8 +131,8 @@ describe('Table analyse', () => {
|
||||
test.each(engines.filter(x => !x.skipIndexes).map(engine => [engine.label, engine]))(
|
||||
'Index - full analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t1Sql);
|
||||
await driver.query(conn, ix1Sql);
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t1Sql));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(ix1Sql));
|
||||
const structure = await driver.analyseFull(conn);
|
||||
|
||||
const t1 = structure.tables.find(x => x.pureName == 't1');
|
||||
@@ -145,7 +146,7 @@ describe('Table analyse', () => {
|
||||
test.each(engines.filter(x => !x.skipUnique).map(engine => [engine.label, engine]))(
|
||||
'Unique - full analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t2Sql(engine));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t2Sql(engine)));
|
||||
const structure = await driver.analyseFull(conn);
|
||||
|
||||
const t2 = structure.tables.find(x => x.pureName == 't2');
|
||||
@@ -159,8 +160,8 @@ describe('Table analyse', () => {
|
||||
test.each(engines.filter(x => !x.skipReferences).map(engine => [engine.label, engine]))(
|
||||
'Foreign key - full analysis - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t2Sql(engine));
|
||||
await driver.query(conn, t3Sql);
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t2Sql(engine)));
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t3Sql));
|
||||
// await driver.query(conn, fkSql);
|
||||
|
||||
const structure = await driver.analyseFull(conn);
|
||||
@@ -179,7 +180,7 @@ describe('Table analyse', () => {
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Table structure - default value - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await driver.query(conn, t4Sql);
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put(t4Sql));
|
||||
|
||||
const structure = await driver.analyseFull(conn);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ const _ = require('lodash');
|
||||
const fp = require('lodash/fp');
|
||||
const engines = require('../engines');
|
||||
const { testWrapper } = require('../tools');
|
||||
const { extendDatabaseInfo } = require('dbgate-tools');
|
||||
const { extendDatabaseInfo, runCommandOnDriver } = require('dbgate-tools');
|
||||
|
||||
function createExpector(value) {
|
||||
return _.cloneDeepWith(value, x => {
|
||||
@@ -25,7 +25,7 @@ function checkTableStructure2(t1, t2) {
|
||||
}
|
||||
|
||||
async function testTableCreate(conn, driver, table) {
|
||||
await driver.query(conn, `create table t0 (id int not null primary key)`);
|
||||
await runCommandOnDriver(conn, driver, dmp => dmp.put('create table ~t0 (~id int not null primary key)'));
|
||||
|
||||
const dmp = driver.createDumper();
|
||||
const table1 = {
|
||||
|
||||
@@ -70,3 +70,9 @@ services:
|
||||
# - cockroachdb
|
||||
# restart: on-failure
|
||||
|
||||
oracle:
|
||||
image: gvenzl/oracle-xe:21-slim
|
||||
environment:
|
||||
ORACLE_PASSWORD: Pwd2020Db
|
||||
ports:
|
||||
- 15006:1521
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const views = {
|
||||
type: 'views',
|
||||
create1: 'CREATE VIEW obj1 AS SELECT id FROM t1',
|
||||
create2: 'CREATE VIEW obj2 AS SELECT id FROM t2',
|
||||
drop1: 'DROP VIEW obj1',
|
||||
drop2: 'DROP VIEW obj2',
|
||||
create1: 'CREATE VIEW ~obj1 AS SELECT ~id FROM ~t1',
|
||||
create2: 'CREATE VIEW ~obj2 AS SELECT ~id FROM ~t2',
|
||||
drop1: 'DROP VIEW ~obj1',
|
||||
drop2: 'DROP VIEW ~obj2',
|
||||
};
|
||||
const matviews = {
|
||||
type: 'matviews',
|
||||
@@ -28,7 +28,16 @@ const engines = [
|
||||
port: 15001,
|
||||
},
|
||||
// skipOnCI: true,
|
||||
objects: [views],
|
||||
objects: [
|
||||
views,
|
||||
{
|
||||
type: 'procedures',
|
||||
create1: 'CREATE PROCEDURE obj1() BEGIN SELECT * FROM t1; END',
|
||||
create2: 'CREATE PROCEDURE obj2() BEGIN SELECT * FROM t2; END',
|
||||
drop1: 'DROP PROCEDURE obj1',
|
||||
drop2: 'DROP PROCEDURE obj2',
|
||||
},
|
||||
],
|
||||
dbSnapshotBySeconds: true,
|
||||
dumpFile: 'data/chinook-mysql.sql',
|
||||
dumpChecks: [
|
||||
@@ -37,6 +46,68 @@ const engines = [
|
||||
res: '25',
|
||||
},
|
||||
],
|
||||
parametersOtherSql: ['CREATE PROCEDURE obj2(a int, b int) BEGIN SELECT * FROM t1; END'],
|
||||
parameters: [
|
||||
{
|
||||
testName: 'simple',
|
||||
create: 'CREATE PROCEDURE obj1(a int) BEGIN SELECT * FROM t1; END',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: 'a',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'int',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
testName: 'paramTypes',
|
||||
create: 'CREATE PROCEDURE obj1(a int, b varchar(50), c numeric(10,2)) BEGIN SELECT * FROM t1; END',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: 'a',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'int',
|
||||
},
|
||||
{
|
||||
parameterName: 'b',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'varchar(50)',
|
||||
},
|
||||
{
|
||||
parameterName: 'c',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'decimal(10,2)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
testName: 'paramModes',
|
||||
create: 'CREATE PROCEDURE obj1(IN a int, OUT b int, INOUT c int) BEGIN SELECT * FROM t1; END',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: 'a',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'int',
|
||||
},
|
||||
{
|
||||
parameterName: 'b',
|
||||
parameterMode: 'OUT',
|
||||
dataType: 'int',
|
||||
},
|
||||
{
|
||||
parameterName: 'c',
|
||||
parameterMode: 'INOUT',
|
||||
dataType: 'int',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'MariaDB',
|
||||
@@ -105,6 +176,94 @@ const engines = [
|
||||
res: '25',
|
||||
},
|
||||
],
|
||||
|
||||
parametersOtherSql: ['CREATE PROCEDURE obj2(a integer, b integer) LANGUAGE SQL AS $$ select * from t1 $$'],
|
||||
parameters: [
|
||||
{
|
||||
testName: 'simple',
|
||||
create: 'CREATE PROCEDURE obj1(a integer) LANGUAGE SQL AS $$ select * from t1 $$',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: 'a',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'integer',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
testName: 'dataTypes',
|
||||
create:
|
||||
'CREATE PROCEDURE obj1(a integer, b varchar(20), c numeric(18,2)) LANGUAGE SQL AS $$ select * from t1 $$',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: 'a',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'integer',
|
||||
},
|
||||
{
|
||||
parameterName: 'b',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'varchar',
|
||||
},
|
||||
{
|
||||
parameterName: 'c',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'numeric',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
testName: 'paramModes',
|
||||
create: 'CREATE PROCEDURE obj1(IN a integer, INOUT b integer) LANGUAGE SQL AS $$ select * from t1 $$',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: 'a',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'integer',
|
||||
},
|
||||
{
|
||||
parameterName: 'b',
|
||||
parameterMode: 'INOUT',
|
||||
dataType: 'integer',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
testName: 'paramModesFunction',
|
||||
objectTypeField: 'functions',
|
||||
create: `
|
||||
create or replace function obj1(
|
||||
out min_len int,
|
||||
out max_len int)
|
||||
language plpgsql
|
||||
as $$
|
||||
begin
|
||||
select min(id),
|
||||
max(id)
|
||||
into min_len, max_len
|
||||
from t1;
|
||||
end;$$`,
|
||||
drop: 'DROP FUNCTION obj1',
|
||||
list: [
|
||||
{
|
||||
parameterName: 'min_len',
|
||||
parameterMode: 'OUT',
|
||||
dataType: 'integer',
|
||||
},
|
||||
{
|
||||
parameterName: 'max_len',
|
||||
parameterMode: 'OUT',
|
||||
dataType: 'integer',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
label: 'SQL Server',
|
||||
@@ -129,6 +288,63 @@ const engines = [
|
||||
drop2: 'DROP PROCEDURE obj2',
|
||||
},
|
||||
],
|
||||
parametersOtherSql: ['CREATE PROCEDURE obj2 (@p1 int, @p2 int) AS SELECT id from t1'],
|
||||
parameters: [
|
||||
{
|
||||
testName: 'simple',
|
||||
create: 'CREATE PROCEDURE obj1 (@param1 int) AS SELECT id from t1',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: '@param1',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'int',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
testName: 'dataTypes',
|
||||
create: 'CREATE PROCEDURE obj1 (@p1 bit, @p2 nvarchar(20), @p3 decimal(18,2), @p4 float) AS SELECT id from t1',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: '@p1',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'bit',
|
||||
},
|
||||
{
|
||||
parameterName: '@p2',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'nvarchar(20)',
|
||||
},
|
||||
{
|
||||
parameterName: '@p3',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'decimal(18,2)',
|
||||
},
|
||||
{
|
||||
parameterName: '@p4',
|
||||
parameterMode: 'IN',
|
||||
dataType: 'float',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
testName: 'outputParam',
|
||||
create: 'CREATE PROCEDURE obj1 (@p1 int OUTPUT) AS SELECT id from t1',
|
||||
drop: 'DROP PROCEDURE obj1',
|
||||
objectTypeField: 'procedures',
|
||||
list: [
|
||||
{
|
||||
parameterName: '@p1',
|
||||
parameterMode: 'OUT',
|
||||
dataType: 'int',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
supportSchemas: true,
|
||||
supportRenameSqlObject: true,
|
||||
defaultSchemaName: 'dbo',
|
||||
@@ -184,6 +400,42 @@ const engines = [
|
||||
dbSnapshotBySeconds: true,
|
||||
skipChangeColumn: true,
|
||||
},
|
||||
{
|
||||
label: 'Oracle',
|
||||
connection: {
|
||||
engine: 'oracle@dbgate-plugin-oracle',
|
||||
password: 'Pwd2020Db',
|
||||
user: 'system',
|
||||
server: 'oracle',
|
||||
port: 1521,
|
||||
serviceName: 'xe',
|
||||
},
|
||||
local: {
|
||||
server: 'localhost',
|
||||
port: 15006,
|
||||
},
|
||||
skipOnCI: false,
|
||||
dbSnapshotBySeconds: true,
|
||||
setNullDefaultInsteadOfDrop: true,
|
||||
skipIncrementalAnalysis: true,
|
||||
objects: [
|
||||
views,
|
||||
{
|
||||
type: 'procedures',
|
||||
create1: 'CREATE PROCEDURE ~obj1 AS BEGIN SELECT ~id FROM ~t1 END',
|
||||
create2: 'CREATE PROCEDURE ~obj2 AS BEGIN SELECT ~id FROM ~t2 END',
|
||||
drop1: 'DROP PROCEDURE ~obj1',
|
||||
drop2: 'DROP PROCEDURE ~obj2',
|
||||
},
|
||||
{
|
||||
type: 'functions',
|
||||
create1: 'CREATE FUNCTION ~obj1 RETURN NUMBER IS v_count NUMBER; \n BEGIN SELECT COUNT(*) INTO v_count FROM ~t1;\n RETURN v_count;\n END ~obj1',
|
||||
create2: 'CREATE FUNCTION ~obj2 RETURN NUMBER IS v_count NUMBER; \n BEGIN SELECT COUNT(*) INTO v_count FROM ~t2;\n RETURN v_count;\n END ~obj2',
|
||||
drop1: 'DROP FUNCTION ~obj1',
|
||||
drop2: 'DROP FUNCTION ~obj2',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const filterLocal = [
|
||||
@@ -191,10 +443,11 @@ const filterLocal = [
|
||||
'-MySQL',
|
||||
'-MariaDB',
|
||||
'-PostgreSQL',
|
||||
'SQL Server',
|
||||
'-SQL Server',
|
||||
'-SQLite',
|
||||
'-CockroachDB',
|
||||
'-ClickHouse',
|
||||
'Oracle',
|
||||
];
|
||||
|
||||
const enginesPostgre = engines.filter(x => x.label == 'PostgreSQL');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dbgate-integration-tests",
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"homepage": "https://dbgate.org/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
const requireEngineDriver = require('dbgate-api/src/utility/requireEngineDriver');
|
||||
const crypto = require('crypto');
|
||||
|
||||
function randomDbName() {
|
||||
function randomDbName(dialect) {
|
||||
const generatedKey = crypto.randomBytes(6);
|
||||
const newKey = generatedKey.toString('hex');
|
||||
return `db${newKey}`;
|
||||
const res = `db${newKey}`;
|
||||
if (dialect.upperCaseAllDbObjectNames) return res.toUpperCase();
|
||||
return res;
|
||||
}
|
||||
|
||||
function extractConnection(engine) {
|
||||
@@ -32,12 +34,14 @@ async function connect(engine, database) {
|
||||
return conn;
|
||||
} else {
|
||||
const conn = await driver.connect(connection);
|
||||
await driver.query(conn, `CREATE DATABASE ${database}`);
|
||||
const dmp = driver.createDumper();
|
||||
dmp.createDatabase(database);
|
||||
await driver.query(conn, dmp.s);
|
||||
await driver.close(conn);
|
||||
|
||||
const res = await driver.connect({
|
||||
...connection,
|
||||
database,
|
||||
database: (driver.dialect.userDatabaseNamePrefix ?? '') + database,
|
||||
});
|
||||
return res;
|
||||
}
|
||||
@@ -55,12 +59,14 @@ async function prepareConnection(engine, database) {
|
||||
};
|
||||
} else {
|
||||
const conn = await driver.connect(connection);
|
||||
await driver.query(conn, `CREATE DATABASE ${database}`);
|
||||
const dmp = driver.createDumper();
|
||||
dmp.createDatabase(database);
|
||||
await driver.query(conn, dmp.s);
|
||||
await driver.close(conn);
|
||||
|
||||
return {
|
||||
...connection,
|
||||
database,
|
||||
database: (driver.dialect.userDatabaseNamePrefix ?? '') + database,
|
||||
isPreparedOnly: true,
|
||||
};
|
||||
}
|
||||
@@ -71,7 +77,7 @@ const testWrapper =
|
||||
async (label, ...other) => {
|
||||
const engine = other[other.length - 1];
|
||||
const driver = requireEngineDriver(engine.connection);
|
||||
const conn = await connect(engine, randomDbName());
|
||||
const conn = await connect(engine, randomDbName(driver.dialect));
|
||||
try {
|
||||
await body(conn, driver, ...other);
|
||||
} finally {
|
||||
@@ -84,7 +90,7 @@ const testWrapperPrepareOnly =
|
||||
async (label, ...other) => {
|
||||
const engine = other[other.length - 1];
|
||||
const driver = requireEngineDriver(engine.connection);
|
||||
const conn = await prepareConnection(engine, randomDbName());
|
||||
const conn = await prepareConnection(engine, randomDbName(driver.dialect));
|
||||
await body(conn, driver, ...other);
|
||||
};
|
||||
|
||||
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"version": "5.5.7-alpha.60",
|
||||
"version": "6.1.0",
|
||||
"name": "dbgate-all",
|
||||
"workspaces": [
|
||||
"packages/*",
|
||||
@@ -52,8 +52,9 @@
|
||||
"resetPackagedPlugins": "node resetPackagedPlugins",
|
||||
"prettier": "prettier --write packages/api/src && prettier --write packages/datalib/src && prettier --write packages/filterparser/src && prettier --write packages/sqltree/src && prettier --write packages/tools/src && prettier --write packages/types && prettier --write packages/web/src && prettier --write app/src",
|
||||
"copy:docker:build": "copyfiles packages/api/dist/* docker -f && copyfiles packages/web/public/* docker -u 2 && copyfiles \"packages/web/public/**/*\" docker -u 2 && copyfiles \"plugins/dist/**/*\" docker/plugins -u 2",
|
||||
"copy:packer:build": "copyfiles packages/api/dist/* packer/build -f && copyfiles packages/web/public/* packer/build -u 2 && copyfiles \"packages/web/public/**/*\" packer/build -u 2 && copyfiles \"plugins/dist/**/*\" packer/build/plugins -u 2 && copyfiles packer/install-packages.sh packer/build -f",
|
||||
"install:drivers:docker": "cd docker && yarn init --yes && yarn add better-sqlite3 && yarn add oracledb && cd ..",
|
||||
"copy:packer:build": "copyfiles packages/api/dist/* packer/build -f && copyfiles packages/web/public/* packer/build -u 2 && copyfiles \"packages/web/public/**/*\" packer/build -u 2 && copyfiles \"plugins/dist/**/*\" packer/build/plugins -u 2 && copyfiles packer/install-packages.sh packer/build -f && yarn install:drivers:packer",
|
||||
"install:drivers:docker": "node common/defineVolatileDependencies.js docker && cd docker && yarn install && cd ..",
|
||||
"install:drivers:packer": "node common/defineVolatileDependencies.js packer/build",
|
||||
"prepare:docker": "yarn plugins:copydist && yarn build:web && yarn build:api && yarn copy:docker:build && yarn install:drivers:docker",
|
||||
"prepare:packer": "yarn plugins:copydist && yarn build:web && yarn build:api && yarn copy:packer:build",
|
||||
"start": "concurrently --kill-others-on-fail \"yarn start:api\" \"yarn start:web\"",
|
||||
|
||||
Vendored
+29
-42
@@ -1,60 +1,47 @@
|
||||
DEVMODE=1
|
||||
|
||||
CONNECTIONS=mysql,postgres,postgres1,mongo,mongo2,mysqlssh,sqlite,relational
|
||||
CONNECTIONS=mysql,postgres,mongo,redis,mssql,oracle
|
||||
|
||||
LABEL_mysql=MySql localhost
|
||||
SERVER_mysql=localhost
|
||||
LABEL_mysql=MySql
|
||||
SERVER_mysql=dbgatedckstage1.sprinx.cz
|
||||
USER_mysql=root
|
||||
PASSWORD_mysql=test
|
||||
PORT_mysql=3307
|
||||
PASSWORD_mysql=Pwd2020Db
|
||||
PORT_mysql=3306
|
||||
ENGINE_mysql=mysql@dbgate-plugin-mysql
|
||||
|
||||
LABEL_postgres=Postgres localhost
|
||||
SERVER_postgres=localhost
|
||||
LABEL_postgres=Postgres
|
||||
SERVER_postgres=dbgatedckstage1.sprinx.cz
|
||||
USER_postgres=postgres
|
||||
PASSWORD_postgres=Pwd2020Db
|
||||
PORT_postgres=5432
|
||||
ENGINE_postgres=postgres@dbgate-plugin-postgres
|
||||
|
||||
LABEL_postgres1=Postgres localhost test DB
|
||||
SERVER_postgres1=localhost
|
||||
USER_postgres1=postgres
|
||||
PASSWORD_postgres1=Pwd2020Db
|
||||
PORT_postgres1=5432
|
||||
ENGINE_postgres1=postgres@dbgate-plugin-postgres
|
||||
DATABASE_postgres1=test
|
||||
|
||||
LABEL_mongo=Mongo URL
|
||||
URL_mongo=mongodb://localhost:27017
|
||||
LABEL_mongo=Mongo
|
||||
SERVER_mongo=dbgatedckstage1.sprinx.cz
|
||||
USER_mongo=root
|
||||
PASSWORD_mongo=Pwd2020Db
|
||||
PORT_mongo=27017
|
||||
ENGINE_mongo=mongo@dbgate-plugin-mongo
|
||||
|
||||
LABEL_mongo2=Mongo Server
|
||||
SERVER_mongo2=localhost
|
||||
ENGINE_mongo2=mongo@dbgate-plugin-mongo
|
||||
LABEL_redis=Redis
|
||||
SERVER_redis=dbgatedckstage1.sprinx.cz
|
||||
ENGINE_redis=redis@dbgate-plugin-redis
|
||||
PORT_redis=6379
|
||||
|
||||
LABEL_mysqlssh=MySql SSH
|
||||
SERVER_mysqlssh=localhost
|
||||
USER_mysqlssh=root
|
||||
PASSWORD_mysqlssh=xxx
|
||||
PORT_mysqlssh=3316
|
||||
ENGINE_mysqlssh=mysql@dbgate-plugin-mysql
|
||||
USE_SSH_mysqlssh=1
|
||||
SSH_HOST_mysqlssh=demo.dbgate.org
|
||||
SSH_PORT_mysqlssh=22
|
||||
SSH_MODE_mysqlssh=userPassword
|
||||
SSH_LOGIN_mysqlssh=root
|
||||
SSH_PASSWORD_mysqlssh=xxx
|
||||
LABEL_mssql=SQL Server
|
||||
SERVER_mssql=dbgatedckstage1.sprinx.cz
|
||||
USER_mssql=sa
|
||||
PASSWORD_mssql=Pwd2020Db
|
||||
PORT_mssql=1433
|
||||
ENGINE_mssql=mssql@dbgate-plugin-mssql
|
||||
|
||||
LABEL_sqlite=sqlite
|
||||
FILE_sqlite=/home/jena/.dbgate/files/sqlite/feeds.sqlite
|
||||
ENGINE_sqlite=sqlite@dbgate-plugin-sqlite
|
||||
|
||||
LABEL_relational=Relational dataset repo
|
||||
SERVER_relational=relational.fit.cvut.cz
|
||||
USER_relational=guest
|
||||
PASSWORD_relational=relational
|
||||
ENGINE_relational=mariadb@dbgate-plugin-mysql
|
||||
READONLY_relational=1
|
||||
LABEL_oracle=Oracle
|
||||
SERVER_oracle=dbgatedckstage1.sprinx.cz
|
||||
USER_oracle=system
|
||||
PASSWORD_oracle=Pwd2020Db
|
||||
PORT_oracle=1521
|
||||
ENGINE_oracle=oracle@dbgate-plugin-oracle
|
||||
SERVICE_NAME_oracle=xe
|
||||
|
||||
# SETTINGS_dataGrid.showHintColumns=1
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -12,6 +12,6 @@ DBCONFIG_mysql=[{"name":"Chinook","connectionColor":"cyan"}]
|
||||
|
||||
|
||||
SINGLE_CONNECTION=mysql
|
||||
SINGLE_DATABASE=Chinook
|
||||
# SINGLE_DATABASE=Chinook
|
||||
|
||||
PERMISSIONS=files/charts/read
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "dbgate-api",
|
||||
"main": "src/index.js",
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"homepage": "https://dbgate.org/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -29,10 +29,10 @@
|
||||
"compare-versions": "^3.6.0",
|
||||
"cors": "^2.8.5",
|
||||
"cross-env": "^6.0.3",
|
||||
"dbgate-datalib": "^5.0.0-alpha.1",
|
||||
"dbgate-datalib": "^6.0.0-alpha.1",
|
||||
"dbgate-query-splitter": "^4.11.2",
|
||||
"dbgate-sqltree": "^5.0.0-alpha.1",
|
||||
"dbgate-tools": "^5.0.0-alpha.1",
|
||||
"dbgate-sqltree": "^6.0.0-alpha.1",
|
||||
"dbgate-tools": "^6.0.0-alpha.1",
|
||||
"debug": "^4.3.4",
|
||||
"diff": "^5.0.0",
|
||||
"diff2html": "^3.4.13",
|
||||
@@ -81,7 +81,7 @@
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "^9.0.11",
|
||||
"@types/lodash": "^4.14.149",
|
||||
"dbgate-types": "^5.0.0-alpha.1",
|
||||
"dbgate-types": "^6.0.0-alpha.1",
|
||||
"env-cmd": "^10.1.0",
|
||||
"jsdoc-to-markdown": "^9.0.5",
|
||||
"node-loader": "^1.0.2",
|
||||
|
||||
@@ -230,7 +230,7 @@ class LoginsProvider extends AuthProviderBase {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
return { error: 'Invalid credentials' };
|
||||
}
|
||||
|
||||
@@ -271,11 +271,10 @@ function hasEnvLogins() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function detectEnvAuthProvider() {
|
||||
function detectEnvAuthProviderCore() {
|
||||
if (process.env.AUTH_PROVIDER) {
|
||||
return process.env.AUTH_PROVIDER;
|
||||
}
|
||||
|
||||
if (process.env.STORAGE_DATABASE) {
|
||||
return 'denyall';
|
||||
}
|
||||
@@ -291,6 +290,14 @@ function detectEnvAuthProvider() {
|
||||
return 'none';
|
||||
}
|
||||
|
||||
function detectEnvAuthProvider() {
|
||||
const authProvider = detectEnvAuthProviderCore();
|
||||
if (process.env.BASIC_AUTH && authProvider != 'logins' && authProvider != 'ad') {
|
||||
throw new Error(`BASIC_AUTH is not supported with ${authProvider} auth provider`);
|
||||
}
|
||||
return authProvider;
|
||||
}
|
||||
|
||||
function createEnvAuthProvider() {
|
||||
const authProvider = detectEnvAuthProvider();
|
||||
switch (authProvider) {
|
||||
|
||||
@@ -9,6 +9,7 @@ const _ = require('lodash');
|
||||
const AsyncLock = require('async-lock');
|
||||
const jwt = require('jsonwebtoken');
|
||||
|
||||
const processArgs = require('../utility/processArgs');
|
||||
const currentVersion = require('../currentVersion');
|
||||
const platformInfo = require('../utility/platformInfo');
|
||||
const connections = require('../controllers/connections');
|
||||
@@ -62,6 +63,8 @@ module.exports = {
|
||||
const logoutUrl = storageConnectionError ? null : await authProvider.getLogoutUrl();
|
||||
const adminConfig = storageConnectionError ? null : await storage.readConfig({ group: 'admin' });
|
||||
|
||||
storage.startRefreshLicense();
|
||||
|
||||
const isAdminPasswordMissing = !!(
|
||||
process.env.STORAGE_DATABASE &&
|
||||
!process.env.ADMIN_PASSWORD &&
|
||||
@@ -81,7 +84,8 @@ module.exports = {
|
||||
isElectron: platformInfo.isElectron,
|
||||
isLicenseValid,
|
||||
isLicenseExpired: checkedLicense?.isExpired,
|
||||
trialDaysLeft: checkedLicense?.isGeneratedTrial && !checkedLicense?.isExpired ? checkedLicense?.daysLeft : null,
|
||||
trialDaysLeft:
|
||||
checkedLicense?.licenseTypeObj?.isTrial && !checkedLicense?.isExpired ? checkedLicense?.daysLeft : null,
|
||||
checkedLicense,
|
||||
configurationError,
|
||||
logoutUrl,
|
||||
@@ -99,7 +103,10 @@ module.exports = {
|
||||
adminPasswordState: adminConfig?.adminPasswordState,
|
||||
storageDatabase: process.env.STORAGE_DATABASE,
|
||||
logsFilePath: getLogsFilePath(),
|
||||
connectionsFilePath: path.join(datadir(), 'connections.jsonl'),
|
||||
connectionsFilePath: path.join(
|
||||
datadir(),
|
||||
processArgs.runE2eTests ? 'connections-e2etests.jsonl' : 'connections.jsonl'
|
||||
),
|
||||
...currentVersion,
|
||||
};
|
||||
|
||||
|
||||
@@ -199,8 +199,11 @@ module.exports = {
|
||||
const dir = datadir();
|
||||
if (!portalConnections) {
|
||||
// @ts-ignore
|
||||
this.datastore = new JsonLinesDatabase(path.join(dir, 'connections.jsonl'));
|
||||
this.datastore = new JsonLinesDatabase(
|
||||
path.join(dir, processArgs.runE2eTests ? 'connections-e2etests.jsonl' : 'connections.jsonl')
|
||||
);
|
||||
}
|
||||
await this.checkUnsavedConnectionsLimit();
|
||||
},
|
||||
|
||||
list_meta: true,
|
||||
@@ -219,7 +222,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
test_meta: true,
|
||||
test(connection) {
|
||||
test({ connection, requestDbList }) {
|
||||
const subprocess = fork(
|
||||
global['API_PACKAGE'] || process.argv[1],
|
||||
[
|
||||
@@ -234,7 +237,7 @@ module.exports = {
|
||||
}
|
||||
);
|
||||
pipeForkLogs(subprocess);
|
||||
subprocess.send(connection);
|
||||
subprocess.send({ connection, requestDbList });
|
||||
return new Promise(resolve => {
|
||||
subprocess.on('message', resp => {
|
||||
if (handleProcessCommunication(resp, subprocess)) return;
|
||||
@@ -300,6 +303,32 @@ module.exports = {
|
||||
return res;
|
||||
},
|
||||
|
||||
async checkUnsavedConnectionsLimit() {
|
||||
if (!this.datastore) {
|
||||
return;
|
||||
}
|
||||
const MAX_UNSAVED_CONNECTIONS = 5;
|
||||
await this.datastore.transformAll(connections => {
|
||||
const count = connections.filter(x => x.unsaved).length;
|
||||
if (count > MAX_UNSAVED_CONNECTIONS) {
|
||||
const res = [];
|
||||
let unsavedToSkip = count - MAX_UNSAVED_CONNECTIONS;
|
||||
for (const item of connections) {
|
||||
if (item.unsaved) {
|
||||
if (unsavedToSkip > 0) {
|
||||
unsavedToSkip--;
|
||||
} else {
|
||||
res.push(item);
|
||||
}
|
||||
} else {
|
||||
res.push(item);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
update_meta: true,
|
||||
async update({ _id, values }, req) {
|
||||
if (portalConnections) return;
|
||||
@@ -483,4 +512,10 @@ module.exports = {
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
reloadConnectionList_meta: true,
|
||||
async reloadConnectionList() {
|
||||
if (portalConnections) return;
|
||||
await this.datastore.unload();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ module.exports = {
|
||||
const scriptFile = path.join(uploadsdir(), runid + '.js');
|
||||
fs.writeFileSync(`${scriptFile}`, scriptText);
|
||||
fs.mkdirSync(directory);
|
||||
const pluginNames = _.union(fs.readdirSync(pluginsdir()), packagedPluginList);
|
||||
const pluginNames = extractPlugins(scriptText);
|
||||
logger.info({ scriptFile }, 'Running script');
|
||||
// const subprocess = fork(scriptFile, ['--checkParent', '--max-old-space-size=8192'], {
|
||||
const subprocess = fork(
|
||||
|
||||
@@ -52,7 +52,7 @@ module.exports = {
|
||||
if (existing) return existing;
|
||||
const connection = await connections.getCore({ conid });
|
||||
if (!connection) {
|
||||
throw new Error(`Connection with conid="${conid}" not fund`);
|
||||
throw new Error(`Connection with conid="${conid}" not found`);
|
||||
}
|
||||
if (connection.passwordMode == 'askPassword' || connection.passwordMode == 'askUser') {
|
||||
throw new MissingCredentialsError({ conid, passwordMode: connection.passwordMode });
|
||||
|
||||
@@ -26,4 +26,6 @@ module.exports = {
|
||||
async readConfig({ group }) {
|
||||
return {};
|
||||
},
|
||||
|
||||
startRefreshLicense() {},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
module.exports = {
|
||||
version: '5.0.0-alpha.1',
|
||||
buildTime: '2021-04-17T07:22:49.702Z'
|
||||
version: '6.0.0-alpha.1',
|
||||
buildTime: '2024-12-01T00:00:00Z'
|
||||
};
|
||||
|
||||
@@ -28,6 +28,7 @@ const files = require('./controllers/files');
|
||||
const scheduler = require('./controllers/scheduler');
|
||||
const queryHistory = require('./controllers/queryHistory');
|
||||
const onFinished = require('on-finished');
|
||||
const processArgs = require('./utility/processArgs');
|
||||
|
||||
const { rundir } = require('./utility/directories');
|
||||
const platformInfo = require('./utility/platformInfo');
|
||||
@@ -77,6 +78,8 @@ function start() {
|
||||
app.use(getExpressPath('/'), express.static('/home/dbgate-docker/public'));
|
||||
} else if (platformInfo.isAwsUbuntuLayout) {
|
||||
app.use(getExpressPath('/'), express.static('/home/ubuntu/build/public'));
|
||||
} else if (processArgs.runE2eTests) {
|
||||
app.use(getExpressPath('/'), express.static(path.resolve('packer/build/public')));
|
||||
} else if (platformInfo.isNpmDist) {
|
||||
app.use(
|
||||
getExpressPath('/'),
|
||||
|
||||
@@ -16,13 +16,19 @@ Platform: ${process.platform}
|
||||
|
||||
function start() {
|
||||
childProcessChecker();
|
||||
process.on('message', async connection => {
|
||||
process.on('message', async args => {
|
||||
// @ts-ignore
|
||||
const { connection, requestDbList } = args;
|
||||
if (handleProcessCommunication(connection)) return;
|
||||
try {
|
||||
const driver = requireEngineDriver(connection);
|
||||
const dbhan = await connectUtility(driver, connection, 'app');
|
||||
const res = await driver.getVersion(dbhan);
|
||||
process.send({ msgtype: 'connected', ...res });
|
||||
let databases = undefined;
|
||||
if (requestDbList) {
|
||||
databases = await driver.listDatabases(dbhan);
|
||||
}
|
||||
process.send({ msgtype: 'connected', ...res, databases });
|
||||
await driver.close(dbhan);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@@ -23,6 +23,12 @@ class JsonLinesDatabase {
|
||||
await fs.writeFile(this.filename, this.data.map(x => JSON.stringify(x)).join('\n'));
|
||||
}
|
||||
|
||||
async unload() {
|
||||
this.data = [];
|
||||
this.loadedOk = false;
|
||||
this.loadPerformed = false;
|
||||
}
|
||||
|
||||
async _ensureLoaded() {
|
||||
if (!this.loadPerformed) {
|
||||
await lock.acquire('reader', async () => {
|
||||
@@ -111,6 +117,15 @@ class JsonLinesDatabase {
|
||||
return removed;
|
||||
}
|
||||
|
||||
async transformAll(transformFunction) {
|
||||
await this._ensureLoaded();
|
||||
const newData = transformFunction(this.data);
|
||||
if (newData) {
|
||||
this.data = newData;
|
||||
await this._save();
|
||||
}
|
||||
}
|
||||
|
||||
// async _openReader() {
|
||||
// return new Promise((resolve, reject) =>
|
||||
// lineReader.open(this.filename, (err, reader) => {
|
||||
|
||||
@@ -96,6 +96,9 @@ function packagedPluginsDir() {
|
||||
// return path.resolve(__dirname, '../../plugins');
|
||||
// }
|
||||
}
|
||||
if (processArgs.runE2eTests) {
|
||||
return path.resolve('packer/build/plugins');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ const workspaceDir = getNamedArg('--workspace-dir');
|
||||
const processDisplayName = getNamedArg('--process-display-name');
|
||||
const listenApi = process.argv.includes('--listen-api');
|
||||
const listenApiChild = process.argv.includes('--listen-api-child') || listenApi;
|
||||
const runE2eTests = process.argv.includes('--run-e2e-tests');
|
||||
|
||||
function getPassArgs() {
|
||||
const res = [];
|
||||
@@ -23,6 +24,9 @@ function getPassArgs() {
|
||||
if (listenApiChild) {
|
||||
res.push('listen-api-child');
|
||||
}
|
||||
if (runE2eTests) {
|
||||
res.push('--run-e2e-tests');
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -36,4 +40,5 @@ module.exports = {
|
||||
listenApi,
|
||||
listenApiChild,
|
||||
processDisplayName,
|
||||
runE2eTests,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"name": "dbgate-datalib",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@@ -13,13 +13,13 @@
|
||||
"lib"
|
||||
],
|
||||
"dependencies": {
|
||||
"dbgate-sqltree": "^5.0.0-alpha.1",
|
||||
"dbgate-tools": "^5.0.0-alpha.1",
|
||||
"dbgate-filterparser": "^5.0.0-alpha.1",
|
||||
"dbgate-sqltree": "^6.0.0-alpha.1",
|
||||
"dbgate-tools": "^6.0.0-alpha.1",
|
||||
"dbgate-filterparser": "^6.0.0-alpha.1",
|
||||
"uuid": "^3.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dbgate-types": "^5.0.0-alpha.1",
|
||||
"dbgate-types": "^6.0.0-alpha.1",
|
||||
"@types/node": "^13.7.0",
|
||||
"jest": "^28.1.3",
|
||||
"ts-jest": "^28.0.7",
|
||||
|
||||
@@ -66,7 +66,7 @@ class DuplicatorItemHolder {
|
||||
this.autoColumn = this.table.columns.find(x => x.autoIncrement)?.columnName;
|
||||
if (
|
||||
this.table.primaryKey?.columns?.length != 1 ||
|
||||
this.table.primaryKey?.columns?.[0].columnName != this.autoColumn
|
||||
this.table.primaryKey?.columns?.[0]?.columnName != this.autoColumn
|
||||
) {
|
||||
this.autoColumn = null;
|
||||
}
|
||||
@@ -140,6 +140,9 @@ class DuplicatorItemHolder {
|
||||
weakref.foreignKey.columns[0].columnName
|
||||
);
|
||||
});
|
||||
if (this.duplicator.driver.dialect.requireFromDual) {
|
||||
dmp.put(' ^from ^dual');
|
||||
}
|
||||
});
|
||||
const qrow = qres.rows[0];
|
||||
return this.weakReferences.filter(x => qrow[x.columnName] == 0).map(x => x.columnName);
|
||||
@@ -194,6 +197,7 @@ class DuplicatorItemHolder {
|
||||
res = await runQueryOnDriver(pool, driver, dmp => dmp.selectScopeIdentity(this.table));
|
||||
}
|
||||
// console.log('IDRES', JSON.stringify(res));
|
||||
// console.log('*********** ENTRIES OF', res?.rows?.[0]);
|
||||
const resId = Object.entries(res?.rows?.[0])?.[0]?.[1];
|
||||
if (resId != null) {
|
||||
this.idMap[chunk[this.autoColumn]] = resId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dbmodel",
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"homepage": "https://dbgate.org/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -30,16 +30,16 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"commander": "^10.0.0",
|
||||
"dbgate-api": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-csv": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-excel": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-mongo": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-mssql": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-mysql": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-postgres": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-xml": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-oracle": "^5.0.0-alpha.1",
|
||||
"dbgate-web": "^5.0.0-alpha.1",
|
||||
"dbgate-api": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-csv": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-excel": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-mongo": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-mssql": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-mysql": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-postgres": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-xml": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-oracle": "^6.0.0-alpha.1",
|
||||
"dbgate-web": "^6.0.0-alpha.1",
|
||||
"dotenv": "^16.0.0",
|
||||
"pinomin": "^1.0.4"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"name": "dbgate-filterparser",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@@ -13,7 +13,7 @@
|
||||
"lib"
|
||||
],
|
||||
"devDependencies": {
|
||||
"dbgate-types": "^5.0.0-alpha.1",
|
||||
"dbgate-types": "^6.0.0-alpha.1",
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^13.7.0",
|
||||
"jest": "^28.1.3",
|
||||
@@ -22,7 +22,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/parsimmon": "^1.10.1",
|
||||
"dbgate-tools": "^5.0.0-alpha.1",
|
||||
"dbgate-tools": "^6.0.0-alpha.1",
|
||||
"lodash": "^4.17.21",
|
||||
"date-fns": "^4.1.0",
|
||||
"moment": "^2.24.0",
|
||||
|
||||
+14
-14
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dbgate-serve",
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"homepage": "https://dbgate.org/",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -18,19 +18,19 @@
|
||||
"web"
|
||||
],
|
||||
"dependencies": {
|
||||
"dbgate-api": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-clickhouse": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-csv": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-excel": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-mongo": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-mssql": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-mysql": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-oracle": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-postgres": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-redis": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-sqlite": "^5.0.0-alpha.1",
|
||||
"dbgate-plugin-xml": "^5.0.0-alpha.1",
|
||||
"dbgate-web": "^5.0.0-alpha.1",
|
||||
"dbgate-api": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-clickhouse": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-csv": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-excel": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-mongo": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-mssql": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-mysql": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-oracle": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-postgres": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-redis": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-sqlite": "^6.0.0-alpha.1",
|
||||
"dbgate-plugin-xml": "^6.0.0-alpha.1",
|
||||
"dbgate-web": "^6.0.0-alpha.1",
|
||||
"dotenv": "^16.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"name": "dbgate-sqltree",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@@ -27,7 +27,7 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^13.7.0",
|
||||
"dbgate-types": "^5.0.0-alpha.1",
|
||||
"dbgate-types": "^6.0.0-alpha.1",
|
||||
"typescript": "^4.4.3"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"name": "dbgate-tools",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@@ -25,14 +25,14 @@
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^13.7.0",
|
||||
"dbgate-types": "^5.0.0-alpha.1",
|
||||
"dbgate-types": "^6.0.0-alpha.1",
|
||||
"jest": "^24.9.0",
|
||||
"ts-jest": "^25.2.1",
|
||||
"typescript": "^4.4.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"dbgate-query-splitter": "^4.11.2",
|
||||
"dbgate-sqltree": "^5.0.0-alpha.1",
|
||||
"dbgate-sqltree": "^6.0.0-alpha.1",
|
||||
"debug": "^4.3.4",
|
||||
"json-stable-stringify": "^1.0.1",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
@@ -359,7 +359,7 @@ export class DatabaseAnalyser {
|
||||
}
|
||||
|
||||
static byTableFilter(table) {
|
||||
return x => x.pureName == table.pureName && x.schemaName == x.schemaName;
|
||||
return x => x.pureName == table.pureName && x.schemaName == table.schemaName;
|
||||
}
|
||||
|
||||
static extractPrimaryKeys(table, pkColumns) {
|
||||
|
||||
@@ -17,6 +17,7 @@ import type {
|
||||
CheckInfo,
|
||||
AlterProcessor,
|
||||
SqlObjectInfo,
|
||||
CallableObjectInfo,
|
||||
} from 'dbgate-types';
|
||||
import _isString from 'lodash/isString';
|
||||
import _isNumber from 'lodash/isNumber';
|
||||
@@ -782,4 +783,18 @@ export class SqlDumper implements AlterProcessor {
|
||||
this.endCommand();
|
||||
}
|
||||
}
|
||||
|
||||
callableTemplate(func: CallableObjectInfo) {
|
||||
this.put(
|
||||
'^call %f(&>&n',
|
||||
func,
|
||||
);
|
||||
|
||||
this.putCollection(',&n', func.parameters || [], param => {
|
||||
this.putRaw(param.parameterMode == 'IN' ? ':' + param.parameterName : param.parameterName);
|
||||
});
|
||||
|
||||
this.put('&<&n)');
|
||||
this.endCommand();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import _compact from 'lodash/compact';
|
||||
import _isString from 'lodash/isString';
|
||||
import { SqlDumper } from './SqlDumper';
|
||||
import { splitQuery } from 'dbgate-query-splitter';
|
||||
import { dumpSqlSelect } from 'dbgate-sqltree';
|
||||
@@ -26,9 +27,17 @@ const dialect = {
|
||||
defaultSchemaName: null,
|
||||
};
|
||||
|
||||
export async function runCommandOnDriver(pool, driver: EngineDriver, cmd: (dmp: SqlDumper) => void): Promise<void> {
|
||||
export async function runCommandOnDriver(
|
||||
pool,
|
||||
driver: EngineDriver,
|
||||
cmd: (dmp: SqlDumper) => void | string
|
||||
): Promise<void> {
|
||||
const dmp = driver.createDumper();
|
||||
cmd(dmp as any);
|
||||
if (_isString(cmd)) {
|
||||
dmp.put(cmd);
|
||||
} else {
|
||||
cmd(dmp as any);
|
||||
}
|
||||
// console.log('CMD:', dmp.s);
|
||||
await driver.query(pool, dmp.s, { discardResult: true });
|
||||
}
|
||||
@@ -39,11 +48,21 @@ export async function runQueryOnDriver(
|
||||
cmd: (dmp: SqlDumper) => void
|
||||
): Promise<QueryResult> {
|
||||
const dmp = driver.createDumper();
|
||||
cmd(dmp as any);
|
||||
if (_isString(cmd)) {
|
||||
dmp.put(cmd);
|
||||
} else {
|
||||
cmd(dmp as any);
|
||||
}
|
||||
// console.log('QUERY:', dmp.s);
|
||||
return await driver.query(pool, dmp.s);
|
||||
}
|
||||
|
||||
export function formatQueryWithoutParams(driver: EngineDriver, sql: string) {
|
||||
const dmp = driver.createDumper();
|
||||
dmp.put(sql);
|
||||
return dmp.s;
|
||||
}
|
||||
|
||||
export const driverBase = {
|
||||
analyserClass: null,
|
||||
dumperClass: SqlDumper,
|
||||
|
||||
@@ -2,9 +2,9 @@ import _compact from 'lodash/compact';
|
||||
import _isString from 'lodash/isString';
|
||||
import _startCase from 'lodash/startCase';
|
||||
|
||||
export interface FilterNameDefinition {
|
||||
childName: string;
|
||||
}
|
||||
// export interface FilterNameDefinition {
|
||||
// childName: string;
|
||||
// }
|
||||
|
||||
function camelMatch(filter: string, text: string): boolean {
|
||||
if (!text) return false;
|
||||
@@ -20,7 +20,7 @@ function camelMatch(filter: string, text: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function filterName(filter: string, ...names: (string | FilterNameDefinition)[]) {
|
||||
export function filterName(filter: string, ...names: string[]) {
|
||||
if (!filter) return true;
|
||||
|
||||
// const camelVariants = [name.replace(/[^A-Z]/g, '')]
|
||||
@@ -28,22 +28,135 @@ export function filterName(filter: string, ...names: (string | FilterNameDefinit
|
||||
|
||||
const namesCompacted = _compact(names);
|
||||
|
||||
// @ts-ignore
|
||||
const namesOwn: string[] = namesCompacted.filter(x => _isString(x));
|
||||
// @ts-ignore
|
||||
const namesChild: string[] = namesCompacted.filter(x => x.childName).map(x => x.childName);
|
||||
|
||||
for (const token of tokens) {
|
||||
// const tokenUpper = token.toUpperCase();
|
||||
if (token.startsWith('#')) {
|
||||
// const tokenUpperSub = tokenUpper.substring(1);
|
||||
const found = namesChild.find(name => camelMatch(token.substring(1), name));
|
||||
if (!found) return false;
|
||||
} else {
|
||||
const found = namesOwn.find(name => camelMatch(token, name));
|
||||
if (!found) return false;
|
||||
}
|
||||
const found = namesCompacted.find(name => camelMatch(token, name));
|
||||
if (!found) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function filterNameCompoud(
|
||||
filter: string,
|
||||
namesMain: string[],
|
||||
namesChild: string[]
|
||||
): 'main' | 'child' | 'both' | 'none' {
|
||||
if (!filter) return 'both';
|
||||
|
||||
// const camelVariants = [name.replace(/[^A-Z]/g, '')]
|
||||
const tokens = filter.split(' ').map(x => x.trim());
|
||||
|
||||
const namesCompactedMain = _compact(namesMain);
|
||||
const namesCompactedChild = _compact(namesChild);
|
||||
|
||||
let isMainOnly = true;
|
||||
let isChildOnly = true;
|
||||
|
||||
for (const token of tokens) {
|
||||
const foundMain = namesCompactedMain.find(name => camelMatch(token, name));
|
||||
const foundChild = namesCompactedChild.find(name => camelMatch(token, name));
|
||||
if (!foundMain && !foundChild) return 'none';
|
||||
|
||||
if (!foundMain) isMainOnly = false;
|
||||
if (!foundChild) isChildOnly = false;
|
||||
}
|
||||
|
||||
if (isMainOnly && isChildOnly) return 'both';
|
||||
if (isMainOnly) return 'main';
|
||||
if (isChildOnly) return 'child';
|
||||
return 'none';
|
||||
}
|
||||
|
||||
export function tokenizeBySearchFilter(text: string, filter: string): { text: string; isMatch: boolean }[] {
|
||||
const camelTokens = [];
|
||||
const stdTokens = [];
|
||||
for (const token of filter.split(' ').map(x => x.trim())) {
|
||||
if (token.replace(/[A-Z]/g, '').length == 0) {
|
||||
camelTokens.push(token);
|
||||
} else {
|
||||
stdTokens.push(token.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
let res = [
|
||||
{
|
||||
text,
|
||||
isMatch: false,
|
||||
},
|
||||
];
|
||||
|
||||
for (const token of camelTokens) {
|
||||
const nextres = [];
|
||||
for (const item of res) {
|
||||
const indexes = [];
|
||||
for (const char of token) {
|
||||
if (indexes.length == 0 && char == item.text[0]?.toUpperCase()) {
|
||||
// handle first letter of camelcase
|
||||
indexes.push(0);
|
||||
} else {
|
||||
const index = item.text.indexOf(char, indexes.length > 0 ? indexes[indexes.length - 1] + 1 : 0);
|
||||
if (index < 0) {
|
||||
indexes.push(-1);
|
||||
} else {
|
||||
indexes.push(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (indexes.some(x => x < 0)) {
|
||||
nextres.push(item);
|
||||
} else {
|
||||
let lastIndex = 0;
|
||||
for (let i = 0; i < indexes.length; i++) {
|
||||
if (indexes[i] > lastIndex) {
|
||||
nextres.push({ text: item.text.substring(lastIndex, indexes[i]), isMatch: false });
|
||||
}
|
||||
nextres.push({ text: item.text.substring(indexes[i], indexes[i] + 1), isMatch: true });
|
||||
lastIndex = indexes[i] + 1;
|
||||
}
|
||||
nextres.push({ text: item.text.substring(lastIndex), isMatch: false });
|
||||
}
|
||||
}
|
||||
res = nextres;
|
||||
}
|
||||
|
||||
for (const token of stdTokens) {
|
||||
const nextres = [];
|
||||
for (const item of res) {
|
||||
const index = item.text?.toUpperCase().indexOf(token);
|
||||
if (index < 0) {
|
||||
nextres.push(item);
|
||||
} else {
|
||||
nextres.push({ text: item.text.substring(0, index), isMatch: false });
|
||||
nextres.push({ text: item.text.substring(index, index + token.length), isMatch: true });
|
||||
nextres.push({ text: item.text.substring(index + token.length), isMatch: false });
|
||||
}
|
||||
}
|
||||
res = nextres;
|
||||
}
|
||||
|
||||
res = res.filter(x => x.text.length > 0);
|
||||
|
||||
if (res.length == 1 && !res[0].isMatch) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
// const result = [];
|
||||
// let lastMatch = 0;
|
||||
// for (const token of tokens) {
|
||||
// const index = text.indexOf(token, lastMatch);
|
||||
// if (index < 0) {
|
||||
// result.push({ token, isMatch: false });
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// result.push({ token: text.substring(lastMatch, index), isMatch: false });
|
||||
// result.push({ token: text.substring(index, index + token.length), isMatch: true });
|
||||
// lastMatch = index + token.length;
|
||||
// }
|
||||
|
||||
// result.push({ token: text.substring(lastMatch), isMatch: false });
|
||||
|
||||
// return result;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ export function extractShellApiFunctionName(functionName) {
|
||||
}
|
||||
|
||||
export function findEngineDriver(connection, extensions: ExtensionsDirectory): EngineDriver {
|
||||
if (!extensions) {
|
||||
return null;
|
||||
}
|
||||
if (_isString(connection)) {
|
||||
return extensions.drivers.find(x => x.engine == connection);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,20 @@ function fillDatabaseExtendedInfo(db: DatabaseInfo): DatabaseInfo {
|
||||
procedures: (db.procedures || []).map(obj => ({
|
||||
...obj,
|
||||
objectTypeField: 'procedures',
|
||||
parameters: (obj.parameters || []).map(param => ({
|
||||
...param,
|
||||
pureName: obj.pureName,
|
||||
schemaName: obj.schemaName,
|
||||
})),
|
||||
})),
|
||||
functions: (db.functions || []).map(obj => ({
|
||||
...obj,
|
||||
objectTypeField: 'functions',
|
||||
parameters: (obj.parameters || []).map(param => ({
|
||||
...param,
|
||||
pureName: obj.pureName,
|
||||
schemaName: obj.schemaName,
|
||||
})),
|
||||
})),
|
||||
triggers: (db.triggers || []).map(obj => ({
|
||||
...obj,
|
||||
|
||||
Vendored
+17
-5
@@ -35,7 +35,7 @@ export interface IndexInfo extends ColumnsConstraintInfo {
|
||||
isUnique: boolean;
|
||||
// indexType: 'normal' | 'clustered' | 'xml' | 'spatial' | 'fulltext';
|
||||
indexType?: string;
|
||||
// condition for filtered index (SQL Server)
|
||||
// condition for filtered index (SQL Server)
|
||||
filterDefinition?: string;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ export interface DatabaseObjectInfo extends NamedObjectInfo {
|
||||
modifyDate?: string;
|
||||
hashCode?: string;
|
||||
objectTypeField?: string;
|
||||
obejctComment?: string;
|
||||
objectComment?: string;
|
||||
}
|
||||
|
||||
export interface SqlObjectInfo extends DatabaseObjectInfo {
|
||||
@@ -118,10 +118,22 @@ export interface ViewInfo extends SqlObjectInfo {
|
||||
columns: ColumnInfo[];
|
||||
}
|
||||
|
||||
export interface ProcedureInfo extends SqlObjectInfo {}
|
||||
export type ParameterMode = 'IN' | 'OUT' | 'INOUT' | 'RETURN';
|
||||
|
||||
export interface FunctionInfo extends SqlObjectInfo {
|
||||
// returnDataType?: string;
|
||||
export interface ParameterInfo extends NamedObjectInfo {
|
||||
parameterName?: string;
|
||||
dataType: string;
|
||||
parameterMode?: ParameterMode;
|
||||
}
|
||||
|
||||
export interface CallableObjectInfo extends SqlObjectInfo {
|
||||
parameters?: ParameterInfo[];
|
||||
}
|
||||
|
||||
export interface ProcedureInfo extends CallableObjectInfo {}
|
||||
|
||||
export interface FunctionInfo extends CallableObjectInfo {
|
||||
returnType?: string;
|
||||
}
|
||||
|
||||
export interface TriggerInfo extends SqlObjectInfo {}
|
||||
|
||||
Vendored
+2
@@ -51,6 +51,8 @@ export interface SqlDialect {
|
||||
|
||||
dropReferencesWhenDropTable?: boolean;
|
||||
requireFromDual?: boolean;
|
||||
userDatabaseNamePrefix?: string; // c## in Oracle
|
||||
upperCaseAllDbObjectNames?: boolean;
|
||||
|
||||
predefinedDataTypes: string[];
|
||||
|
||||
|
||||
Vendored
+3
-1
@@ -1,5 +1,5 @@
|
||||
import { AlterProcessor } from './alter-processor';
|
||||
import { TableInfo } from './dbinfo';
|
||||
import { CallableObjectInfo, NamedObjectInfo, TableInfo } from './dbinfo';
|
||||
import { SqlDialect } from './dialect';
|
||||
|
||||
export type TransformType = 'GROUP:YEAR' | 'GROUP:MONTH' | 'GROUP:DAY' | 'YEAR' | 'MONTH' | 'DAY'; // | 'GROUP:HOUR' | 'GROUP:MINUTE';
|
||||
@@ -17,6 +17,8 @@ export interface SqlDumper extends AlterProcessor {
|
||||
createDatabase(name: string);
|
||||
dropDatabase(name: string);
|
||||
|
||||
callableTemplate(func: CallableObjectInfo);
|
||||
|
||||
endCommand();
|
||||
allowIdentityInsert(table: NamedObjectInfo, allow: boolean);
|
||||
truncateTable(table: NamedObjectInfo);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"name": "dbgate-types",
|
||||
"homepage": "https://dbgate.org/",
|
||||
"repository": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dbgate-web",
|
||||
"version": "5.0.0-alpha.1",
|
||||
"version": "6.0.0-alpha.1",
|
||||
"scripts": {
|
||||
"build": "yarn build:index && rollup -c",
|
||||
"dev": "yarn build:index && cross-env API_URL=http://localhost:3000 rollup -c -w",
|
||||
@@ -20,15 +20,15 @@
|
||||
"@rollup/plugin-replace": "^3.0.0",
|
||||
"@rollup/plugin-typescript": "^8.2.5",
|
||||
"@tsconfig/svelte": "^1.0.0",
|
||||
"ace-builds": "^1.4.8",
|
||||
"ace-builds": "^1.36.5",
|
||||
"chart.js": "^4.4.2",
|
||||
"chartjs-adapter-moment": "^1.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"dbgate-datalib": "^5.0.0-alpha.1",
|
||||
"dbgate-datalib": "^6.0.0-alpha.1",
|
||||
"dbgate-query-splitter": "^4.11.2",
|
||||
"dbgate-sqltree": "^5.0.0-alpha.1",
|
||||
"dbgate-tools": "^5.0.0-alpha.1",
|
||||
"dbgate-types": "^5.0.0-alpha.1",
|
||||
"dbgate-sqltree": "^6.0.0-alpha.1",
|
||||
"dbgate-tools": "^6.0.0-alpha.1",
|
||||
"dbgate-types": "^6.0.0-alpha.1",
|
||||
"diff": "^5.0.0",
|
||||
"diff2html": "^3.4.13",
|
||||
"file-selector": "^0.2.4",
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
}
|
||||
|
||||
// $: console.log('CONFIG', $config);
|
||||
|
||||
$: {
|
||||
if ($config?.isLicenseValid) {
|
||||
internalRedirectTo(isOneOfPage('admin-license') ? '/admin.html' : '/index.html');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<FormProviderCore {values}>
|
||||
@@ -88,8 +94,16 @@
|
||||
<FormStyledButton
|
||||
value="Purchase DbGate Premium"
|
||||
on:click={async e => {
|
||||
// openWebLink(
|
||||
// `https://auth.dbgate.eu/create-checkout-session-simple?source=trial-${isExpired ? 'expired' : (trialDaysLeft ?? 'no')}`
|
||||
// );
|
||||
|
||||
// openWebLink(
|
||||
// `https://auth-proxy.dbgate.udolni.net/redirect-to-purchase?product=${getElectron() ? 'premium' : 'teram-premium'}&source=trial-${isExpired ? 'expired' : (trialDaysLeft ?? 'no')}`
|
||||
// );
|
||||
|
||||
openWebLink(
|
||||
`https://auth.dbgate.eu/create-checkout-session-simple?source=trial-${isExpired ? 'expired' : (trialDaysLeft ?? 'no')}`
|
||||
`https://auth.dbgate.eu/redirect-to-purchase?product=${getElectron() ? 'premium' : 'team-premium'}&source=trial-${isExpired ? 'expired' : (trialDaysLeft ?? 'no')}`
|
||||
);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
|
||||
export const extractKey = data => data.fileName;
|
||||
export const createMatcher =
|
||||
({ fileName }) =>
|
||||
filter =>
|
||||
({ fileName }) =>
|
||||
filterName(filter, fileName);
|
||||
const APP_ICONS = {
|
||||
'config.json': 'img json',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = data => data.name;
|
||||
export const createMatcher = data => filter => filterName(filter, data.name);
|
||||
export const createMatcher = filter => data => filterName(filter, data.name);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import CheckboxField from '../forms/CheckboxField.svelte';
|
||||
import { copyTextToClipboard } from '../utility/clipboard';
|
||||
import { showSnackbarSuccess } from '../utility/snackbar';
|
||||
import TokenizedFilteredText from '../widgets/TokenizedFilteredText.svelte';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
@@ -14,6 +15,7 @@
|
||||
export let module = null;
|
||||
|
||||
export let isBold = false;
|
||||
export let isChoosed = false;
|
||||
export let isBusy = false;
|
||||
export let statusIcon = undefined;
|
||||
export let statusIconBefore = undefined;
|
||||
@@ -29,6 +31,9 @@
|
||||
export let onUnpin = null;
|
||||
export let showPinnedInsteadOfUnpin = false;
|
||||
export let indentLevel = 0;
|
||||
export let disableBoldScroll = false;
|
||||
export let filter = null;
|
||||
export let disableHover = false;
|
||||
|
||||
$: isChecked =
|
||||
checkedObjectsStore && $checkedObjectsStore.find(x => module?.extractKey(data) == module?.extractKey(x));
|
||||
@@ -56,6 +61,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
function handleMouseDown(e) {
|
||||
if (e.button == 1) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
function setChecked(value) {
|
||||
if (!value && isChecked) {
|
||||
checkedObjectsStore.update(x => x.filter(y => module?.extractKey(data) != module?.extractKey(y)));
|
||||
@@ -66,14 +78,27 @@
|
||||
}
|
||||
|
||||
// $: console.log(title, indentLevel);
|
||||
let domDiv;
|
||||
|
||||
$: if (isBold && domDiv && !disableBoldScroll) {
|
||||
domDiv.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
||||
}
|
||||
|
||||
$: if (isChoosed && domDiv) {
|
||||
domDiv.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="main"
|
||||
class:isBold
|
||||
class:isChoosed
|
||||
class:disableHover
|
||||
draggable={true}
|
||||
on:click={handleClick}
|
||||
on:mouseup={handleMouseUp}
|
||||
on:mousedown={handleMouseDown}
|
||||
on:mousedown
|
||||
on:dblclick
|
||||
use:contextMenu={disableContextMenu ? null : menu}
|
||||
on:dragstart={e => {
|
||||
@@ -83,6 +108,7 @@
|
||||
on:dragenter
|
||||
on:dragend
|
||||
on:drop
|
||||
bind:this={domDiv}
|
||||
>
|
||||
{#if checkedObjectsStore}
|
||||
<CheckboxField
|
||||
@@ -109,7 +135,7 @@
|
||||
{#if colorMark}
|
||||
<FontIcon style={`color:${colorMark}`} icon="icon square" />
|
||||
{/if}
|
||||
{title}
|
||||
<TokenizedFilteredText text={title} {filter} />
|
||||
{#if statusIconBefore}
|
||||
<span class="status">
|
||||
<FontIcon icon={statusIconBefore} />
|
||||
@@ -131,7 +157,7 @@
|
||||
{/if}
|
||||
{#if extInfo}
|
||||
<span class="ext-info">
|
||||
{extInfo}
|
||||
<TokenizedFilteredText text={extInfo} {filter} />
|
||||
</span>
|
||||
{/if}
|
||||
{#if onPin}
|
||||
@@ -174,12 +200,18 @@
|
||||
white-space: nowrap;
|
||||
font-weight: normal;
|
||||
}
|
||||
.main:hover {
|
||||
.main:hover:not(.disableHover) {
|
||||
background-color: var(--theme-bg-hover);
|
||||
}
|
||||
.isBold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.isChoosed {
|
||||
background-color: var(--theme-bg-3);
|
||||
}
|
||||
:global(.app-object-list-focused) .isChoosed {
|
||||
background-color: var(--theme-bg-selected);
|
||||
}
|
||||
.status {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
export let onDropOnGroup = undefined;
|
||||
export let groupContextMenu = null;
|
||||
export let collapsedGroupNames;
|
||||
export let filter = undefined;
|
||||
|
||||
$: isExpanded = !$collapsedGroupNames.includes(group);
|
||||
|
||||
@@ -86,6 +87,9 @@
|
||||
on:objectClick
|
||||
{disableContextMenu}
|
||||
{passProps}
|
||||
isExpandedBySearch={filter && item.isChildMatched}
|
||||
{filter}
|
||||
isMainMatched={item.isMainMatched}
|
||||
/>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<script>
|
||||
import _, { sortBy } from 'lodash';
|
||||
import { asyncFilter } from '../utility/common';
|
||||
import _ from 'lodash';
|
||||
import AppObjectGroup from './AppObjectGroup.svelte';
|
||||
import { plusExpandIcon } from '../icons/expandIcons';
|
||||
|
||||
import AppObjectListItem from './AppObjectListItem.svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import Link from '../elements/Link.svelte';
|
||||
import { focusedConnectionOrDatabase } from '../stores';
|
||||
import { tick } from 'svelte';
|
||||
|
||||
export let list;
|
||||
export let module;
|
||||
@@ -16,7 +18,7 @@
|
||||
export let expandIconFunc = undefined;
|
||||
export let checkedObjectsStore = null;
|
||||
export let disableContextMenu = false;
|
||||
export let passProps;
|
||||
export let passProps = {};
|
||||
export let getIsExpanded = null;
|
||||
export let setIsExpanded = null;
|
||||
export let sortGroups = false;
|
||||
@@ -26,24 +28,47 @@
|
||||
export let groupFunc = undefined;
|
||||
export let onDropOnGroup = undefined;
|
||||
export let emptyGroupNames = [];
|
||||
export let isExpandedBySearch = false;
|
||||
|
||||
export let collapsedGroupNames = writable([]);
|
||||
export let onChangeFilteredList = undefined;
|
||||
|
||||
$: filtered = !groupFunc
|
||||
? list.filter(data => {
|
||||
const matcher = module.createMatcher && module.createMatcher(data);
|
||||
if (matcher && !matcher(filter)) return false;
|
||||
return true;
|
||||
})
|
||||
: null;
|
||||
let expandLimited = false;
|
||||
|
||||
$: childrenMatched = !groupFunc
|
||||
? list.filter(data => {
|
||||
const matcher = module.createChildMatcher && module.createChildMatcher(data);
|
||||
if (matcher && !matcher(filter)) return false;
|
||||
return true;
|
||||
})
|
||||
: null;
|
||||
$: matcher = module.createMatcher && module.createMatcher(filter, passProps?.searchSettings);
|
||||
|
||||
$: dataLabeled = _.compact(
|
||||
(list || []).map(data => {
|
||||
const matchResult = matcher ? matcher(data) : true;
|
||||
|
||||
let isMatched = true;
|
||||
let isMainMatched = true;
|
||||
let isChildMatched = true;
|
||||
|
||||
if (matchResult == false) {
|
||||
isMatched = false;
|
||||
isChildMatched = false;
|
||||
isMainMatched = false;
|
||||
} else if (matchResult == 'child') {
|
||||
isMainMatched = false;
|
||||
} else if (matchResult == 'main') {
|
||||
isChildMatched = false;
|
||||
} else if (matchResult == 'none') {
|
||||
isMatched = false;
|
||||
isChildMatched = false;
|
||||
isMainMatched = false;
|
||||
} else if (matchResult == 'both') {
|
||||
isChildMatched = !module.disableShowChildrenWithParentMatch;
|
||||
}
|
||||
|
||||
const group = groupFunc ? groupFunc(data) : undefined;
|
||||
return { group, data, isMatched, isChildMatched, isMainMatched };
|
||||
})
|
||||
);
|
||||
|
||||
$: filtered = dataLabeled.filter(x => x.isMatched).map(x => x.data);
|
||||
$: childrenMatched = dataLabeled.filter(x => x.isChildMatched).map(x => x.data);
|
||||
$: mainMatched = dataLabeled.filter(x => x.isMainMatched).map(x => x.data);
|
||||
|
||||
// let filtered = [];
|
||||
|
||||
@@ -59,17 +84,6 @@
|
||||
// }
|
||||
// }
|
||||
|
||||
$: listGrouped = groupFunc
|
||||
? _.compact(
|
||||
(list || []).map(data => {
|
||||
const matcher = module.createMatcher && module.createMatcher(data);
|
||||
const isMatched = matcher && !matcher(filter) ? false : true;
|
||||
const group = groupFunc(data);
|
||||
return { group, data, isMatched };
|
||||
})
|
||||
)
|
||||
: null;
|
||||
|
||||
function extendGroups(base, emptyList) {
|
||||
const res = {
|
||||
...base,
|
||||
@@ -81,7 +95,24 @@
|
||||
return res;
|
||||
}
|
||||
|
||||
$: groups = groupFunc ? extendGroups(_.groupBy(listGrouped, 'group'), emptyGroupNames) : null;
|
||||
function setExpandLimited() {
|
||||
expandLimited = true;
|
||||
}
|
||||
|
||||
$: groups = groupFunc ? extendGroups(_.groupBy(dataLabeled, 'group'), emptyGroupNames) : null;
|
||||
|
||||
$: listLimited = isExpandedBySearch && !expandLimited ? filtered.slice(0, filter.trim().length < 3 ? 1 : 3) : list;
|
||||
$: isListLimited = isExpandedBySearch && listLimited.length < filtered.length;
|
||||
$: listMissingItems = isListLimited ? filtered.slice(listLimited.length) : [];
|
||||
|
||||
$: if (
|
||||
$focusedConnectionOrDatabase &&
|
||||
listMissingItems.some(
|
||||
x => $focusedConnectionOrDatabase.conid == x?.connection?._id && $focusedConnectionOrDatabase.database == x?.name
|
||||
)
|
||||
) {
|
||||
tick().then(setExpandLimited);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if groupFunc}
|
||||
@@ -107,7 +138,7 @@
|
||||
/>
|
||||
{/each}
|
||||
{:else}
|
||||
{#each list as data}
|
||||
{#each listLimited as data}
|
||||
<AppObjectListItem
|
||||
isHidden={!filtered.includes(data)}
|
||||
{module}
|
||||
@@ -120,10 +151,20 @@
|
||||
{checkedObjectsStore}
|
||||
{disableContextMenu}
|
||||
{filter}
|
||||
isExpandedBySearch={childrenMatched.includes(data)}
|
||||
isExpandedBySearch={filter && childrenMatched.includes(data)}
|
||||
isMainMatched={filter && mainMatched.includes(data)}
|
||||
{passProps}
|
||||
{getIsExpanded}
|
||||
{setIsExpanded}
|
||||
/>
|
||||
{/each}
|
||||
{#if isListLimited}
|
||||
<div class="ml-2">
|
||||
<Link
|
||||
onClick={() => {
|
||||
expandLimited = true;
|
||||
}}>Show next {filtered.length - listLimited.length}</Link
|
||||
>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
export let passProps;
|
||||
export let getIsExpanded = null;
|
||||
export let setIsExpanded = null;
|
||||
export let isMainMatched = false;
|
||||
|
||||
let isExpandedCore = false;
|
||||
|
||||
@@ -50,18 +51,29 @@
|
||||
<svelte:component
|
||||
this={module.default}
|
||||
{data}
|
||||
on:click={handleExpand}
|
||||
on:dblclick={handleExpand}
|
||||
on:expand={handleExpandButton}
|
||||
expandIcon={getExpandIcon(!isExpandedBySearch && expandable, subItemsComponent, isExpanded, expandIconFunc)}
|
||||
{checkedObjectsStore}
|
||||
{module}
|
||||
{disableContextMenu}
|
||||
{passProps}
|
||||
{filter}
|
||||
/>
|
||||
|
||||
{#if (isExpanded || isExpandedBySearch) && subItemsComponent}
|
||||
<div class="subitems">
|
||||
<svelte:component this={subItemsComponent} {data} {filter} {passProps} />
|
||||
<svelte:component
|
||||
this={subItemsComponent(data, {
|
||||
isExpandedBySearch,
|
||||
})}
|
||||
{data}
|
||||
{filter}
|
||||
{passProps}
|
||||
{isExpandedBySearch}
|
||||
{isExpanded}
|
||||
{isMainMatched}
|
||||
/>
|
||||
</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
|
||||
export const extractKey = data => data.fileName;
|
||||
export const createMatcher =
|
||||
({ fileName }) =>
|
||||
filter =>
|
||||
({ fileName }) =>
|
||||
filterName(filter, fileName);
|
||||
const ARCHIVE_ICONS = {
|
||||
'table.yaml': 'img table',
|
||||
@@ -70,7 +70,7 @@
|
||||
import { getExtensions } from '../stores';
|
||||
|
||||
import createQuickExportMenu from '../utility/createQuickExportMenu';
|
||||
import { exportQuickExportFile, } from '../utility/exportFileTools';
|
||||
import { exportQuickExportFile } from '../utility/exportFileTools';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = data => data.name;
|
||||
export const createMatcher = data => filter => filterName(filter, data.name);
|
||||
export const createMatcher = filter => data => filterName(filter, data.name);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = ({ columnName }) => columnName;
|
||||
|
||||
export const createMatcher =
|
||||
(filter, cfg = DEFAULT_OBJECT_SEARCH_SETTINGS) =>
|
||||
data => {
|
||||
const filterArgs = [];
|
||||
if (cfg.columnName) filterArgs.push(data.columnName);
|
||||
if (cfg.columnComment) filterArgs.push(data.columnComment);
|
||||
if (cfg.columnDataType) filterArgs.push(data.dataType);
|
||||
|
||||
const res = filterName(filter, ...filterArgs);
|
||||
return res;
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -9,6 +21,8 @@
|
||||
import { renameDatabaseObjectDialog, alterDatabaseDialog } from '../utility/alterDatabaseTools';
|
||||
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import { DEFAULT_OBJECT_SEARCH_SETTINGS } from '../stores';
|
||||
import { filterName } from 'dbgate-tools';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -35,7 +49,21 @@
|
||||
];
|
||||
}
|
||||
|
||||
$: extInfo = data.foreignKey ? `${data.dataType} -> ${data.foreignKey.refTableName}` : data.dataType;
|
||||
function getExtInfo(data) {
|
||||
const res = [];
|
||||
if (data.foreignKey) {
|
||||
res.push(`${data.dataType} -> ${data.foreignKey.refTableName}`);
|
||||
} else {
|
||||
res.push(data.dataType);
|
||||
}
|
||||
if (data.columnComment) {
|
||||
res.push(data.columnComment);
|
||||
}
|
||||
if (res.length > 0) return res.join(', ');
|
||||
return null;
|
||||
}
|
||||
|
||||
$: extInfo = getExtInfo(data);
|
||||
</script>
|
||||
|
||||
<AppObjectCore
|
||||
@@ -45,5 +73,5 @@
|
||||
{extInfo}
|
||||
icon={getColumnIcon(data, true)}
|
||||
menu={createMenu}
|
||||
disableHover
|
||||
\
|
||||
/>
|
||||
|
||||
@@ -1,17 +1,35 @@
|
||||
<script context="module">
|
||||
export const extractKey = data => data._id;
|
||||
export const createMatcher = props => filter => {
|
||||
const { _id, displayName, server } = props;
|
||||
const databases = getLocalStorage(`database_list_${_id}`) || [];
|
||||
return filterName(filter, displayName, server, ...databases.map(x => x.name));
|
||||
};
|
||||
export const createChildMatcher = props => filter => {
|
||||
if (!filter) return false;
|
||||
const { _id } = props;
|
||||
const databases = getLocalStorage(`database_list_${_id}`) || [];
|
||||
return filterName(filter, ...databases.map(x => x.name));
|
||||
};
|
||||
export function openConnection(connection) {
|
||||
export const createMatcher =
|
||||
(filter, cfg = DEFAULT_CONNECTION_SEARCH_SETTINGS) =>
|
||||
props => {
|
||||
const { _id, displayName, server, user, engine } = props;
|
||||
const databases = getLocalStorage(`database_list_${_id}`) || [];
|
||||
const match = (engine || '').match(/^([^@]*)@/);
|
||||
const engineDisplay = match ? match[1] : engine;
|
||||
|
||||
return filterNameCompoud(
|
||||
filter,
|
||||
[
|
||||
cfg.displayName ? displayName : null,
|
||||
cfg.server ? server : null,
|
||||
cfg.user ? user : null,
|
||||
cfg.engine ? engineDisplay : null,
|
||||
],
|
||||
cfg.database ? databases.map(x => x.name) : []
|
||||
);
|
||||
};
|
||||
export function openConnection(connection, disableExpand = false) {
|
||||
if (connection.singleDatabase) {
|
||||
if (getOpenedSingleDatabaseConnections().includes(connection._id)) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (getOpenedConnections().includes(connection._id)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const config = getCurrentConfig();
|
||||
if (connection.singleDatabase) {
|
||||
switchCurrentDatabase({ connection, name: connection.defaultDatabase });
|
||||
@@ -27,7 +45,14 @@
|
||||
conid: connection._id,
|
||||
keepOpen: true,
|
||||
});
|
||||
expandedConnections.update(x => _.uniq([...x, connection._id]));
|
||||
|
||||
if (!disableExpand) {
|
||||
expandedConnections.update(x => _.uniq([...x, connection._id]));
|
||||
}
|
||||
|
||||
if (connection.defaultDatabase) {
|
||||
switchCurrentDatabase({ connection, name: connection.defaultDatabase });
|
||||
}
|
||||
|
||||
// if (!config.runAsPortal && getCurrentSettings()['defaultAction.connectionClick'] != 'connect') {
|
||||
// expandedConnections.update(x => _.uniq([...x, connection._id]));
|
||||
@@ -81,17 +106,20 @@
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import {
|
||||
currentDatabase,
|
||||
DEFAULT_CONNECTION_SEARCH_SETTINGS,
|
||||
expandedConnections,
|
||||
extensions,
|
||||
focusedConnectionOrDatabase,
|
||||
getCurrentConfig,
|
||||
getCurrentDatabase,
|
||||
getCurrentSettings,
|
||||
getOpenedConnections,
|
||||
getOpenedSingleDatabaseConnections,
|
||||
getOpenedTabs,
|
||||
openedConnections,
|
||||
openedSingleDatabaseConnections,
|
||||
} from '../stores';
|
||||
import { filterName } from 'dbgate-tools';
|
||||
import { filterName, filterNameCompoud } from 'dbgate-tools';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import ConfirmModal from '../modals/ConfirmModal.svelte';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
@@ -108,6 +136,7 @@
|
||||
import { getConnectionLabel } from 'dbgate-tools';
|
||||
import hasPermission from '../utility/hasPermission';
|
||||
import { switchCurrentDatabase } from '../utility/common';
|
||||
import { getConnectionClickActionSetting } from '../settings/settingsTools';
|
||||
|
||||
export let data;
|
||||
export let passProps;
|
||||
@@ -120,8 +149,8 @@
|
||||
|
||||
const electron = getElectron();
|
||||
|
||||
const handleConnect = () => {
|
||||
openConnection(data);
|
||||
const handleConnect = (disableExpand = false) => {
|
||||
openConnection(data, disableExpand);
|
||||
};
|
||||
|
||||
const handleOpenConnectionTab = () => {
|
||||
@@ -135,13 +164,14 @@
|
||||
});
|
||||
};
|
||||
|
||||
const handleClick = async () => {
|
||||
const config = getCurrentConfig();
|
||||
if (config.runAsPortal) {
|
||||
await tick();
|
||||
handleConnect();
|
||||
return;
|
||||
}
|
||||
const handleDoubleClick = async () => {
|
||||
// const config = getCurrentConfig();
|
||||
// if (config.runAsPortal) {
|
||||
// await tick();
|
||||
// handleConnect(true);
|
||||
// return;
|
||||
// }
|
||||
|
||||
if ($openedSingleDatabaseConnections.includes(data._id)) {
|
||||
switchCurrentDatabase({ connection: data, name: data.defaultDatabase });
|
||||
return;
|
||||
@@ -149,15 +179,54 @@
|
||||
if ($openedConnections.includes(data._id)) {
|
||||
return;
|
||||
}
|
||||
await tick();
|
||||
handleConnect(true);
|
||||
|
||||
if (getCurrentSettings()['defaultAction.connectionClick'] == 'openDetails') {
|
||||
handleOpenConnectionTab();
|
||||
} else {
|
||||
// if (getCurrentSettings()['defaultAction.connectionClick'] == 'openDetails') {
|
||||
// handleOpenConnectionTab();
|
||||
// } else {
|
||||
// await tick();
|
||||
// handleConnect();
|
||||
// }
|
||||
};
|
||||
|
||||
const handleClick = async e => {
|
||||
// focusedConnectionOrDatabase.set({
|
||||
// conid: data?._id,
|
||||
// connection: data,
|
||||
// database: data.singleDatabase ? data.defaultDatabase : null,
|
||||
// });
|
||||
|
||||
const config = getCurrentConfig();
|
||||
|
||||
const connectionClickAction = getConnectionClickActionSetting();
|
||||
if (connectionClickAction == 'openDetails') {
|
||||
if (config.runAsPortal == false && !config.storageDatabase) {
|
||||
openNewTab({
|
||||
title: getConnectionLabel(data),
|
||||
icon: 'img connection',
|
||||
tabComponent: 'ConnectionTab',
|
||||
tabPreviewMode: true,
|
||||
props: {
|
||||
conid: data._id,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
if (connectionClickAction == 'connect') {
|
||||
await tick();
|
||||
handleConnect();
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseDown = () => {
|
||||
focusedConnectionOrDatabase.set({
|
||||
conid: data?._id,
|
||||
connection: data,
|
||||
database: data.singleDatabase ? data.defaultDatabase : null,
|
||||
});
|
||||
};
|
||||
|
||||
const handleSqlRestore = () => {
|
||||
showModal(ImportDatabaseDumpModal, {
|
||||
connection: data,
|
||||
@@ -222,6 +291,18 @@
|
||||
};
|
||||
|
||||
return [
|
||||
!data.singleDatabase && [
|
||||
!$openedConnections.includes(data._id) && {
|
||||
text: 'Connect',
|
||||
onClick: handleConnect,
|
||||
isBold: true,
|
||||
},
|
||||
$openedConnections.includes(data._id) && {
|
||||
text: 'Disconnect',
|
||||
onClick: handleDisconnect,
|
||||
},
|
||||
],
|
||||
{ divider: true },
|
||||
config.runAsPortal == false &&
|
||||
!config.storageDatabase && [
|
||||
{
|
||||
@@ -237,21 +318,14 @@
|
||||
onClick: handleDuplicate,
|
||||
},
|
||||
],
|
||||
{ divider: true },
|
||||
!data.singleDatabase && [
|
||||
!$openedConnections.includes(data._id) && {
|
||||
text: 'Connect',
|
||||
onClick: handleConnect,
|
||||
},
|
||||
hasPermission(`dbops/query`) && { onClick: handleNewQuery, text: 'New query', isNewQuery: true },
|
||||
$openedConnections.includes(data._id) &&
|
||||
data.status && {
|
||||
text: 'Refresh',
|
||||
onClick: handleRefresh,
|
||||
},
|
||||
$openedConnections.includes(data._id) && {
|
||||
text: 'Disconnect',
|
||||
onClick: handleDisconnect,
|
||||
},
|
||||
hasPermission(`dbops/createdb`) &&
|
||||
$openedConnections.includes(data._id) &&
|
||||
driver?.supportedCreateDatabase &&
|
||||
@@ -319,8 +393,8 @@
|
||||
title={getConnectionLabel(data, { showUnsaved: true })}
|
||||
icon={data.singleDatabase ? 'img database' : 'img server'}
|
||||
isBold={data.singleDatabase
|
||||
? _.get($currentDatabase, 'connection._id') == data._id && _.get($currentDatabase, 'name') == data.defaultDatabase
|
||||
: _.get($currentDatabase, 'connection._id') == data._id}
|
||||
? $currentDatabase?.connection?._id == data._id && $currentDatabase?.name == data.defaultDatabase
|
||||
: $currentDatabase?.connection?._id == data._id}
|
||||
statusIcon={statusIcon || engineStatusIcon}
|
||||
statusTitle={statusTitle || engineStatusTitle}
|
||||
statusTitleToCopy={statusTitle || engineStatusTitle}
|
||||
@@ -329,12 +403,18 @@
|
||||
colorMark={passProps?.connectionColorFactory && passProps?.connectionColorFactory({ conid: data._id })}
|
||||
menu={getContextMenu}
|
||||
on:click={handleClick}
|
||||
on:click
|
||||
on:mousedown={handleMouseDown}
|
||||
on:dblclick
|
||||
on:expand
|
||||
on:dblclick={handleConnect}
|
||||
on:dblclick={handleDoubleClick}
|
||||
on:middleclick={() => {
|
||||
_.flattenDeep(getContextMenu())
|
||||
.find(x => x.isNewQuery)
|
||||
.onClick();
|
||||
}}
|
||||
isChoosed={data._id == $focusedConnectionOrDatabase?.conid &&
|
||||
(data.singleDatabase
|
||||
? $focusedConnectionOrDatabase?.database == data.defaultDatabase
|
||||
: !$focusedConnectionOrDatabase?.database)}
|
||||
disableBoldScroll={!!$focusedConnectionOrDatabase}
|
||||
/>
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
export const extractKey = props => props.name;
|
||||
|
||||
export const createMatcher = filter => props => {
|
||||
const { name, displayName, server } = props;
|
||||
return filterName(filter, name, displayName, server);
|
||||
};
|
||||
|
||||
export function disconnectDatabaseConnection(conid, database, showConfirmation = true) {
|
||||
const closeCondition = x =>
|
||||
x.props?.conid == conid &&
|
||||
@@ -351,11 +356,13 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
text: `New ${driver?.collectionSingularLabel ?? 'collection/container'}`,
|
||||
},
|
||||
hasPermission(`dbops/query`) &&
|
||||
driver?.databaseEngineTypes?.includes('sql') && { onClick: handleQueryDesigner, text: 'Design query' },
|
||||
driver?.databaseEngineTypes?.includes('sql') && {
|
||||
onClick: handleNewPerspective,
|
||||
text: 'Design perspective query',
|
||||
},
|
||||
driver?.databaseEngineTypes?.includes('sql') &&
|
||||
isProApp() && { onClick: handleQueryDesigner, text: 'Design query' },
|
||||
driver?.databaseEngineTypes?.includes('sql') &&
|
||||
isProApp() && {
|
||||
onClick: handleNewPerspective,
|
||||
text: 'Design perspective query',
|
||||
},
|
||||
connection.useSeparateSchemas && { onClick: handleRefreshSchemas, text: 'Refresh schemas' },
|
||||
|
||||
{ divider: true },
|
||||
@@ -446,12 +453,15 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
currentArchive,
|
||||
currentDatabase,
|
||||
extensions,
|
||||
focusedConnectionOrDatabase,
|
||||
getCurrentDatabase,
|
||||
getExtensions,
|
||||
getOpenedTabs,
|
||||
loadingSchemaLists,
|
||||
lockedDatabaseMode,
|
||||
openedConnections,
|
||||
openedSingleDatabaseConnections,
|
||||
openedTabs,
|
||||
pinnedDatabases,
|
||||
selectedWidget,
|
||||
visibleWidgetSideBar,
|
||||
@@ -460,7 +470,13 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import { showSnackbarError, showSnackbarSuccess } from '../utility/snackbar';
|
||||
import { extractDbNameFromComposite, extractPackageName, findEngineDriver, getConnectionLabel } from 'dbgate-tools';
|
||||
import {
|
||||
extractDbNameFromComposite,
|
||||
extractPackageName,
|
||||
filterName,
|
||||
findEngineDriver,
|
||||
getConnectionLabel,
|
||||
} from 'dbgate-tools';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
import { getDatabaseInfo, useUsedApps } from '../utility/metadataLoaders';
|
||||
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
||||
@@ -482,6 +498,8 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
import ExportDbModelModal from '../modals/ExportDbModelModal.svelte';
|
||||
import ChooseArchiveFolderModal from '../modals/ChooseArchiveFolderModal.svelte';
|
||||
import { extractShellConnection } from '../impexp/createImpExpScript';
|
||||
import { getNumberIcon } from '../icons/FontIcon.svelte';
|
||||
import { getDatabaseClickActionSetting } from '../settings/settingsTools';
|
||||
|
||||
export let data;
|
||||
export let passProps;
|
||||
@@ -509,10 +527,22 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
extInfo={data.extInfo}
|
||||
icon="img database"
|
||||
colorMark={passProps?.connectionColorFactory &&
|
||||
passProps?.connectionColorFactory({ conid: _.get(data.connection, '_id'), database: data.name }, null, null, false)}
|
||||
isBold={_.get($currentDatabase, 'connection._id') == _.get(data.connection, '_id') &&
|
||||
extractDbNameFromComposite(_.get($currentDatabase, 'name')) == data.name}
|
||||
on:click={() => switchCurrentDatabase(data)}
|
||||
passProps?.connectionColorFactory({ conid: data?.connection?._id, database: data.name }, null, null, false)}
|
||||
isBold={$currentDatabase?.connection?._id == data?.connection?._id &&
|
||||
extractDbNameFromComposite($currentDatabase?.name) == data.name}
|
||||
on:dblclick={() => {
|
||||
switchCurrentDatabase(data);
|
||||
// passProps?.onFocusSqlObjectList?.();
|
||||
}}
|
||||
on:click={() => {
|
||||
// switchCurrentDatabase(data);
|
||||
if (getDatabaseClickActionSetting() == 'switch') {
|
||||
switchCurrentDatabase(data);
|
||||
}
|
||||
}}
|
||||
on:mousedown={() => {
|
||||
$focusedConnectionOrDatabase = { conid: data.connection?._id, database: data.name, connection: data.connection };
|
||||
}}
|
||||
on:dragstart
|
||||
on:dragenter
|
||||
on:dragend
|
||||
@@ -522,7 +552,15 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
.find(x => x.isNewQuery)
|
||||
.onClick();
|
||||
}}
|
||||
statusIcon={isLoadingSchemas ? 'icon loading' : ''}
|
||||
statusIcon={isLoadingSchemas
|
||||
? 'icon loading'
|
||||
: $lockedDatabaseMode
|
||||
? getNumberIcon(
|
||||
$openedTabs.filter(
|
||||
x => !x.closedTime && x.props.conid == data?.connection?._id && x.props.database == data?.name
|
||||
).length
|
||||
)
|
||||
: ''}
|
||||
menu={createMenu}
|
||||
showPinnedInsteadOfUnpin={passProps?.showPinnedInsteadOfUnpin}
|
||||
onPin={isPinned ? null : () => pinnedDatabases.update(list => [...list, data])}
|
||||
@@ -532,4 +570,7 @@ await dbgateApi.dropAllDbObjects(${JSON.stringify(
|
||||
list.filter(x => x?.name != data?.name || x?.connection?._id != data?.connection?._id)
|
||||
)
|
||||
: null}
|
||||
isChoosed={data.connection?._id == $focusedConnectionOrDatabase?.conid &&
|
||||
data.name == $focusedConnectionOrDatabase?.database}
|
||||
disableBoldScroll={!!$focusedConnectionOrDatabase}
|
||||
/>
|
||||
|
||||
@@ -3,14 +3,34 @@
|
||||
|
||||
export const extractKey = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName);
|
||||
export const createMatcher =
|
||||
({ schemaName, pureName, columns }) =>
|
||||
filter =>
|
||||
filterName(
|
||||
filter,
|
||||
pureName,
|
||||
schemaName,
|
||||
...(columns?.map(({ columnName }) => ({ childName: columnName })) || [])
|
||||
);
|
||||
(filter, cfg = DEFAULT_OBJECT_SEARCH_SETTINGS) =>
|
||||
({ schemaName, pureName, objectComment, tableEngine, columns, objectTypeField, createSql }) => {
|
||||
const mainArgs = [];
|
||||
const childArgs = [];
|
||||
if (cfg.schemaName) mainArgs.push(schemaName);
|
||||
if (objectTypeField == 'tables') {
|
||||
if (cfg.tableName) mainArgs.push(pureName);
|
||||
if (cfg.tableComment) mainArgs.push(objectComment);
|
||||
if (cfg.tableEngine) mainArgs.push(tableEngine);
|
||||
|
||||
for (const column of columns || []) {
|
||||
if (cfg.columnName) childArgs.push(column.columnName);
|
||||
if (cfg.columnComment) childArgs.push(column.columnComment);
|
||||
if (cfg.columnDataType) childArgs.push(column.dataType);
|
||||
}
|
||||
} else if (objectTypeField == 'collections') {
|
||||
if (cfg.collectionName) mainArgs.push(pureName);
|
||||
} else {
|
||||
if (cfg.sqlObjectName) mainArgs.push(pureName);
|
||||
if (cfg.sqlObjectText) childArgs.push(createSql);
|
||||
}
|
||||
|
||||
const res = filterNameCompoud(filter, mainArgs, childArgs);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const disableShowChildrenWithParentMatch = true;
|
||||
|
||||
export const createTitle = ({ schemaName, pureName }) => (schemaName ? `${schemaName}.${pureName}` : pureName);
|
||||
|
||||
export const databaseObjectIcons = {
|
||||
@@ -29,12 +49,18 @@
|
||||
views: 'ViewDataTab',
|
||||
matviews: 'ViewDataTab',
|
||||
queries: 'QueryDataTab',
|
||||
procedures: 'SqlObjectTab',
|
||||
functions: 'SqlObjectTab',
|
||||
};
|
||||
|
||||
function createMenusCore(
|
||||
objectTypeField,
|
||||
driver
|
||||
): {
|
||||
function createScriptTemplatesSubmenu(objectTypeField) {
|
||||
return {
|
||||
label: 'SQL template',
|
||||
submenu: getSupportedScriptTemplates(objectTypeField),
|
||||
};
|
||||
}
|
||||
|
||||
interface DbObjMenuItem {
|
||||
label?: string;
|
||||
tab?: string;
|
||||
forceNewTab?: boolean;
|
||||
@@ -53,46 +79,61 @@
|
||||
isExport?: boolean;
|
||||
isImport?: boolean;
|
||||
isActiveChart?: boolean;
|
||||
isShowSql?: boolean;
|
||||
scriptTemplate?: string;
|
||||
sqlGeneratorProps?: any;
|
||||
isDropCollection?: boolean;
|
||||
isRenameCollection?: boolean;
|
||||
isDuplicateCollection?: boolean;
|
||||
}[] {
|
||||
submenu?: DbObjMenuItem[];
|
||||
}
|
||||
|
||||
function createMenusCore(objectTypeField, driver): DbObjMenuItem[] {
|
||||
switch (objectTypeField) {
|
||||
case 'tables':
|
||||
return [
|
||||
...defaultDatabaseObjectAppObjectActions['tables'],
|
||||
{
|
||||
label: 'Open data',
|
||||
tab: 'TableDataTab',
|
||||
forceNewTab: true,
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
label: 'Open form',
|
||||
tab: 'TableDataTab',
|
||||
forceNewTab: true,
|
||||
initialData: {
|
||||
grid: {
|
||||
isFormView: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'Open structure',
|
||||
tab: 'TableStructureTab',
|
||||
icon: 'img table-structure',
|
||||
},
|
||||
{
|
||||
isProApp() && {
|
||||
label: 'Design query',
|
||||
isQueryDesigner: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
{
|
||||
isProApp() && {
|
||||
label: 'Design perspective query',
|
||||
tab: 'PerspectiveTab',
|
||||
forceNewTab: true,
|
||||
icon: 'img perspective',
|
||||
},
|
||||
createScriptTemplatesSubmenu('tables'),
|
||||
{
|
||||
label: 'SQL generator',
|
||||
submenu: [
|
||||
{
|
||||
label: 'CREATE TABLE',
|
||||
sqlGeneratorProps: {
|
||||
createTables: true,
|
||||
createIndexes: true,
|
||||
createForeignKeys: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'DROP TABLE',
|
||||
sqlGeneratorProps: {
|
||||
dropTables: true,
|
||||
dropReferences: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'INSERT',
|
||||
sqlGeneratorProps: {
|
||||
insert: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
@@ -142,61 +183,44 @@
|
||||
label: 'Open active chart',
|
||||
isActiveChart: true,
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE TABLE',
|
||||
scriptTemplate: 'CREATE TABLE',
|
||||
},
|
||||
{
|
||||
label: 'SQL: SELECT',
|
||||
scriptTemplate: 'SELECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE TABLE',
|
||||
sqlGeneratorProps: {
|
||||
createTables: true,
|
||||
createIndexes: true,
|
||||
createForeignKeys: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: DROP TABLE',
|
||||
sqlGeneratorProps: {
|
||||
dropTables: true,
|
||||
dropReferences: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: INSERT',
|
||||
sqlGeneratorProps: {
|
||||
insert: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
case 'views':
|
||||
return [
|
||||
...defaultDatabaseObjectAppObjectActions['views'],
|
||||
{
|
||||
label: 'Open data',
|
||||
tab: 'ViewDataTab',
|
||||
forceNewTab: true,
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
label: 'Open structure',
|
||||
tab: 'TableStructureTab',
|
||||
icon: 'img view-structure',
|
||||
},
|
||||
{
|
||||
isProApp() && {
|
||||
label: 'Design query',
|
||||
isQueryDesigner: true,
|
||||
},
|
||||
{
|
||||
isProApp() && {
|
||||
label: 'Design perspective query',
|
||||
tab: 'PerspectiveTab',
|
||||
forceNewTab: true,
|
||||
icon: 'img perspective',
|
||||
},
|
||||
createScriptTemplatesSubmenu('views'),
|
||||
{
|
||||
label: 'SQL generator',
|
||||
submenu: [
|
||||
{
|
||||
label: 'CREATE VIEW',
|
||||
sqlGeneratorProps: {
|
||||
createViews: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'DROP VIEW',
|
||||
sqlGeneratorProps: {
|
||||
dropViews: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
hasPermission('dbops/model/edit') && {
|
||||
label: 'Drop view',
|
||||
isDrop: true,
|
||||
@@ -219,48 +243,12 @@
|
||||
label: 'Open active chart',
|
||||
isActiveChart: true,
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE VIEW',
|
||||
scriptTemplate: 'CREATE OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: ALTER VIEW',
|
||||
scriptTemplate: 'ALTER OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE TABLE',
|
||||
scriptTemplate: 'CREATE TABLE',
|
||||
},
|
||||
{
|
||||
label: 'SQL: SELECT',
|
||||
scriptTemplate: 'SELECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE VIEW',
|
||||
sqlGeneratorProps: {
|
||||
createViews: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: DROP VIEW',
|
||||
sqlGeneratorProps: {
|
||||
dropViews: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
case 'matviews':
|
||||
return [
|
||||
...defaultDatabaseObjectAppObjectActions['matviews'],
|
||||
{
|
||||
label: 'Open data',
|
||||
tab: 'ViewDataTab',
|
||||
forceNewTab: true,
|
||||
},
|
||||
{
|
||||
label: 'Open structure',
|
||||
tab: 'TableStructureTab',
|
||||
divider: true,
|
||||
},
|
||||
hasPermission('dbops/model/edit') && {
|
||||
label: 'Drop view',
|
||||
@@ -272,10 +260,31 @@
|
||||
isRename: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
label: 'Query designer',
|
||||
isQueryDesigner: true,
|
||||
},
|
||||
createScriptTemplatesSubmenu('matviews'),
|
||||
{
|
||||
label: 'SQL generator',
|
||||
submenu: [
|
||||
{
|
||||
label: 'CREATE MATERIALIZED VIEW',
|
||||
sqlGeneratorProps: {
|
||||
createMatviews: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'DROP MATERIALIZED VIEW',
|
||||
sqlGeneratorProps: {
|
||||
dropMatviews: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
@@ -288,37 +297,6 @@
|
||||
label: 'Open active chart',
|
||||
isActiveChart: true,
|
||||
},
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE MATERIALIZED VIEW',
|
||||
scriptTemplate: 'CREATE OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: ALTER MATERIALIZED VIEW',
|
||||
scriptTemplate: 'ALTER OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE TABLE',
|
||||
scriptTemplate: 'CREATE TABLE',
|
||||
},
|
||||
{
|
||||
label: 'SQL: SELECT',
|
||||
scriptTemplate: 'SELECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE MATERIALIZED VIEW',
|
||||
sqlGeneratorProps: {
|
||||
createMatviews: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: DROP MATERIALIZED VIEW',
|
||||
sqlGeneratorProps: {
|
||||
dropMatviews: true,
|
||||
},
|
||||
},
|
||||
];
|
||||
case 'queries':
|
||||
return [
|
||||
@@ -330,6 +308,10 @@
|
||||
];
|
||||
case 'procedures':
|
||||
return [
|
||||
...defaultDatabaseObjectAppObjectActions['procedures'],
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
hasPermission('dbops/model/edit') && {
|
||||
label: 'Drop procedure',
|
||||
isDrop: true,
|
||||
@@ -340,33 +322,31 @@
|
||||
isRename: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
createScriptTemplatesSubmenu('procedures'),
|
||||
{
|
||||
label: 'SQL: CREATE PROCEDURE',
|
||||
scriptTemplate: 'CREATE OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: ALTER PROCEDURE',
|
||||
scriptTemplate: 'ALTER OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: EXECUTE',
|
||||
scriptTemplate: 'EXECUTE PROCEDURE',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE PROCEDURE',
|
||||
sqlGeneratorProps: {
|
||||
createProcedures: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: DROP PROCEDURE',
|
||||
sqlGeneratorProps: {
|
||||
dropProcedures: true,
|
||||
},
|
||||
label: 'SQL generator',
|
||||
submenu: [
|
||||
{
|
||||
label: 'CREATE PROCEDURE',
|
||||
sqlGeneratorProps: {
|
||||
createProcedures: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'DROP PROCEDURE',
|
||||
sqlGeneratorProps: {
|
||||
dropProcedures: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
case 'functions':
|
||||
return [
|
||||
...defaultDatabaseObjectAppObjectActions['functions'],
|
||||
{
|
||||
divider: true,
|
||||
},
|
||||
hasPermission('dbops/model/edit') && {
|
||||
label: 'Drop function',
|
||||
isDrop: true,
|
||||
@@ -377,45 +357,32 @@
|
||||
isRename: true,
|
||||
requiresWriteAccess: true,
|
||||
},
|
||||
createScriptTemplatesSubmenu('functions'),
|
||||
{
|
||||
label: 'SQL: CREATE FUNCTION',
|
||||
scriptTemplate: 'CREATE OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: ALTER FUNCTION',
|
||||
scriptTemplate: 'ALTER OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE FUNCTION',
|
||||
sqlGeneratorProps: {
|
||||
createFunctions: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: DROP FUNCTION',
|
||||
sqlGeneratorProps: {
|
||||
dropFunctions: true,
|
||||
},
|
||||
label: 'SQL generator',
|
||||
submenu: [
|
||||
{
|
||||
label: 'CREATE FUNCTION',
|
||||
sqlGeneratorProps: {
|
||||
createFunctions: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: 'DROP FUNCTION',
|
||||
sqlGeneratorProps: {
|
||||
dropFunctions: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
case 'collections':
|
||||
return [
|
||||
...defaultDatabaseObjectAppObjectActions['collections'],
|
||||
{
|
||||
label: 'Open data',
|
||||
tab: 'CollectionDataTab',
|
||||
forceNewTab: true,
|
||||
divider: true,
|
||||
},
|
||||
{
|
||||
label: 'Open JSON',
|
||||
tab: 'CollectionDataTab',
|
||||
forceNewTab: true,
|
||||
initialData: {
|
||||
grid: {
|
||||
isJsonView: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
isProApp() && {
|
||||
label: 'Design perspective query',
|
||||
tab: 'PerspectiveTab',
|
||||
forceNewTab: true,
|
||||
@@ -659,15 +626,30 @@
|
||||
// fixedTargetPureName: data.pureName,
|
||||
// },
|
||||
// });
|
||||
// } else if (menu.isShowSql) {
|
||||
// openNewTab({
|
||||
// title: data.pureName,
|
||||
// icon: 'img sql-file',
|
||||
// tabComponent: 'SqlObjectTab',
|
||||
// tabPreviewMode: true,
|
||||
// props: {
|
||||
// conid: data.conid,
|
||||
// database: data.database,
|
||||
// schemaName: data.schemaName,
|
||||
// pureName: data.pureName,
|
||||
// objectTypeField: data.objectTypeField,
|
||||
// },
|
||||
// });
|
||||
} else {
|
||||
openDatabaseObjectDetail(
|
||||
menu.tab,
|
||||
menu.scriptTemplate,
|
||||
data,
|
||||
{ ...data, defaultActionId: menu.defaultActionId },
|
||||
menu.forceNewTab,
|
||||
menu.initialData,
|
||||
menu.icon,
|
||||
data
|
||||
data,
|
||||
!!menu.defaultActionId
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -697,11 +679,12 @@
|
||||
export async function openDatabaseObjectDetail(
|
||||
tabComponent,
|
||||
scriptTemplate,
|
||||
{ schemaName, pureName, conid, database, objectTypeField },
|
||||
{ schemaName, pureName, conid, database, objectTypeField, defaultActionId },
|
||||
forceNewTab?,
|
||||
initialData?,
|
||||
icon?,
|
||||
appObjectData?
|
||||
appObjectData?,
|
||||
tabPreviewMode?
|
||||
) {
|
||||
const connection = await getConnectionInfo({ conid });
|
||||
const tooltip = `${getConnectionLabel(connection)}\n${database}\n${fullDisplayName({
|
||||
@@ -711,12 +694,16 @@
|
||||
|
||||
openNewTab(
|
||||
{
|
||||
title: scriptTemplate ? 'Query #' : getObjectTitle(connection, schemaName, pureName),
|
||||
// title: getObjectTitle(connection, schemaName, pureName),
|
||||
title: tabComponent ? getObjectTitle(connection, schemaName, pureName) : 'Query #',
|
||||
tooltip,
|
||||
icon: icon || (scriptTemplate ? 'img sql-file' : databaseObjectIcons[objectTypeField]),
|
||||
tabComponent: scriptTemplate ? 'QueryTab' : tabComponent,
|
||||
icon:
|
||||
icon ||
|
||||
(scriptTemplate || tabComponent == 'SqlObjectTab' ? 'img sql-file' : databaseObjectIcons[objectTypeField]),
|
||||
tabComponent: tabComponent ?? 'QueryTab',
|
||||
appObject: 'DatabaseObjectAppObject',
|
||||
appObjectData,
|
||||
tabPreviewMode,
|
||||
props: {
|
||||
schemaName,
|
||||
pureName,
|
||||
@@ -724,38 +711,79 @@
|
||||
database,
|
||||
objectTypeField,
|
||||
initialArgs: scriptTemplate ? { scriptTemplate } : null,
|
||||
defaultActionId,
|
||||
},
|
||||
},
|
||||
initialData,
|
||||
{ forceNewTab }
|
||||
);
|
||||
|
||||
if (tabPreviewMode && defaultActionId && getBoolSettingsValue('defaultAction.useLastUsedAction', true)) {
|
||||
lastUsedDefaultActions.update(actions => ({
|
||||
...actions,
|
||||
[objectTypeField]: defaultActionId,
|
||||
}));
|
||||
// apiCall('config/update-settings', {
|
||||
// [`defaultAction.dbObjectClick.${objectTypeField}`]: defaultActionId,
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
export function handleDatabaseObjectClick(data, forceNewTab = false) {
|
||||
export function handleDatabaseObjectClick(
|
||||
data,
|
||||
{ forceNewTab = false, tabPreviewMode = false, focusTab = false } = {}
|
||||
) {
|
||||
const { schemaName, pureName, conid, database, objectTypeField } = data;
|
||||
const driver = findEngineDriver(data, getExtensions());
|
||||
|
||||
const configuredAction = getCurrentSettings()[`defaultAction.dbObjectClick.${objectTypeField}`];
|
||||
const overrideMenu = createMenus(objectTypeField, driver).find(x => x.label && x.label == configuredAction);
|
||||
if (overrideMenu) {
|
||||
databaseObjectMenuClickHandler(data, overrideMenu);
|
||||
const activeTab = getActiveTab();
|
||||
const activeTabProps = activeTab?.props || {};
|
||||
// const activeDefaultActionId = activeTab?.props?.defaultActionId;
|
||||
|
||||
if (matchDatabaseObjectAppObject(data, activeTabProps)) {
|
||||
if (!tabPreviewMode) {
|
||||
openedTabs.update(tabs => {
|
||||
return tabs.map(tab => ({
|
||||
...tab,
|
||||
tabPreviewMode: tab.tabid == activeTab.tabid ? false : tab.tabPreviewMode,
|
||||
focused: focusTab && tab.tabid == activeTab.tabid ? true : tab.focused,
|
||||
}));
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const availableDefaultActions = defaultDatabaseObjectAppObjectActions[objectTypeField];
|
||||
|
||||
const configuredActionId = getLastUsedDefaultActions()[objectTypeField];
|
||||
const prefferedAction =
|
||||
// availableDefaultActions.find(x => x.defaultActionId == activeDefaultActionId) ??
|
||||
availableDefaultActions.find(x => x.defaultActionId == configuredActionId) ?? availableDefaultActions[0];
|
||||
|
||||
// console.log('activeTab', activeTab);
|
||||
|
||||
// const overrideMenu = createMenus(objectTypeField, driver).find(x => x.label && x.label == configuredAction);
|
||||
// if (overrideMenu) {
|
||||
// databaseObjectMenuClickHandler(data, overrideMenu);
|
||||
// return;
|
||||
// }
|
||||
|
||||
openDatabaseObjectDetail(
|
||||
defaultTabs[objectTypeField],
|
||||
defaultTabs[objectTypeField] ? null : 'CREATE OBJECT',
|
||||
prefferedAction.tab,
|
||||
activeTabProps?.scriptTemplate,
|
||||
{
|
||||
schemaName,
|
||||
pureName,
|
||||
conid,
|
||||
database,
|
||||
objectTypeField,
|
||||
defaultActionId: prefferedAction.defaultActionId,
|
||||
},
|
||||
forceNewTab,
|
||||
null,
|
||||
null,
|
||||
data
|
||||
data,
|
||||
tabPreviewMode
|
||||
);
|
||||
}
|
||||
|
||||
@@ -769,64 +797,84 @@
|
||||
);
|
||||
}
|
||||
|
||||
function menuItemMapper(menu, data, connection) {
|
||||
if (menu.divider) return menu;
|
||||
|
||||
if (menu.isExport) {
|
||||
return createQuickExportMenu(
|
||||
fmt => async () => {
|
||||
const coninfo = await getConnectionInfo(data);
|
||||
exportQuickExportFile(
|
||||
data.pureName,
|
||||
{
|
||||
functionName: menu.functionName,
|
||||
props: {
|
||||
connection: extractShellConnection(coninfo, data.database),
|
||||
..._.pick(data, ['pureName', 'schemaName']),
|
||||
},
|
||||
},
|
||||
fmt
|
||||
);
|
||||
},
|
||||
{
|
||||
onClick: () => {
|
||||
openImportExportTab({
|
||||
sourceStorageType: 'database',
|
||||
sourceConnectionId: data.conid,
|
||||
sourceDatabaseName: extractDbNameFromComposite(data.database),
|
||||
sourceSchemaName: data.schemaName,
|
||||
sourceList: [data.pureName],
|
||||
});
|
||||
// showModal(ImportExportModal, {
|
||||
// initialValues: {
|
||||
// sourceStorageType: 'database',
|
||||
// sourceConnectionId: data.conid,
|
||||
// sourceDatabaseName: data.database,
|
||||
// sourceSchemaName: data.schemaName,
|
||||
// sourceList: [data.pureName],
|
||||
// },
|
||||
// });
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (connection?.isReadOnly && menu.requiresWriteAccess) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (menu.submenu) {
|
||||
return {
|
||||
...menu,
|
||||
submenu: menu.submenu.map(x => menuItemMapper(x, data, connection)),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
text: menu.label,
|
||||
onClick: () => {
|
||||
databaseObjectMenuClickHandler(data, menu);
|
||||
},
|
||||
iconAlt: menu.defaultActionId ? 'icon open-in-new' : null,
|
||||
onClickAlt: menu.defaultActionId
|
||||
? () => {
|
||||
databaseObjectMenuClickHandler(data, { ...menu, forceNewTab: true, defaultActionId: null });
|
||||
}
|
||||
: null,
|
||||
isBold:
|
||||
data.objectTypeField &&
|
||||
menu.defaultActionId &&
|
||||
getLastUsedDefaultActions()[data.objectTypeField] == menu.defaultActionId,
|
||||
};
|
||||
}
|
||||
|
||||
export function createDatabaseObjectMenu(data, connection = null) {
|
||||
const driver = findEngineDriver(data, getExtensions());
|
||||
|
||||
const { objectTypeField } = data;
|
||||
return createMenus(objectTypeField, driver)
|
||||
.filter(x => x)
|
||||
.map(menu => {
|
||||
if (menu.divider) return menu;
|
||||
|
||||
if (menu.isExport) {
|
||||
return createQuickExportMenu(
|
||||
fmt => async () => {
|
||||
const coninfo = await getConnectionInfo(data);
|
||||
exportQuickExportFile(
|
||||
data.pureName,
|
||||
{
|
||||
functionName: menu.functionName,
|
||||
props: {
|
||||
connection: extractShellConnection(coninfo, data.database),
|
||||
..._.pick(data, ['pureName', 'schemaName']),
|
||||
},
|
||||
},
|
||||
fmt
|
||||
);
|
||||
},
|
||||
{
|
||||
onClick: () => {
|
||||
openImportExportTab({
|
||||
sourceStorageType: 'database',
|
||||
sourceConnectionId: data.conid,
|
||||
sourceDatabaseName: extractDbNameFromComposite(data.database),
|
||||
sourceSchemaName: data.schemaName,
|
||||
sourceList: [data.pureName],
|
||||
});
|
||||
// showModal(ImportExportModal, {
|
||||
// initialValues: {
|
||||
// sourceStorageType: 'database',
|
||||
// sourceConnectionId: data.conid,
|
||||
// sourceDatabaseName: data.database,
|
||||
// sourceSchemaName: data.schemaName,
|
||||
// sourceList: [data.pureName],
|
||||
// },
|
||||
// });
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (connection?.isReadOnly && menu.requiresWriteAccess) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
text: menu.label,
|
||||
onClick: () => {
|
||||
databaseObjectMenuClickHandler(data, menu);
|
||||
},
|
||||
};
|
||||
});
|
||||
.map(menu => menuItemMapper(menu, data, connection));
|
||||
}
|
||||
|
||||
function formatRowCount(value) {
|
||||
@@ -838,6 +886,38 @@
|
||||
export function createAppObjectMenu(data) {
|
||||
return createDatabaseObjectMenu(data);
|
||||
}
|
||||
|
||||
export function handleObjectClick(data, clickAction) {
|
||||
// on:click={() => handleObjectClick(data, { tabPreviewMode: true })}
|
||||
// on:middleclick={() => handleObjectClick(data, { forceNewTab: true })}
|
||||
// on:dblclick={() => handleObjectClick(data, { tabPreviewMode: false, focusTab: true })}
|
||||
const openDetailOnArrows = getOpenDetailOnArrowsSettings();
|
||||
|
||||
let forceNewTab = false;
|
||||
let tabPreviewMode = false;
|
||||
let focusTab = false;
|
||||
|
||||
switch (clickAction) {
|
||||
case 'leftClick':
|
||||
tabPreviewMode = true;
|
||||
break;
|
||||
case 'middleClick':
|
||||
forceNewTab = true;
|
||||
break;
|
||||
case 'dblClick':
|
||||
focusTab = true;
|
||||
break;
|
||||
case 'keyEnter':
|
||||
focusTab = true;
|
||||
break;
|
||||
case 'keyArrow':
|
||||
if (!openDetailOnArrows) return;
|
||||
tabPreviewMode = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return handleDatabaseObjectClick(data, { forceNewTab, tabPreviewMode, focusTab });
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -845,16 +925,24 @@
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import {
|
||||
currentDatabase,
|
||||
DEFAULT_OBJECT_SEARCH_SETTINGS,
|
||||
extensions,
|
||||
getActiveTab,
|
||||
getCurrentSettings,
|
||||
getDatabaseObjectAppObjectSearchSettings,
|
||||
getExtensions,
|
||||
getLastUsedDefaultActions,
|
||||
lastUsedDefaultActions,
|
||||
openedConnections,
|
||||
openedTabs,
|
||||
pinnedTables,
|
||||
selectedDatabaseObjectAppObject,
|
||||
} from '../stores';
|
||||
import openNewTab from '../utility/openNewTab';
|
||||
import {
|
||||
extractDbNameFromComposite,
|
||||
filterName,
|
||||
filterNameCompoud,
|
||||
generateDbPairingId,
|
||||
getAlterDatabaseScript,
|
||||
getConnectionLabel,
|
||||
@@ -877,20 +965,23 @@
|
||||
import { getDefaultFileFormat } from '../plugins/fileformats';
|
||||
import hasPermission from '../utility/hasPermission';
|
||||
import { openImportExportTab } from '../utility/importExportTools';
|
||||
import { defaultDatabaseObjectAppObjectActions, matchDatabaseObjectAppObject } from './appObjectTools';
|
||||
import { getSupportedScriptTemplates } from '../utility/applyScriptTemplate';
|
||||
import { getBoolSettingsValue, getOpenDetailOnArrowsSettings } from '../settings/settingsTools';
|
||||
import { isProApp } from '../utility/proTools';
|
||||
|
||||
export let data;
|
||||
export let passProps;
|
||||
|
||||
function handleClick(forceNewTab = false) {
|
||||
handleDatabaseObjectClick(data, forceNewTab);
|
||||
}
|
||||
|
||||
function createMenu() {
|
||||
return createDatabaseObjectMenu(data, passProps?.connection);
|
||||
}
|
||||
|
||||
function getExtInfo(data) {
|
||||
const res = [];
|
||||
if (data.objectComment) {
|
||||
res.push(data.objectComment);
|
||||
}
|
||||
if (data.tableRowCount != null) {
|
||||
res.push(`${formatRowCount(data.tableRowCount)} rows`);
|
||||
}
|
||||
@@ -915,11 +1006,16 @@
|
||||
onPin={isPinned ? null : () => pinnedTables.update(list => [...list, data])}
|
||||
onUnpin={isPinned ? () => pinnedTables.update(list => list.filter(x => !testEqual(x, data))) : null}
|
||||
extInfo={getExtInfo(data)}
|
||||
on:click={() => handleClick()}
|
||||
on:middleclick={() => handleClick(true)}
|
||||
isChoosed={matchDatabaseObjectAppObject($selectedDatabaseObjectAppObject, data)}
|
||||
on:click={() => handleObjectClick(data, 'leftClick')}
|
||||
on:middleclick={() => handleObjectClick(data, 'middleClick')}
|
||||
on:dblclick={() => handleObjectClick(data, 'dblClick')}
|
||||
on:expand
|
||||
on:dragstart
|
||||
on:dragenter
|
||||
on:dragend
|
||||
on:drop
|
||||
on:mousedown={() => {
|
||||
$selectedDatabaseObjectAppObject = _.pick(data, ['conid', 'database', 'objectTypeField', 'pureName', 'schemaName']);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = data => data.name;
|
||||
export const createMatcher = ({ name, title }) => filter => filterName(filter, name, title);
|
||||
export const createMatcher =
|
||||
filter =>
|
||||
({ name, title }) =>
|
||||
filterName(filter, name, title);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = ({ columnName }) => columnName;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<AppObjectCore
|
||||
{...$$restProps}
|
||||
{data}
|
||||
title={data.parameterName?.startsWith('@') ? data.parameterName.substring(1) : data.parameterName}
|
||||
extInfo={data.parameterMode && data.parameterMode !== 'IN' ? `${data.dataType} ${data.parameterMode}` : data.dataType}
|
||||
icon={'icon parameter'}
|
||||
disableHover
|
||||
/>
|
||||
@@ -0,0 +1,23 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = ({ columnName }) => columnName;
|
||||
|
||||
export const createMatcher =
|
||||
(filter, cfg = DEFAULT_OBJECT_SEARCH_SETTINGS) =>
|
||||
data => {
|
||||
const filterArgs = [];
|
||||
if (cfg.sqlObjectText) filterArgs.push(data.lineData);
|
||||
|
||||
const res = filterName(filter, ...filterArgs);
|
||||
return res;
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import AppObjectCore from './AppObjectCore.svelte';
|
||||
import { filterName } from 'dbgate-tools';
|
||||
import { DEFAULT_OBJECT_SEARCH_SETTINGS } from '../stores';
|
||||
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<AppObjectCore {...$$restProps} {data} icon="icon text" title={data.lineData?.substring(0, 100)} disableHover />
|
||||
@@ -104,8 +104,8 @@
|
||||
|
||||
export const extractKey = data => data.file;
|
||||
export const createMatcher =
|
||||
({ file }) =>
|
||||
filter =>
|
||||
({ file }) =>
|
||||
filterName(filter, file);
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,23 +1,32 @@
|
||||
<script lang="ts">
|
||||
import { filterName } from 'dbgate-tools';
|
||||
import { filterName, getConnectionLabel } from 'dbgate-tools';
|
||||
import _ from 'lodash';
|
||||
import { useDatabaseList } from '../utility/metadataLoaders';
|
||||
import AppObjectList from './AppObjectList.svelte';
|
||||
import * as databaseAppObject from './DatabaseAppObject.svelte';
|
||||
import { volatileConnectionMapStore } from '../utility/api';
|
||||
import { getLocalStorage } from '../utility/storageCache';
|
||||
|
||||
export let filter;
|
||||
export let data;
|
||||
export let passProps;
|
||||
|
||||
$: databases = useDatabaseList({ conid: data._id });
|
||||
export let isExpandedBySearch;
|
||||
export let isExpanded;
|
||||
export let isMainMatched;
|
||||
|
||||
$: isExpandedOnlyBySearch = isExpandedBySearch && !isExpanded;
|
||||
|
||||
$: databases = useDatabaseList({ conid: isExpandedOnlyBySearch ? null : data._id });
|
||||
$: dbList = isExpandedOnlyBySearch ? getLocalStorage(`database_list_${data._id}`) || [] : $databases || [];
|
||||
|
||||
// .filter(x => filterName(filter, x.name, data.displayName, data.server))
|
||||
</script>
|
||||
|
||||
<AppObjectList
|
||||
list={_.sortBy(
|
||||
($databases || []).filter(x => filterName(filter, x.name)),
|
||||
x => x.sortOrder ?? x.name
|
||||
).map(db => ({ ...db, connection: data }))}
|
||||
list={_.sortBy(dbList, x => x.sortOrder ?? x.name).map(db => ({ ...db, connection: data }))}
|
||||
module={databaseAppObject}
|
||||
{passProps}
|
||||
filter={isMainMatched ? '' : filter}
|
||||
{isExpandedBySearch}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<script lang="ts" context="module">
|
||||
export const extractKey = ({ lineData }) => lineData;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import AppObjectList from './AppObjectList.svelte';
|
||||
import * as procedureLineAppObject from './ProcedureLineAppObject.svelte';
|
||||
|
||||
export let data;
|
||||
export let filter;
|
||||
export let isExpandedBySearch;
|
||||
</script>
|
||||
|
||||
<AppObjectList
|
||||
list={(data.createSql?.split('\n') || []).map(lineData => ({
|
||||
lineData,
|
||||
}))}
|
||||
module={procedureLineAppObject}
|
||||
{filter}
|
||||
{isExpandedBySearch}
|
||||
/>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import AppObjectList from './AppObjectList.svelte';
|
||||
import * as parameterAppObject from './ParameterAppObject.svelte';
|
||||
|
||||
export let data;
|
||||
</script>
|
||||
|
||||
<AppObjectList
|
||||
list={(data.parameters || []).map(parameter => ({
|
||||
...data,
|
||||
...parameter,
|
||||
}))}
|
||||
module={parameterAppObject}
|
||||
/>
|
||||
+4
@@ -5,6 +5,8 @@
|
||||
import * as columnAppObject from './ColumnAppObject.svelte';
|
||||
|
||||
export let data;
|
||||
export let filter;
|
||||
export let isExpandedBySearch;
|
||||
</script>
|
||||
|
||||
<AppObjectList
|
||||
@@ -14,4 +16,6 @@
|
||||
foreignKey: findForeignKeyForColumn(data, col),
|
||||
}))}
|
||||
module={columnAppObject}
|
||||
{filter}
|
||||
{isExpandedBySearch}
|
||||
/>
|
||||
@@ -0,0 +1,80 @@
|
||||
export function matchDatabaseObjectAppObject(obj1, obj2) {
|
||||
return (
|
||||
obj1?.objectTypeField == obj2?.objectTypeField &&
|
||||
obj1?.conid == obj2?.conid &&
|
||||
obj1?.database == obj2?.database &&
|
||||
obj1?.pureName == obj2?.pureName &&
|
||||
obj1?.schemaName == obj2?.schemaName
|
||||
);
|
||||
}
|
||||
|
||||
function getTableLikeActions(dataTab) {
|
||||
return [
|
||||
{
|
||||
label: 'Open data',
|
||||
tab: dataTab,
|
||||
defaultActionId: 'openTable',
|
||||
},
|
||||
// {
|
||||
// label: 'Open form',
|
||||
// tab: dataTab,
|
||||
// initialData: {
|
||||
// grid: {
|
||||
// isFormView: true,
|
||||
// },
|
||||
// },
|
||||
// defaultActionId: 'openForm',
|
||||
// },
|
||||
{
|
||||
label: 'Open structure',
|
||||
tab: 'TableStructureTab',
|
||||
icon: 'img table-structure',
|
||||
defaultActionId: 'openStructure',
|
||||
},
|
||||
{
|
||||
label: 'Show SQL',
|
||||
tab: 'SqlObjectTab',
|
||||
defaultActionId: 'showSql',
|
||||
icon: 'img sql-file',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export const defaultDatabaseObjectAppObjectActions = {
|
||||
tables: getTableLikeActions('TableDataTab'),
|
||||
views: getTableLikeActions('ViewDataTab'),
|
||||
matviews: getTableLikeActions('ViewDataTab'),
|
||||
procedures: [
|
||||
{
|
||||
label: 'Show SQL',
|
||||
tab: 'SqlObjectTab',
|
||||
defaultActionId: 'showSql',
|
||||
icon: 'img sql-file',
|
||||
},
|
||||
],
|
||||
functions: [
|
||||
{
|
||||
label: 'Show SQL',
|
||||
tab: 'SqlObjectTab',
|
||||
defaultActionId: 'showSql',
|
||||
icon: 'img sql-file',
|
||||
},
|
||||
],
|
||||
collections: [
|
||||
{
|
||||
label: 'Open data',
|
||||
tab: 'CollectionDataTab',
|
||||
defaultActionId: 'openTable',
|
||||
},
|
||||
{
|
||||
label: 'Open JSON',
|
||||
tab: 'CollectionDataTab',
|
||||
defaultActionId: 'openJson',
|
||||
initialData: {
|
||||
grid: {
|
||||
isJsonView: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -7,20 +7,32 @@
|
||||
|
||||
export let icon = 'icon chevron-down';
|
||||
export let menu;
|
||||
export let asyncMenu = undefined;
|
||||
export let narrow = false;
|
||||
export let square = true;
|
||||
export let disabled = false;
|
||||
let domButton;
|
||||
|
||||
function handleClick() {
|
||||
let domButton;
|
||||
let isLoading = false;
|
||||
|
||||
async function handleClick() {
|
||||
if (disabled) return;
|
||||
|
||||
|
||||
let items = menu;
|
||||
|
||||
if (asyncMenu) {
|
||||
isLoading = true;
|
||||
items = await asyncMenu();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
const rect = domButton.getBoundingClientRect();
|
||||
const left = rect.left;
|
||||
const top = rect.bottom;
|
||||
currentDropDownMenu.set({ left, top, items: menu });
|
||||
currentDropDownMenu.set({ left, top, items });
|
||||
}
|
||||
</script>
|
||||
|
||||
<InlineButton square {narrow} on:click={handleClick} bind:this={domButton} {disabled}>
|
||||
<FontIcon {icon} />
|
||||
<InlineButton {square} {narrow} on:click={handleClick} bind:this={domButton} {disabled}>
|
||||
<FontIcon icon={isLoading ? 'icon loading' : icon} />
|
||||
</InlineButton>
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
export let disabled = false;
|
||||
export let value;
|
||||
export let title = null;
|
||||
export let skipWidth = false;
|
||||
export let outline = false;
|
||||
|
||||
function handleClick() {
|
||||
if (!disabled) dispatch('click');
|
||||
@@ -19,27 +21,53 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<input {type} {value} {title} class:disabled {...$$restProps} on:click={handleClick} bind:this={domButton} />
|
||||
<input
|
||||
{type}
|
||||
{value}
|
||||
{title}
|
||||
class:disabled
|
||||
{...$$restProps}
|
||||
on:click={handleClick}
|
||||
bind:this={domButton}
|
||||
class:skipWidth
|
||||
class:outline
|
||||
/>
|
||||
|
||||
<style>
|
||||
input {
|
||||
border: 1px solid var(--theme-bg-button-inv-2);
|
||||
padding: 5px;
|
||||
margin: 2px;
|
||||
width: 100px;
|
||||
background-color: var(--theme-bg-button-inv);
|
||||
color: var(--theme-font-inv-1);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
input:hover:not(.disabled) {
|
||||
input:not(.skipWidth) {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
input:hover:not(.disabled):not(.outline) {
|
||||
background-color: var(--theme-bg-button-inv-2);
|
||||
}
|
||||
input:active:not(.disabled) {
|
||||
input:active:not(.disabled):not(.outline) {
|
||||
background-color: var(--theme-bg-button-inv-3);
|
||||
}
|
||||
input.disabled {
|
||||
background-color: var(--theme-bg-button-inv-3);
|
||||
color: var(--theme-font-inv-3);
|
||||
}
|
||||
|
||||
input.outline {
|
||||
background-color: transparent;
|
||||
color: var(--theme-font-2);
|
||||
border: 1px solid var(--theme-bg-button-inv-2);
|
||||
}
|
||||
|
||||
input.outline:hover:not(.disabled) {
|
||||
color: var(--theme-bg-button-inv-3);
|
||||
border: 2px solid var(--theme-bg-button-inv-3);
|
||||
margin: 1px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -11,7 +11,16 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="outer buttonLike" {title} class:disabled class:square class:narrow on:click bind:this={domButton}>
|
||||
<div
|
||||
class="outer buttonLike"
|
||||
{title}
|
||||
class:disabled
|
||||
class:square
|
||||
class:narrow
|
||||
on:click
|
||||
bind:this={domButton}
|
||||
data-testid={$$props['data-testid']}
|
||||
>
|
||||
<div class="inner">
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
@@ -173,17 +173,19 @@ registerCommand({
|
||||
},
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'new.queryDesign',
|
||||
category: 'New',
|
||||
icon: 'img query-design',
|
||||
name: 'Query design',
|
||||
menuName: 'New query design',
|
||||
onClick: () => newQueryDesign(),
|
||||
testEnabled: () =>
|
||||
getCurrentDatabase() &&
|
||||
findEngineDriver(getCurrentDatabase()?.connection, getExtensions())?.databaseEngineTypes?.includes('sql'),
|
||||
});
|
||||
if (isProApp()) {
|
||||
registerCommand({
|
||||
id: 'new.queryDesign',
|
||||
category: 'New',
|
||||
icon: 'img query-design',
|
||||
name: 'Query design',
|
||||
menuName: 'New query design',
|
||||
onClick: () => newQueryDesign(),
|
||||
testEnabled: () =>
|
||||
getCurrentDatabase() &&
|
||||
findEngineDriver(getCurrentDatabase()?.connection, getExtensions())?.databaseEngineTypes?.includes('sql'),
|
||||
});
|
||||
}
|
||||
|
||||
if (isProApp()) {
|
||||
registerCommand({
|
||||
@@ -229,14 +231,16 @@ if (isProApp()) {
|
||||
});
|
||||
}
|
||||
|
||||
registerCommand({
|
||||
id: 'new.perspective',
|
||||
category: 'New',
|
||||
icon: 'img perspective',
|
||||
name: 'Perspective',
|
||||
menuName: 'New perspective',
|
||||
onClick: () => newPerspective(),
|
||||
});
|
||||
if (isProApp()) {
|
||||
registerCommand({
|
||||
id: 'new.perspective',
|
||||
category: 'New',
|
||||
icon: 'img perspective',
|
||||
name: 'Perspective',
|
||||
menuName: 'New perspective',
|
||||
onClick: () => newPerspective(),
|
||||
});
|
||||
}
|
||||
|
||||
registerCommand({
|
||||
id: 'new.diagram',
|
||||
@@ -942,6 +946,14 @@ registerCommand({
|
||||
onClick: () => showModal(UploadErrorModal),
|
||||
});
|
||||
|
||||
registerCommand({
|
||||
id: 'app.unsetCurrentDatabase',
|
||||
category: 'Application',
|
||||
name: 'Unset current database',
|
||||
testEnabled: () => getCurrentDatabase() != null,
|
||||
onClick: () => currentDatabase.set(null),
|
||||
});
|
||||
|
||||
const electron = getElectron();
|
||||
if (electron) {
|
||||
electron.addEventListener('run-command', (e, commandId) => runCommand(commandId));
|
||||
|
||||
@@ -142,6 +142,8 @@
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let isColumnManagerFocused = false;
|
||||
</script>
|
||||
|
||||
{#if allowChangeChangeSetStructure}
|
||||
@@ -207,9 +209,13 @@
|
||||
bind:this={domFocusField}
|
||||
on:keydown={handleKeyDown}
|
||||
on:focus={() => {
|
||||
isColumnManagerFocused = true;
|
||||
// activator.activate();
|
||||
// invalidateCommands();
|
||||
}}
|
||||
on:blur={() => {
|
||||
isColumnManagerFocused = false;
|
||||
}}
|
||||
on:copy={copyToClipboard}
|
||||
/>
|
||||
|
||||
@@ -224,10 +230,12 @@
|
||||
{database}
|
||||
{tableInfo}
|
||||
{setTableInfo}
|
||||
{isColumnManagerFocused}
|
||||
columnInfo={tableInfo?.columns?.[columnIndex]}
|
||||
{columnIndex}
|
||||
{allowChangeChangeSetStructure}
|
||||
isSelected={selectedColumns.includes(column.uniqueName) || currentColumnUniqueName == column.uniqueName}
|
||||
{filter}
|
||||
on:click={() => {
|
||||
if (domFocusField) domFocusField.focus();
|
||||
selectedColumns = [column.uniqueName];
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
export let conid;
|
||||
export let database;
|
||||
export let isDynamicStructure;
|
||||
export let filter = undefined;
|
||||
|
||||
export let tableInfo;
|
||||
export let setTableInfo;
|
||||
@@ -22,6 +23,8 @@
|
||||
export let columnInfo = null;
|
||||
export let columnIndex = -1;
|
||||
|
||||
export let isColumnManagerFocused = false;
|
||||
|
||||
export let allowChangeChangeSetStructure = false;
|
||||
$: addDataCommand = allowChangeChangeSetStructure;
|
||||
|
||||
@@ -49,6 +52,7 @@
|
||||
else display.focusColumns([column.uniqueName]);
|
||||
}}
|
||||
class:isSelected
|
||||
class:isFocused={isColumnManagerFocused}
|
||||
on:click
|
||||
on:mousedown
|
||||
on:mousemove
|
||||
@@ -80,7 +84,7 @@
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
<ColumnLabel {...column} showDataType {conid} {database} />
|
||||
<ColumnLabel {...column} showDataType {conid} {database} {filter} />
|
||||
</div>
|
||||
|
||||
{#if allowChangeChangeSetStructure && !isDynamicStructure}
|
||||
@@ -123,6 +127,10 @@
|
||||
}
|
||||
|
||||
.row.isSelected {
|
||||
background: var(--theme-bg-3);
|
||||
}
|
||||
|
||||
.row.isSelected.isFocused {
|
||||
background: var(--theme-bg-selected);
|
||||
}
|
||||
|
||||
|
||||
@@ -54,6 +54,8 @@
|
||||
|
||||
// don't parse JSON for explicit data types
|
||||
$: jsonParsedValue = !editorTypes?.explicitDataType && isJsonLikeLongString(value) ? safeJsonParse(value) : null;
|
||||
|
||||
$: showHint = allowHintField && rowData && _.some(col.hintColumnNames, hintColumnName => rowData[hintColumnName]);
|
||||
</script>
|
||||
|
||||
<td
|
||||
@@ -68,11 +70,12 @@
|
||||
class:isDeleted
|
||||
class:isAutofillSelected
|
||||
class:isFocusedColumn
|
||||
class:alignRight={_.isNumber(value) && !showHint}
|
||||
{style}
|
||||
>
|
||||
<CellValue {rowData} {value} {jsonParsedValue} {editorTypes} />
|
||||
|
||||
{#if allowHintField && rowData && _.some(col.hintColumnNames, hintColumnName => rowData[hintColumnName])}
|
||||
{#if showHint}
|
||||
<span class="hint"
|
||||
>{col.hintColumnNames.map(hintColumnName => rowData[hintColumnName]).join(col.hintColumnDelimiter || ' ')}</span
|
||||
>
|
||||
@@ -173,6 +176,9 @@
|
||||
background: var(--theme-bg-volcano);
|
||||
}
|
||||
td.isSelected {
|
||||
background: var(--theme-bg-3);
|
||||
}
|
||||
:global(.data-grid-focused) td.isSelected {
|
||||
background: var(--theme-bg-selected);
|
||||
}
|
||||
td.isDeleted {
|
||||
@@ -196,4 +202,9 @@
|
||||
overflow: visible;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.alignRight {
|
||||
color: var(--theme-icon-green);
|
||||
text-align: var(--data-grid-numbers-align);
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -416,7 +416,6 @@
|
||||
import GenerateSqlFromDataModal from '../modals/GenerateSqlFromDataModal.svelte';
|
||||
import { showModal } from '../modals/modalTools';
|
||||
import StatusBarTabItem from '../widgets/StatusBarTabItem.svelte';
|
||||
import { findCommand } from '../commands/runCommand';
|
||||
import { openJsonDocument } from '../tabs/JsonTab.svelte';
|
||||
import EditJsonModal from '../modals/EditJsonModal.svelte';
|
||||
import { apiCall } from '../utility/api';
|
||||
@@ -430,8 +429,7 @@
|
||||
import { openJsonLinesData } from '../utility/openJsonLinesData';
|
||||
import contextMenuActivator from '../utility/contextMenuActivator';
|
||||
import InputTextModal from '../modals/InputTextModal.svelte';
|
||||
import hasPermission from '../utility/hasPermission';
|
||||
|
||||
|
||||
export let onLoadNextData = undefined;
|
||||
export let grider = undefined;
|
||||
export let display: GridDisplay = undefined;
|
||||
@@ -472,7 +470,7 @@
|
||||
export let dataEditorTypesBehaviourOverride = null;
|
||||
|
||||
const wheelRowCount = 5;
|
||||
const tabVisible: any = getContext('tabVisible');
|
||||
const tabFocused: any = getContext('tabFocused');
|
||||
|
||||
let containerHeight = 0;
|
||||
let containerWidth = 0;
|
||||
@@ -483,6 +481,7 @@
|
||||
let domFocusField;
|
||||
let domHorizontalScroll;
|
||||
let domVerticalScroll;
|
||||
let domContainer;
|
||||
|
||||
let currentCell = topLeftCell;
|
||||
let selectedCells = [topLeftCell];
|
||||
@@ -492,6 +491,8 @@
|
||||
let autofillSelectedCells = emptyCellArray;
|
||||
const domFilterControlsRef = createRef({});
|
||||
|
||||
let isGridFocused = false;
|
||||
|
||||
const tabid = getContext('tabid');
|
||||
|
||||
let unsubscribeDbRefresh;
|
||||
@@ -594,6 +595,7 @@
|
||||
selectedCells = [cell];
|
||||
await tick();
|
||||
scrollIntoView(cell);
|
||||
domFocusField?.focus();
|
||||
}
|
||||
|
||||
export async function cloneRows() {
|
||||
@@ -1041,7 +1043,6 @@
|
||||
return !hideGridLeftColumn;
|
||||
}
|
||||
|
||||
|
||||
$: autofillMarkerCell =
|
||||
selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map(x => x[0])).length == 1
|
||||
? [_.max(selectedCells.map(x => x[0])), _.max(selectedCells.map(x => x[1]))]
|
||||
@@ -1134,7 +1135,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: if ($tabVisible && domFocusField && focusOnVisible) {
|
||||
$: if ($tabFocused && domFocusField && focusOnVisible) {
|
||||
domFocusField.focus();
|
||||
}
|
||||
|
||||
@@ -1747,6 +1748,11 @@
|
||||
// { text: 'Copy as JSON', onClick: () => copyToClipboardCore('json') },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Paste',
|
||||
onClick: () => domFocusField.paste(),
|
||||
keyText: 'CtrlOrCommand+V',
|
||||
},
|
||||
{ placeTag: 'switch' },
|
||||
{ divider: true },
|
||||
{ placeTag: 'save' },
|
||||
@@ -1837,11 +1843,11 @@
|
||||
{/if}
|
||||
</div>
|
||||
{:else if isDynamicStructure && isLoadedAll && grider?.rowCount == 0}
|
||||
<div>
|
||||
<div class="ml-2">
|
||||
<ErrorInfo
|
||||
alignTop
|
||||
message={grider.editable
|
||||
? 'No rows loaded, check filter or add new documents. You could copy documents from ohter collections/tables with Copy advanved/Copy as JSON command.'
|
||||
? 'No rows loaded, check filter or add new documents. You could copy documents from other collections/tables with Copy advanved/Copy as JSON command.'
|
||||
: 'No rows loaded'}
|
||||
/>
|
||||
{#if display.filterCount > 0}
|
||||
@@ -1863,11 +1869,18 @@
|
||||
{:else}
|
||||
<div
|
||||
class="container"
|
||||
class:data-grid-focused={isGridFocused}
|
||||
bind:clientWidth={containerWidth}
|
||||
bind:clientHeight={containerHeight}
|
||||
bind:this={domContainer}
|
||||
use:contextMenu={buildMenu}
|
||||
use:contextMenuActivator={activator}
|
||||
on:wheel={handleGridWheel}
|
||||
on:click={e => {
|
||||
if (e.target == domContainer) {
|
||||
domFocusField?.focus();
|
||||
}
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
@@ -1877,10 +1890,14 @@
|
||||
on:focus={() => {
|
||||
activator.activate();
|
||||
invalidateCommands();
|
||||
isGridFocused = true;
|
||||
}}
|
||||
on:blur
|
||||
on:paste={handlePaste}
|
||||
on:copy={copyToClipboard}
|
||||
on:blur={handleBlur}
|
||||
on:blur={() => {
|
||||
isGridFocused = false;
|
||||
}}
|
||||
/>
|
||||
<table
|
||||
class="table"
|
||||
@@ -2008,6 +2025,24 @@
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{#if !isDynamicStructure && isLoadedAll && grider?.rowCount == 0}
|
||||
<div class="no-rows-info ml-2">
|
||||
<div class="mb-3">
|
||||
<ErrorInfo alignTop message="No rows loaded" icon="img info" />
|
||||
</div>
|
||||
{#if display.filterCount > 0}
|
||||
<FormStyledButton value="Reset filter" on:click={() => display.clearFilters()} />
|
||||
{/if}
|
||||
{#if grider.editable}
|
||||
<FormStyledButton value="Add row" on:click={insertNewRow} />
|
||||
{/if}
|
||||
{#if onOpenQuery}
|
||||
<FormStyledButton value="Open Query" on:click={onOpenQuery} />
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<HorizontalScrollBar
|
||||
minimum={0}
|
||||
maximum={maxScrollColumn}
|
||||
@@ -2086,4 +2121,8 @@
|
||||
right: 40px;
|
||||
bottom: 20px;
|
||||
}
|
||||
|
||||
.no-rows-info {
|
||||
margin-top: 60px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user