oracle version fallback

This commit is contained in:
Jan Prochazka
2024-06-03 07:53:12 +02:00
parent f4fbb28124
commit 4e6e0a79c4

View File

@@ -205,14 +205,23 @@ const drivers = driverBases.map(driverBase => ({
//console.log('Rows selected: ' + numrows); //console.log('Rows selected: ' + numrows);
//client.query(query); //client.query(query);
}, },
async getVersion(client) { async getVersionCore(client) {
//const { rows } = await this.query(client, "SELECT banner as version FROM v$version WHERE banner LIKE 'Oracle%'"); try {
const { rows } = await this.query(
client,
'SELECT version_full as "version" FROM product_component_version WHERE product LIKE \'Oracle%Database%\''
);
return rows[0].version;
} catch (e) {
const { rows } = await this.query(client, 'SELECT version as "version" FROM v$instance'); const { rows } = await this.query(client, 'SELECT version as "version" FROM v$instance');
const { version } = rows[0]; return rows[0].version;
}
const isCockroach = false; //version.toLowerCase().includes('cockroachdb'); },
const isRedshift = false; // version.toLowerCase().includes('redshift'); async getVersion(client) {
const isOracle = true; try {
//const { rows } = await this.query(client, "SELECT banner as version FROM v$version WHERE banner LIKE 'Oracle%'");
// const { rows } = await this.query(client, 'SELECT version as "version" FROM v$instance');
const version = await this.getVersionCore(client);
const m = version.match(/([\d\.]+)/); const m = version.match(/([\d\.]+)/);
//console.log('M', m); //console.log('M', m);
@@ -220,7 +229,7 @@ const drivers = driverBases.map(driverBase => ({
let versionMajor = null; let versionMajor = null;
let versionMinor = null; let versionMinor = null;
if (m) { if (m) {
if (isOracle) versionText = `Oracle ${m[1]}`; versionText = `Oracle ${m[1]}`;
const numbers = m[1].split('.'); const numbers = m[1].split('.');
if (numbers[0]) versionMajor = parseInt(numbers[0]); if (numbers[0]) versionMajor = parseInt(numbers[0]);
if (numbers[1]) versionMinor = parseInt(numbers[1]); if (numbers[1]) versionMinor = parseInt(numbers[1]);
@@ -229,12 +238,17 @@ const drivers = driverBases.map(driverBase => ({
return { return {
version, version,
versionText, versionText,
isOracle,
isCockroach,
isRedshift,
versionMajor, versionMajor,
versionMinor, versionMinor,
}; };
} catch (e) {
return {
version: '???',
versionText: 'Oracle ???',
versionMajor: 0,
versionMinor: 0,
};
}
}, },
async readQuery(client, sql, structure) { async readQuery(client, sql, structure) {
/* /*