forProductVersion static method
The descriptor for a raw SERVERPROPERTY('ProductVersion') string.
Separate from forServer because a repository inside a transaction
cannot call MssqlConnection.serverInfo() — the connection is leased by
the transaction — and so reads the property through its own session.
A version this cannot parse yields sql2012: guessing downward would silently hand a modern server the legacy paging syntax, while guessing upward at worst produces a clear error naming the feature.
Implementation
static MssqlDialect forProductVersion(
String productVersion, {
int? compatibilityLevel,
}) {
final major = RegExp(r'^\d+').firstMatch(productVersion.trim());
final value = major == null ? null : int.tryParse(major.group(0)!);
if (value == null) {
return compatibilityLevel == null
? sql2012
: MssqlDialect._(11, compatibilityLevel);
}
return MssqlDialect.forVersion(
majorVersion: value,
compatibilityLevel: compatibilityLevel,
);
}