mssql 0.2.0
mssql: ^0.2.0 copied to clipboard
A pure Dart driver for Microsoft SQL Server using the TDS 7.4 wire protocol, with TDS 8.0 strict encryption.
Changelog #
0.2.0 #
Fixed #
- Encrypted connections (
encrypt: true) no longer die withBad state: Connection closed mid-headerafter roughly 13-23 statements, and large statements now work over TLS.dart:io'sSecureSocketcould seal one TDS packet as two TLS records when a write crossed its internal 8 KiB buffer, and SQL Server closes the connection when a packet spans records. Every message on an encrypted connection is now aligned to the packet size (see README, "Encrypted-connection behavior"). - Values that straddle two TDS packets are read correctly. Previously a multi-byte value split across packets could be read as a different number without any error, or fail with
TDS stream ended unexpectedly. Reported and fixed independently in the poble-pos and Alexqwesa forks. - The legacy TLS bridge no longer silently drops all later writes after a single write failure.
- The package compiles under dart2js, so Flutter web builds that reach it no longer fail (it still cannot run on the web; it needs raw sockets). Found in the univelop fork.
Added #
MssqlEncryptMode.strict: TDS 8.0 strict encryption (Encrypt=Strict) for SQL Server 2022+ and Azure SQL. TLS starts before any TDS bytes, the server certificate is always validated, andtrustServerCertificate: trueis rejected. Select it withencryptMode:onMssqlConnection.connect,connectAzureAdandMssqlPoolConfig.encrypt: boolkeeps its old meaning.
Changed #
- Encrypted connections request 512-byte TDS packets and pad each message to keep packets aligned, at a cost of up to about 0.5 KB per statement on the wire. Results and plan caching are unaffected.
program_nameandclient_interface_nameinsys.dm_exec_sessionsshow trailing spaces.encrypt: falseis unchanged. - The minimum Dart SDK is now 3.4.0. The previously declared
>=3.0.0could not be installed, becausehttprequires 3.2 or newer. - Development dependencies updated (
lints6,test1.32).
Tested against #
SQL Server 2017, 2019, 2022 and 2025 on Linux; 2019, 2022 and 2025 on Windows; TDS 8.0 strict on Windows SQL Server 2022 and 2025; Azure SQL Edge; Dart 3.4.0, stable and beta. Not yet verified: Azure SQL Database, Azure AD logins, and strict mode against Azure SQL.
0.1.1 #
- Remove hardcoded credentials from example and benchmark tool — all connection details now read from environment variables.
- Wrap connection and pool usage in
try/finallyto guaranteeclose()on error.
0.1.0 #
- Initial release.
- Pure-Dart TDS 7.4 driver — no native extensions, no FFI.
MssqlConnectionwith SQL Server and Azure AD authentication (bearer token, ROPC, client credentials).MssqlPoolwith configurable min/max, idle reaping, and acquire timeouts.- Full read support for all common SQL Server types including
sql_variant. - Named-parameter queries using
sp_executesql(@namesyntax). - Streaming large result sets with
queryStream. - Multiple result sets via
queryMultiple. - Transaction support — callback form (auto commit/rollback) and manual
begin/commit/rollback. - TLS encryption with optional self-signed certificate trust.
MssqlExceptionwitherrorCode,severity, andprecedingErrorsfor multi-error batches.