Skip to content

Commit

Permalink
[node-hdb] Add fullVersionString and cloudVersionString to connectOpt…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
jeffalbion committed Jan 20, 2025
1 parent ffbfdd5 commit 5cb6570
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
4 changes: 3 additions & 1 deletion lib/protocol/common/ConnectOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ module.exports = {
IGNORE_UNKNOWN_PARTS: 21,
DATA_FORMAT_VERSION2: 23,
OS_USER: 32,
FULL_VERSION_STRING: 44,
REDIRECTION_TYPE: 57,
REDIRECTED_HOST: 58,
REDIRECTED_PORT: 59,
ENDPOINT_HOST: 60,
ENDPOINT_PORT: 61,
ENDPOINT_LIST: 62
ENDPOINT_LIST: 62,
CLOUD_VERSION_STRING: 65,
};
2 changes: 2 additions & 0 deletions lib/protocol/common/ConnectOptionType.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ ConnectOptionType[ConnectOption.ROW_AND_COLUMN_OPTIMIZED_FORMAT] = TypeCode.BOOL
ConnectOptionType[ConnectOption.IGNORE_UNKNOWN_PARTS] = TypeCode.BOOLEAN;
ConnectOptionType[ConnectOption.DATA_FORMAT_VERSION2] = TypeCode.INT;
ConnectOptionType[ConnectOption.OS_USER] = TypeCode.STRING;
ConnectOptionType[ConnectOption.FULL_VERSION_STRING] = TypeCode.STRING;
ConnectOptionType[ConnectOption.REDIRECTION_TYPE] = TypeCode.INT;
ConnectOptionType[ConnectOption.REDIRECTED_HOST] = TypeCode.STRING;
ConnectOptionType[ConnectOption.REDIRECTED_PORT] = TypeCode.INT;
ConnectOptionType[ConnectOption.ENDPOINT_HOST] = TypeCode.STRING;
ConnectOptionType[ConnectOption.ENDPOINT_PORT] = TypeCode.INT;
ConnectOptionType[ConnectOption.ENDPOINT_LIST] = TypeCode.STRING;
ConnectOptionType[ConnectOption.CLOUD_VERSION_STRING] = TypeCode.STRING;
11 changes: 10 additions & 1 deletion lib/protocol/part/ConnectOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ function ConnectOptions() {
// of the communication protocol instead of raising a fatal error.
this.ignoreUnknownParts = undefined;

// This field is sent by the server and is the server version string
this.fullVersionString = undefined;

// This field is sent by the server and is the Cloud version that the
// server was released under (undefined for on-premise servers)
this.cloudVersionString = undefined;

// The client indicates this set of understood type codes and field formats.
// The server then defines the value according to its own capabilities,
// and sends it back. The following values are supported:
Expand Down Expand Up @@ -132,10 +139,12 @@ ConnectOptions.prototype.KEYS = [
common.ConnectOption.DATA_FORMAT_VERSION,
common.ConnectOption.DATA_FORMAT_VERSION2,
common.ConnectOption.OS_USER,
common.ConnectOption.FULL_VERSION_STRING,
common.ConnectOption.REDIRECTION_TYPE,
common.ConnectOption.REDIRECTED_HOST,
common.ConnectOption.REDIRECTED_PORT,
common.ConnectOption.ENDPOINT_HOST,
common.ConnectOption.ENDPOINT_PORT,
common.ConnectOption.ENDPOINT_LIST
common.ConnectOption.ENDPOINT_LIST,
common.ConnectOption.CLOUD_VERSION_STRING,
];
15 changes: 2 additions & 13 deletions test/hdb.Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,7 @@ TestClient.prototype._createResult = function _createResult() {
return this._result;
};

var mock_auth_reply= {
kind: 2,
functionCode: 0,
resultSets: [],
authentication: 'INITIAL'
};
var mock_conn_reply = {
kind: 2,
functionCode: 0,
resultSets: [],
authentication: 'FINAL',
connectOptions: []
};
const { mock_auth_reply, mock_conn_reply } = require('./mock/data/replies.js');

describe('hdb', function () {

Expand Down Expand Up @@ -103,6 +91,7 @@ describe('hdb', function () {
cleanup();
return done(err);
}
client.connectOptions.fullVersionString.should.not.be.undefined;
client.close();
});
});
Expand Down
3 changes: 3 additions & 0 deletions test/mock/MockConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ var lib = require('../../lib');
var util = lib.util;
var common = require('../../lib/protocol/common');

const { mock_auth_reply, mock_conn_reply } = require('./data/replies.js');

module.exports = MockConnection;

util.inherits(MockConnection, EventEmitter);
Expand Down Expand Up @@ -171,6 +173,7 @@ MockConnection.prototype.connect = function connect(options, cb) {
self.readyState = 'disconnected';
} else {
self.readyState = 'connected';
Object.assign(self.connectOptions, mock_conn_reply.connectOptions);
}
cb(err);
});
Expand Down
19 changes: 19 additions & 0 deletions test/mock/data/replies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var mock_auth_reply= {
kind: 2,
functionCode: 0,
resultSets: [],
authentication: 'INITIAL'
};

var mock_conn_reply = {
kind: 2,
functionCode: 0,
resultSets: [],
authentication: 'FINAL',
connectOptions: { fullVersionString: "2.00.083.00.1737144279" },
};

module.exports = {
mock_auth_reply,
mock_conn_reply
};

0 comments on commit 5cb6570

Please sign in to comment.