-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clisqlclient: drop the dependency on
parser
This moves `HasMultipleStatements` to package `scanner` which is much smaller, and uses that. Release note: None
- Loading branch information
Showing
7 changed files
with
116 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2021 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package scanner | ||
|
||
import "testing" | ||
|
||
func TestHasMultipleStatements(t *testing.T) { | ||
testCases := []struct { | ||
in string | ||
expected bool | ||
}{ | ||
{`a b c`, false}, | ||
{`a; b c`, true}, | ||
{`a b; b c`, true}, | ||
{`a b; b c;`, true}, | ||
{`a b;`, false}, | ||
{`SELECT 123; SELECT 123`, true}, | ||
{`SELECT 123; SELECT 123;`, true}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
actual, err := HasMultipleStatements(tc.in) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
|
||
if actual != tc.expected { | ||
t.Errorf("%q: expected %v, got %v", tc.in, tc.expected, actual) | ||
} | ||
} | ||
} |