mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 05:36:00 +00:00
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
const { driverBase } = global.DBGATE_TOOLS;
|
|
const Dumper = require('./Dumper');
|
|
const { sqliteSplitterOptions, noSplitSplitterOptions } = require('dbgate-query-splitter/lib/options');
|
|
|
|
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',
|
|
dropColumnDependencies: ['indexes', 'primaryKey', 'uniques'],
|
|
quoteIdentifier(s) {
|
|
return `[${s}]`;
|
|
},
|
|
anonymousPrimaryKey: true,
|
|
disableExplicitTransaction: true,
|
|
|
|
createColumn: true,
|
|
dropColumn: true,
|
|
createIndex: true,
|
|
dropIndex: true,
|
|
createForeignKey: false,
|
|
dropForeignKey: false,
|
|
createPrimaryKey: false,
|
|
dropPrimaryKey: false,
|
|
dropReferencesWhenDropTable: false,
|
|
};
|
|
|
|
/** @type {import('dbgate-types').EngineDriver} */
|
|
const driver = {
|
|
...driverBase,
|
|
dumperClass: Dumper,
|
|
dialect,
|
|
engine: 'sqlite@dbgate-plugin-sqlite',
|
|
title: 'SQLite',
|
|
readOnlySessions: true,
|
|
showConnectionField: (field, values) => field == 'databaseFile' || field == 'isReadOnly',
|
|
showConnectionTab: (field) => false,
|
|
beforeConnectionSave: (connection) => ({
|
|
...connection,
|
|
singleDatabase: true,
|
|
defaultDatabase: getDatabaseFileLabel(connection.databaseFile),
|
|
}),
|
|
getQuerySplitterOptions: (usage) => (usage == 'stream' ? noSplitSplitterOptions : sqliteSplitterOptions),
|
|
// isFileDatabase: true,
|
|
isElectronOnly: true,
|
|
};
|
|
|
|
module.exports = driver;
|