Skip to content

Function batch.Split() splits on wrong separator #247

@flaviopicci

Description

@flaviopicci

Describe the bug
Function batch.Split(sqlString, "GO") wrongly splits the sqlString on all go occourrecnces, even if it's part of a statement, like goto or columns identifiers, like gone.

To Reproduce
Call batch.Split(sqlString, "GO") with an sqlString that has goXXX as identifier on an newline.
E.g.:

sqlString = `
select 1
go
select
  gone_ts
from t
go`

statements := batch.Split(sqlString, "GO")
// statements = ["\nselect 1\n", "\nselect\n  ", "ne_ts\nfrom t\n"]

Expected behavior
I would expect statements from above to be

// statements = ["\nselect 1\n", "\nselect\n  gone_ts\nfrom t\n"]

Further technical details

go-mssqldb version: 1.8.0
SQL Server version: N/A
Operating system: N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions