1
0
Fork 0
mirror of synced 2024-07-02 21:10:43 +12:00

Merge branch 'master' into fix/12154-invalid-table-fetches

This commit is contained in:
Michael Drury 2023-11-09 18:26:41 +00:00 committed by GitHub
commit dba8764a72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View file

@ -165,10 +165,22 @@ class RedisIntegration {
// commands split line by line
const commands = query.json.trim().split("\n")
let pipelineCommands = []
let tokenised
// process each command separately
for (let command of commands) {
const tokenised = command.trim().split(" ")
const valueToken = command.trim().match(/".*"/)
if (valueToken?.[0]) {
tokenised = [
...command
.substring(0, command.indexOf(valueToken[0]) - 1)
.trim()
.split(" "),
valueToken?.[0],
]
} else {
tokenised = command.trim().split(" ")
}
// Pipeline only accepts lower case commands
tokenised[0] = tokenised[0].toLowerCase()
pipelineCommands.push(tokenised)

View file

@ -85,4 +85,21 @@ describe("Redis Integration", () => {
["get", "foo"],
])
})
it("calls the pipeline method with double quoted phrase values", async () => {
const body = {
json: 'SET foo "What a wonderful world!"\nGET foo',
}
// ioredis-mock doesn't support pipelines
config.integration.client.pipeline = jest.fn(() => ({
exec: jest.fn(() => [[]]),
}))
await config.integration.command(body)
expect(config.integration.client.pipeline).toHaveBeenCalledWith([
["set", "foo", '"What a wonderful world!"'],
["get", "foo"],
])
})
})