Skip to content

Commit b8cefbe

Browse files
Bugfix - :auto didn't handle newlines (#1872)
* fix auto prefix not handling newline * update unit test snapshots * fix auto test
1 parent 6adc67f commit b8cefbe

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

e2e_tests/integration/auto-prefix.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ describe(':auto prefix in browser', () => {
5858
cy.getFrames().should('not.contain', 'ERROR')
5959
cy.getFrames().contains('Started streaming 1 rec')
6060
})
61+
62+
it('newline is allowed after :auto', () => {
63+
cy.executeCommand(':clear')
64+
cy.executeCommand(
65+
`:auto{shift}{enter}CALL {{} RETURN 2 as x {}} IN TRANSACTIONS RETURN 2;`
66+
)
67+
cy.getFrames().should('not.contain', 'ERROR')
68+
cy.getFrames().contains('Started streaming 1 rec')
69+
})
6170
}
6271

6372
it('can use :auto command in multi-statements', () => {

src/shared/modules/commands/cypher.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('Implicit vs explicit transactions', () => {
126126
flushPromises().then(() => {
127127
expect(bolt.routedWriteTransaction).toHaveBeenCalledTimes(1)
128128
expect(bolt.routedWriteTransaction).toHaveBeenCalledWith(
129-
'RETURN 1',
129+
' RETURN 1',
130130
{},
131131
expect.objectContaining({
132132
autoCommit: true
@@ -163,7 +163,7 @@ multiline comment
163163
// comment
164164
165165
// comment
166-
/*:auto*/RETURN ":auto"`,
166+
/*:auto*/ RETURN ":auto"`,
167167
{},
168168
expect.objectContaining({
169169
autoCommit: true

src/shared/services/commandInterpreterHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ const availableCommands = [
414414
// we need to strip that and attach to the actions object
415415
const query = action.cmd.trim()
416416

417-
const autoPrefix = `:${autoCommitTxCommand} `
417+
const autoPrefix = `:${autoCommitTxCommand}`
418418
const blankedComments = query
419419
.replace(/\/\*(.|\n)*?\*\//g, (match: any) => ' '.repeat(match.length)) // mutliline comment
420420
.replace(/\/\/[^\n]*\n/g, (match: any) => ' '.repeat(match.length)) // singleline comment

0 commit comments

Comments
 (0)