Skip to content

SQL Server adapter: update parameters for latest version of sqlcmd#133

Closed
johnybx wants to merge 1 commit intotpope:masterfrom
johnybx:master
Closed

SQL Server adapter: update parameters for latest version of sqlcmd#133
johnybx wants to merge 1 commit intotpope:masterfrom
johnybx:master

Conversation

@johnybx
Copy link
Contributor

@johnybx johnybx commented May 17, 2023

Based on this issue #127 and latest docs for sqlcmd the password is now supplied in SQLCMDPASSWORD environment variable. I also updated the adapter to properly support encrypt-connection, format, column-separator, trim-spaces and trust-server-certificate options. For backward compatibility I left there old flags secure and trustServerCertificate.

@tpope
Copy link
Owner

tpope commented May 18, 2023

There's a lot going on here. Let's do the password change and the new query options separately.

@johnybx
Copy link
Contributor Author

johnybx commented May 18, 2023

Sure, I created new pull request for password change. Once that is merged I will rebase this one.

Comment on lines +54 to +55
" Legacy parameters left just for backward compatibility with older sqlcmd: secure and
" trustServerCertificate
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah now I understand the naming ( I thought that parameters were derived from sqlcmd --help ) - but at least for secure parameter which is supposed to be encrypt there was change

In version 11.2.0 and up, encrypt has been changed from boolean to string, allowing for TDS 8.0 support when the property is set to strict.

Do you want to keep secure a boolean parameter and encrypt as string parameter or there should be just one parameter and type of value will be detected ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since -N doesn't accept a string, and thus there's no way for us to do anything withencrypt=strict, I think we should just leave it as is for now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is actually one of the reasons why I started this pull request - I am using latest sqlcmd:

❯ sqlcmd --version
sqlcmd: 1.0.0

and I cannot use -N as boolean parameter because it was changed

❯ sqlcmd -N
sqlcmd: error: --encrypt-connection: expected string value but got "EOL" (<EOL>)
❯ sqlcmd -N X
sqlcmd: error: --encrypt-connection must be one of "default","false","true","disable" but got "X"
❯ sqlcmd -N disable
unable to open tcp connection with host 'localhost:1433': dial tcp [::1]:1433: connect: connection refused

The idea was that I would add parameter while keeping old one so that the adapter is not broken for people with older version of sqlcmd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rebased the PR and one more thing to note is that encrypt and trustServerCertificate are properties of connection according to specification but format, column-separator and trim-spaces are options of sqlcmd client.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, those have no business being in a URL. URLs specify how to connect to the database, not arbitrary command-line flags. There have been multiple requests of this nature lately (#129, #125) so I think we should add some sort of general interface for that.

As for -N, I'm pushing a fix to support -N on ?encrypt=1 and a string argument for anything else.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants