@mostajs/orm 1.4.1 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -32,9 +32,15 @@ function getDefaultJarDir() {
|
|
|
32
32
|
function getDefaultBridgeJavaPath() {
|
|
33
33
|
if (process.env.MOSTA_BRIDGE_JAVA)
|
|
34
34
|
return process.env.MOSTA_BRIDGE_JAVA;
|
|
35
|
+
const bridgeFile = 'MostaJdbcBridge.java';
|
|
35
36
|
const candidates = [
|
|
36
|
-
|
|
37
|
-
join(__dirname_resolved, '..', '..', '
|
|
37
|
+
// Relative to dist/bridge/ (normal npm install layout)
|
|
38
|
+
join(__dirname_resolved, '..', '..', 'bridge', bridgeFile),
|
|
39
|
+
// Relative to package root (monorepo / local dev)
|
|
40
|
+
join(__dirname_resolved, '..', '..', '..', 'bridge', bridgeFile),
|
|
41
|
+
// Via process.cwd() (fallback)
|
|
42
|
+
join(process.cwd(), 'node_modules', '@mostajs', 'orm', 'bridge', bridgeFile),
|
|
43
|
+
join(process.cwd(), 'bridge', bridgeFile),
|
|
38
44
|
];
|
|
39
45
|
for (const p of candidates) {
|
|
40
46
|
if (existsSync(p))
|
package/dist/core/factory.js
CHANGED
|
@@ -117,7 +117,10 @@ export async function testConnection(config) {
|
|
|
117
117
|
await dialect.connect(config);
|
|
118
118
|
const ok = await dialect.testConnection();
|
|
119
119
|
await dialect.disconnect();
|
|
120
|
-
|
|
120
|
+
if (!ok) {
|
|
121
|
+
return { ok: false, error: 'Connection test returned false (SELECT 1 failed or driver test failed)' };
|
|
122
|
+
}
|
|
123
|
+
return { ok: true };
|
|
121
124
|
}
|
|
122
125
|
catch (e) {
|
|
123
126
|
const error = e instanceof Error ? e.message : String(e);
|
|
@@ -589,12 +589,19 @@ export class AbstractSqlDialect {
|
|
|
589
589
|
async testConnection() {
|
|
590
590
|
try {
|
|
591
591
|
if (this.jdbcBridgeActive && this.bridgeInstance) {
|
|
592
|
-
|
|
592
|
+
// Use dialect-appropriate ping query
|
|
593
|
+
const pingQuery = this.dialectType === 'hsqldb'
|
|
594
|
+
? 'SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS'
|
|
595
|
+
: this.dialectType === 'oracle'
|
|
596
|
+
? 'SELECT 1 FROM DUAL'
|
|
597
|
+
: 'SELECT 1';
|
|
598
|
+
const result = await this.bridgeInstance.normalizer.query(pingQuery, []);
|
|
593
599
|
return Array.isArray(result);
|
|
594
600
|
}
|
|
595
601
|
return await this.doTestConnection();
|
|
596
602
|
}
|
|
597
|
-
catch {
|
|
603
|
+
catch (err) {
|
|
604
|
+
console.error(`[${this.dialectType}] testConnection failed:`, err instanceof Error ? err.message : err);
|
|
598
605
|
return false;
|
|
599
606
|
}
|
|
600
607
|
}
|
package/package.json
CHANGED