Skip to content

CLI: a SQL Server named instance (host\INSTANCE) fails with a bare Invalid URL #239

Description

@tiagolauer

A SQL Server named instance (host\INSTANCE) is the default install shape on Windows, and it cannot be expressed in the mssql:// URL form the CLI documents: new URL() rejects \ as a host character, so the CLI dies with a bare "Invalid URL" and no hint about what to do instead.

Reproduction

$ owlsql generate --url "mssql://sa:pass@localhost\SQLEXPRESS/db"
Error: Invalid URL
mssqlUrlToConfig('mssql://sa:pass@localhost\\SQLEXPRESS/db')  // throws TypeError: Invalid URL
mssqlUrlToConfig('mssql://sa:p%40ss@localhost:1433/db')       // ok

The ADO form does work (--url "Server=localhost\SQLEXPRESS;Database=db;User Id=sa;Password=pass"ADO_MSSQL_PATTERN routes it to mssql and the string is handed to mssql.connect untouched), so this is a discoverability problem more than a missing capability.

Suggestions

  • Catch the new URL failure in mssqlUrlToConfig and rethrow with the redacted URL plus the ADO alternative, the way unrecognizedUrlError already does for other bad URLs.
  • Optionally support the shape directly by splitting host\instance before parsing and emitting options.instanceName (node-mssql's own config field for it).
  • Either way, mention named instances in the --url row of the CLI table in the README.

Found in an audit of master @ dc1afdb (v0.1.8).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions