Skip to content

Commit 00eb396

Browse files
committed
Cleanup code around getRoutingTable invocation
* Use new query parameter syntax `$param` instead of deprecated `{param}` * Do not use ES6 dynamic object key syntax
1 parent c6a4b24 commit 00eb396

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/v1/internal/routing-util.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import Integer, {int} from '../integer';
2222
import {ServerVersion, VERSION_3_2_0} from './server-version';
2323

2424
const CALL_GET_SERVERS = 'CALL dbms.cluster.routing.getServers';
25-
const GET_ROUTING_TABLE_PARAM = 'context';
26-
const CALL_GET_ROUTING_TABLE = 'CALL dbms.cluster.routing.getRoutingTable({' + GET_ROUTING_TABLE_PARAM + '})';
25+
const CALL_GET_ROUTING_TABLE = 'CALL dbms.cluster.routing.getRoutingTable($context)';
2726
const PROCEDURE_NOT_FOUND_CODE = 'Neo.ClientError.Procedure.ProcedureNotFound';
2827
const UNAUTHORIZED_CODE = 'Neo.ClientError.Security.Unauthorized';
2928

@@ -122,7 +121,7 @@ export default class RoutingUtil {
122121

123122
if (serverVersion.compareTo(VERSION_3_2_0) >= 0) {
124123
query = CALL_GET_ROUTING_TABLE;
125-
params = {[GET_ROUTING_TABLE_PARAM]: this._routingContext};
124+
params = {context: this._routingContext};
126125
} else {
127126
query = CALL_GET_SERVERS;
128127
params = {};

test/internal/routing-util.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ describe('RoutingUtil', () => {
100100
const session = FakeSession.withFakeConnection(connection);
101101

102102
callRoutingProcedure(session, {}).then(() => {
103-
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable({context})']);
103+
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable($context)']);
104104
expect(connection.seenParameters).toEqual([{context: {}}]);
105105
done();
106106
});
@@ -111,7 +111,7 @@ describe('RoutingUtil', () => {
111111
const session = FakeSession.withFakeConnection(connection);
112112

113113
callRoutingProcedure(session, {key1: 'value1', key2: 'value2'}).then(() => {
114-
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable({context})']);
114+
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable($context)']);
115115
expect(connection.seenParameters).toEqual([{context: {key1: 'value1', key2: 'value2'}}]);
116116
done();
117117
});
@@ -122,7 +122,7 @@ describe('RoutingUtil', () => {
122122
const session = FakeSession.withFakeConnection(connection);
123123

124124
callRoutingProcedure(session, {}).then(() => {
125-
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable({context})']);
125+
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable($context)']);
126126
expect(connection.seenParameters).toEqual([{context: {}}]);
127127
done();
128128
});
@@ -133,7 +133,7 @@ describe('RoutingUtil', () => {
133133
const session = FakeSession.withFakeConnection(connection);
134134

135135
callRoutingProcedure(session, {key1: 'foo', key2: 'bar'}).then(() => {
136-
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable({context})']);
136+
expect(connection.seenStatements).toEqual(['CALL dbms.cluster.routing.getRoutingTable($context)']);
137137
expect(connection.seenParameters).toEqual([{context: {key1: 'foo', key2: 'bar'}}]);
138138
done();
139139
});

test/resources/boltstub/get_routing_table.script

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO PULL_ALL
44

55
S: SUCCESS {"server": "Neo4j/3.2.2"}
6-
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {}}
6+
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {}}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"], "role": "READ"},{"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"], "role": "ROUTE"}]]

test/resources/boltstub/get_routing_table_with_context.script

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
!: AUTO PULL_ALL
44

55
S: SUCCESS {"server": "Neo4j/3.2.3"}
6-
C: RUN "CALL dbms.cluster.routing.getRoutingTable({context})" {"context": {"policy": "my_policy", "region": "china"}}
6+
C: RUN "CALL dbms.cluster.routing.getRoutingTable($context)" {"context": {"policy": "my_policy", "region": "china"}}
77
PULL_ALL
88
S: SUCCESS {"fields": ["ttl", "servers"]}
99
RECORD [9223372036854775807, [{"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"],"role": "WRITE"}, {"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"], "role": "READ"},{"addresses": ["127.0.0.1:9001", "127.0.0.1:9002"], "role": "ROUTE"}]]

0 commit comments

Comments
 (0)