Skip to content

Commit e8d6fec

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

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
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: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ func (v *Version) Metadata() string {
5656
}
5757

5858
// String returns the string representation, in the format:
59-
// "v1.2.3-beta+md"
59+
//
60+
// "v1.2.3-beta+md"
6061
func (v Version) String() string {
6162
var b bytes.Buffer
6263
fmt.Fprintf(&b, "v%d.%d.%d", v.major, v.minor, v.patch)
@@ -73,22 +74,25 @@ func (v Version) String() string {
7374
// of the form "vMAJOR.MINOR.PATCH[-PRERELEASE][+METADATA]". This
7475
// conforms to https://semver.org/spec/v2.0.0.html
7576
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-.]+|)?$`,
77+
`v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9A-Za-z-.]+)?(\+[0-9A-Za-z-.]+|)?`,
7778
// ^major ^minor ^patch ^preRelease ^metadata
7879
)
7980

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

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

9498
var v Version

0 commit comments

Comments
 (0)