Skip to content

Commit a5c46ae

Browse files
see if I can fix the example orms issue
1 parent 876b2d5 commit a5c46ae

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

testing/main_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ func startServerWithApplication(
112112
func getVersionFromDB(t *testing.T, db *sql.DB) *version.Version {
113113
t.Helper()
114114
var crdbVersion string
115-
if err := db.QueryRow(
116-
`SELECT value FROM crdb_internal.node_build_info where field = 'Version'`,
117-
).Scan(&crdbVersion); err != nil {
115+
if err := db.QueryRow("SHOW crdb_version").Scan(&crdbVersion); err != nil {
118116
t.Fatal(err)
119117
}
120118
v, err := version.Parse(crdbVersion)

version/version.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,23 @@ func (v Version) String() string {
7373
// of the form "vMAJOR.MINOR.PATCH[-PRERELEASE][+METADATA]". This
7474
// conforms to https://semver.org/spec/v2.0.0.html
7575
var versionRE = regexp.MustCompile(
76-
`^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+|)?$`,
76+
`v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+|)?`,
7777
// ^major ^minor ^patch ^preRelease ^metadata
7878
)
7979

8080
// numericRE is the regexp used to check if an identifier is numeric.
8181
var numericRE = regexp.MustCompile(`^(0|[1-9][0-9]*)$`)
8282

83-
// Parse creates a version from a string. The string must be a valid semantic
83+
// Parse creates a version from a string. The string must contain a valid semantic
8484
// version (as per https://semver.org/spec/v2.0.0.html) in the format:
8585
// "vMINOR.MAJOR.PATCH[-PRERELEASE][+METADATA]".
8686
// MINOR, MAJOR, and PATCH are numeric values (without any leading 0s).
8787
// PRERELEASE and METADATA can contain ASCII characters and digits, hyphens and
8888
// dots.
89-
func Parse(str string) (*Version, error) {
90-
if !versionRE.MatchString(str) {
91-
return nil, errors.Errorf("invalid version string '%s'", str)
89+
func Parse(fullStr string) (*Version, error) {
90+
var str string
91+
if str = versionRE.FindString(fullStr); len(str) == 0 {
92+
return nil, errors.Errorf("invalid version string '%s'", fullStr)
9293
}
9394

9495
var v Version

0 commit comments

Comments
 (0)