Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/http-connection/query.codec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { newError, Node, Relationship, int, error, types, Integer, Time, Date, LocalTime, Point, DateTime, LocalDateTime, Duration, isInt, isPoint, isDuration, isLocalTime, isTime, isDate, isLocalDateTime, isDateTime, isRelationship, isPath, isNode, isPathSegment, Path, PathSegment, internal, isUnboundRelationship, isVector } from "neo4j-driver-core"
import { newError, Node, Relationship, int, error, types, Integer, Time, Date, LocalTime, Point, DateTime, LocalDateTime, Duration, isInt, isPoint, isDuration, isLocalTime, isTime, isDate, isLocalDateTime, isDateTime, isRelationship, isPath, isNode, isPathSegment, Path, PathSegment, internal, isUnboundRelationship, isVector, isUnsupportedType } from "neo4j-driver-core"
import { RunQueryConfig } from "neo4j-driver-core/types/connection"
import { NEO4J_QUERY_CONTENT_TYPE, encodeAuthToken, encodeTransactionBody } from "./codec"

Expand Down Expand Up @@ -769,6 +769,8 @@ export class QueryRequestCodec {
return { $type: 'OffsetDateTime', _value: value.toString() }
} else if (isVector(value)) {
throw newError('Vectors are not supported yet on query api', error.PROTOCOL_ERROR)
} else if (isUnsupportedType(value)) {
throw newError('UnsupportedType can not be ingested to the server', error.PROTOCOL_ERROR)
} else if (isRelationship(value) || isNode(value) || isPath(value) || isPathSegment(value) || isUnboundRelationship(value)) {
throw newError('Graph types can not be ingested to the server', error.PROTOCOL_ERROR)
} else if (typeof value === 'object') {
Expand Down
13 changes: 12 additions & 1 deletion test/unit/http-connection/query.code.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import neo4j, { auth, types, internal, int, Date, Time, LocalTime, DateTime, LocalDateTime, Point, Duration, Node, Relationship, UnboundRelationship, Path, PathSegment, Vector } from "neo4j-driver-core";
import neo4j, { auth, types, internal, int, Date, Time, LocalTime, DateTime, LocalDateTime, Point, Duration, Node, Relationship, UnboundRelationship, Path, PathSegment, Vector, UnsupportedType } from "neo4j-driver-core";
import { QueryRequestCodec, QueryRequestCodecConfig, QueryResponseCodec, RawQueryResponse, RawQueryValue } from "../../../src/http-connection/query.codec";

describe('QueryRequestCodec', () => {
Expand Down Expand Up @@ -210,6 +210,17 @@ describe('QueryRequestCodec', () => {
expect(() => codec.body).toThrow('Graph types can not be ingested to the server')
})

it('should not handle UnsupportedType as parameters ', () => {
const param = new UnsupportedType("Vector", 6, 0, "Something good is bad, actually!")
const codec = subject({
parameters: {
param
}
})

expect(() => codec.body).toThrow('UnsupportedType can not be ingested to the server')
})

it.each([
['Vector<INT8>', new Vector(new Int8Array([-127, 0, 128]))],
['Vector<INT16>', new Vector(new Int16Array([-1273, 0, 1283]))],
Expand Down