mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 14:56:01 +00:00
WIP
This commit is contained in:
7
plugins/dbgate-plugin-duckdb/src/frontend/Dumper.js
Normal file
7
plugins/dbgate-plugin-duckdb/src/frontend/Dumper.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const { SqlDumper, arrayToHexString } = require('dbgate-tools');
|
||||
|
||||
class Dumper extends SqlDumper {
|
||||
autoIncrement() {}
|
||||
}
|
||||
|
||||
module.exports = Dumper;
|
||||
72
plugins/dbgate-plugin-duckdb/src/frontend/driver.js
Normal file
72
plugins/dbgate-plugin-duckdb/src/frontend/driver.js
Normal file
@@ -0,0 +1,72 @@
|
||||
// @ts-check
|
||||
|
||||
const { driverBase } = global.DBGATE_PACKAGES['dbgate-tools'];
|
||||
const Dumper = require('./Dumper');
|
||||
const { sqliteSplitterOptions, noSplitSplitterOptions } = require('dbgate-query-splitter/lib/options');
|
||||
|
||||
/**
|
||||
* @param {string} databaseFile
|
||||
*/
|
||||
function getDatabaseFileLabel(databaseFile) {
|
||||
if (!databaseFile) return databaseFile;
|
||||
const m = databaseFile.match(/[\/]([^\/]+)$/);
|
||||
if (m) return m[1];
|
||||
return databaseFile;
|
||||
}
|
||||
|
||||
/** @type {import('dbgate-types').SqlDialect} */
|
||||
const dialect = {
|
||||
limitSelect: true,
|
||||
rangeSelect: true,
|
||||
offsetFetchRangeSyntax: false,
|
||||
explicitDropConstraint: true,
|
||||
stringEscapeChar: "'",
|
||||
fallbackDataType: 'nvarchar',
|
||||
allowMultipleValuesInsert: true,
|
||||
dropColumnDependencies: ['indexes', 'primaryKey', 'uniques'],
|
||||
quoteIdentifier(s) {
|
||||
return `"${s}"`;
|
||||
},
|
||||
anonymousPrimaryKey: true,
|
||||
requireStandaloneSelectForScopeIdentity: true,
|
||||
|
||||
createColumn: true,
|
||||
dropColumn: true,
|
||||
createIndex: true,
|
||||
dropIndex: true,
|
||||
createForeignKey: false,
|
||||
enableForeignKeyChecks: false,
|
||||
dropForeignKey: false,
|
||||
createPrimaryKey: false,
|
||||
dropPrimaryKey: false,
|
||||
dropReferencesWhenDropTable: false,
|
||||
filteredIndexes: true,
|
||||
anonymousForeignKey: true,
|
||||
};
|
||||
|
||||
/** @type {import('dbgate-types').EngineDriver} */
|
||||
const driver = {
|
||||
...driverBase,
|
||||
dumperClass: Dumper,
|
||||
dialect,
|
||||
engine: 'duckdb@dbgate-plugin-duckdb',
|
||||
title: 'DuckDB',
|
||||
readOnlySessions: true,
|
||||
supportsTransactions: true,
|
||||
|
||||
getQuerySplitterOptions: (usage) =>
|
||||
usage == 'editor'
|
||||
? { ...sqliteSplitterOptions, ignoreComments: true, preventSingleLineSplit: true }
|
||||
: usage == 'stream'
|
||||
? noSplitSplitterOptions
|
||||
: sqliteSplitterOptions,
|
||||
showConnectionTab: (field) => false,
|
||||
showConnectionField: (field) => ['databaseFile'].includes(field),
|
||||
beforeConnectionSave: (connection) => ({
|
||||
...connection,
|
||||
singleDatabase: true,
|
||||
defaultDatabase: getDatabaseFileLabel(connection.databaseFile),
|
||||
}),
|
||||
};
|
||||
|
||||
module.exports = driver;
|
||||
6
plugins/dbgate-plugin-duckdb/src/frontend/index.js
Normal file
6
plugins/dbgate-plugin-duckdb/src/frontend/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import driver from './driver';
|
||||
|
||||
export default {
|
||||
packageName: 'dbgate-plugin-duckdb',
|
||||
drivers: [driver],
|
||||
};
|
||||
Reference in New Issue
Block a user