dbt-msft / dbt-sqlserver

dbt adapter for SQL Server and Azure SQL
MIT License
205 stars 96 forks source link

Port is not being applied properly when using Windows Login with non-default port #496

Open cody-scott opened 4 months ago

cody-scott commented 4 months ago

When calling dbt debug from windows using the following profile, the windows login defaults to the Fabric adapter implementation, which omits the port from the connection string.

dbt_project:
  target: dev
  outputs:
    dev:
      type: sqlserver
      driver: 'ODBC Driver 18 for SQL Server'
      server: 0.0.0.0
      port: 1444
      database: data_base
      schema: dbt
      trust_cert: true
      encrypt: false
      windows_login: true

this resolves to

DRIVER={ODBC Driver 18 for SQL Server};SERVER=0.0.0.0;Database=data_base;trusted_connection=Yes;encrypt=No;TrustServerCertificate=Yes;APP=dbt-sqlserver/1.7.4;ConnectRetryCount=1

When using a the standard sql login flow, it adds the port as expected.

Solved by either adding the port to the SERVER line (0.0.0.0,1444) + communicating this to users or lifting the windows login piece out of fabric into this adapter.

dbt_project:
  target: dev
  outputs:
    dev:
      type: sqlserver
      driver: 'ODBC Driver 18 for SQL Server'
      server: 0.0.0.0,1444
      database: data_base
      schema: dbt
      trust_cert: true
      encrypt: false
      windows_login: true