Skip to content

Fix: Miscellaneous ODBC compatibility fixes #397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 20 additions & 37 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ This repository incorporates material as listed below or described in the code.
## github.com/Azure/azure-sdk-for-go/sdk/azcore

* Name: github.com/Azure/azure-sdk-for-go/sdk/azcore
* Version: v1.1.2
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/azcore/v1.1.2/sdk/azcore/LICENSE.txt)
* Version: v1.6.0
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/azcore/v1.6.0/sdk/azcore/LICENSE.txt)

```
MIT License
Expand Down Expand Up @@ -37,8 +37,8 @@ SOFTWARE
## github.com/Azure/azure-sdk-for-go/sdk/azidentity

* Name: github.com/Azure/azure-sdk-for-go/sdk/azidentity
* Version: v1.2.1
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/azidentity/v1.2.1/sdk/azidentity/LICENSE.txt)
* Version: v1.3.0
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/azidentity/v1.3.0/sdk/azidentity/LICENSE.txt)

```
MIT License
Expand Down Expand Up @@ -68,8 +68,8 @@ SOFTWARE
## github.com/Azure/azure-sdk-for-go/sdk/internal

* Name: github.com/Azure/azure-sdk-for-go/sdk/internal
* Version: v1.0.0
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/internal/v1.0.0/sdk/internal/LICENSE.txt)
* Version: v1.3.0
* License: [MIT](https://github.com/Azure/azure-sdk-for-go/blob/sdk/internal/v1.3.0/sdk/internal/LICENSE.txt)

```
MIT License
Expand Down Expand Up @@ -99,8 +99,8 @@ SOFTWARE
## github.com/AzureAD/microsoft-authentication-library-for-go/apps

* Name: github.com/AzureAD/microsoft-authentication-library-for-go/apps
* Version: v0.8.1
* License: [MIT](https://github.com/AzureAD/microsoft-authentication-library-for-go/blob/v0.8.1/LICENSE)
* Version: v1.0.0
* License: [MIT](https://github.com/AzureAD/microsoft-authentication-library-for-go/blob/v1.0.0/LICENSE)

```
MIT License
Expand Down Expand Up @@ -1411,8 +1411,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## github.com/golang-jwt/jwt/v4

* Name: github.com/golang-jwt/jwt/v4
* Version: v4.4.2
* License: [MIT](https://github.com/golang-jwt/jwt/blob/v4.4.2/LICENSE)
* Version: v4.5.0
* License: [MIT](https://github.com/golang-jwt/jwt/blob/v4.5.0/LICENSE)

```
Copyright (c) 2012 Dave Grijalva
Expand All @@ -1430,8 +1430,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
## github.com/golang-sql/civil

* Name: github.com/golang-sql/civil
* Version: v0.0.0-20190719163853-cb61b32ac6fe
* License: [Apache-2.0](https://github.com/golang-sql/civil/blob/cb61b32ac6fe/LICENSE)
* Version: v0.0.0-20220223132316-b832511892a9
* License: [Apache-2.0](https://github.com/golang-sql/civil/blob/b832511892a9/LICENSE)

```

Expand Down Expand Up @@ -4683,8 +4683,8 @@ THE SOFTWARE.
## golang.org/x/crypto

* Name: golang.org/x/crypto
* Version: v0.0.0-20220622213112-05595931fe9d
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/crypto/+/05595931:LICENSE)
* Version: v0.9.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/crypto/+/v0.9.0:LICENSE)

```
Copyright (c) 2009 The Go Authors. All rights reserved.
Expand Down Expand Up @@ -4720,8 +4720,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## golang.org/x/net

* Name: golang.org/x/net
* Version: v0.7.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/net/+/v0.7.0:LICENSE)
* Version: v0.10.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/net/+/v0.10.0:LICENSE)

```
Copyright (c) 2009 The Go Authors. All rights reserved.
Expand Down Expand Up @@ -4757,8 +4757,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## golang.org/x/sys

* Name: golang.org/x/sys
* Version: v0.5.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.5.0:LICENSE)
* Version: v0.8.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/sys/+/v0.8.0:LICENSE)

```
Copyright (c) 2009 The Go Authors. All rights reserved.
Expand Down Expand Up @@ -4794,8 +4794,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
## golang.org/x/text

* Name: golang.org/x/text
* Version: v0.7.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.7.0:LICENSE)
* Version: v0.9.0
* License: [BSD-3-Clause](https://cs.opensource.google/go/x/text/+/v0.9.0:LICENSE)

```
Copyright (c) 2009 The Go Authors. All rights reserved.
Expand Down Expand Up @@ -5066,23 +5066,6 @@ third-party archives.

```

## gopkg.in/natefinch/npipe.v2

* Name: gopkg.in/natefinch/npipe.v2
* Version: v2.0.0-20160621034901-c1b8fa8bdcce
* License: [MIT](https://github.com/natefinch/npipe/blob/c1b8fa8bdcce/LICENSE.txt)

```
The MIT License (MIT)
Copyright (c) 2013 npipe authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
```

## gopkg.in/yaml.v2

* Name: gopkg.in/yaml.v2
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ The `sqlcmd` project aims to be a complete port of the original ODBC sqlcmd to t

The following switches have different behavior in this version of `sqlcmd` compared to the original ODBC based `sqlcmd`.
- `-r` requires a 0 or 1 argument
- `-R` switch will be removed. The go runtime does not provide access to user locale information, and it's not readily available through syscall on all supported platforms.
- `-I` switch will be removed. To disable quoted identifier behavior, add `SET QUOTED IDENTIFIER OFF` in your scripts.
- `-R` switch is ignored. The go runtime does not provide access to user locale information, and it's not readily available through syscall on all supported platforms.
- `-I` switch is ignored; quoted identifiers are always set on. To disable quoted identifier behavior, add `SET QUOTED IDENTIFIER OFF` in your scripts.
- `-N` now takes a string value that can be one of `true`, `false`, or `disable` to specify the encryption choice.
- If `-N` and `-C` are not provided, sqlcmd will negotiate authentication with the server without validating the server certificate.
- If `-N` is provided but `-C` is not, sqlcmd will require validation of the server certificate. Note that a `false` value for encryption could still lead to encryption of the login packet.
Expand All @@ -128,6 +128,7 @@ The following switches have different behavior in this version of `sqlcmd` compa
- All commands must fit on one line, even `EXIT`. Interactive mode will not check for open parentheses or quotes for commands and prompt for successive lines. The ODBC sqlcmd allows the query run by `EXIT(query)` to span multiple lines.
- `-i` now requires multiple arguments for the switch to be separated by `,`.
- `-v` requires multiple variable setters to be comma-separated. eg: `-v var1=v1,var2=v2 -v "var3=v 3"`
- `-M` switch is ignored. Sqlcmd always enables multi-subnet failover.

### Switches not available in the new sqlcmd (go-sqlcmd) yet

Expand Down
5 changes: 3 additions & 2 deletions cmd/sqlcmd/sqlcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ type SQLCmdArguments struct {
VariableTypeWidth *int
FixedTypeWidth *int
TrimSpaces bool
MultiSubnetFailover bool
Password string
DedicatedAdminConnection bool
ListServers bool
Expand Down Expand Up @@ -307,7 +306,7 @@ func setFlags(rootCmd *cobra.Command, args *SQLCmdArguments) {
rootCmd.Flags().BoolVarP(&args.UnicodeOutputFile, "unicode-output-file", "u", false, localizer.Sprintf("Specifies that all output files are encoded with little-endian Unicode"))
rootCmd.Flags().StringVarP(&args.ColumnSeparator, "column-separator", "s", "", localizer.Sprintf("Specifies the column separator character. Sets the %s variable.", localizer.ColSeparatorVar))
rootCmd.Flags().BoolVarP(&args.TrimSpaces, "trim-spaces", "W", false, localizer.Sprintf("Remove trailing spaces from a column"))
rootCmd.Flags().BoolVarP(&args.MultiSubnetFailover, "multi-subnet-failover", "M", false, localizer.Sprintf("Provided for backward compatibility. Sqlcmd always optimizes detection of the active replica of a SQL Failover Cluster"))
_ = rootCmd.Flags().BoolP("multi-subnet-failover", "M", false, localizer.Sprintf("Provided for backward compatibility. Sqlcmd always optimizes detection of the active replica of a SQL Failover Cluster"))

rootCmd.Flags().StringVarP(&args.Password, "password", "P", "", localizer.Sprintf("Password"))

Expand All @@ -319,6 +318,8 @@ func setFlags(rootCmd *cobra.Command, args *SQLCmdArguments) {
_ = rootCmd.Flags().IntP(fixedTypeWidth, "Y", 0, setScriptVariable("SQLCMDMAXFIXEDTYPEWIDTH"))
rootCmd.Flags().BoolVarP(&args.ListServers, "list-servers", "L", false, "List servers")
rootCmd.Flags().BoolVarP(&args.DedicatedAdminConnection, "dedicated-admin-connection", "A", false, localizer.Sprintf("Dedicated administrator connection"))
_ = rootCmd.Flags().BoolP("enable-quoted-identifiers", "I", true, localizer.Sprintf("Provided for backward compatibility. Quoted identifiers are always enabled"))
_ = rootCmd.Flags().BoolP("client-regional-setting", "R", false, localizer.Sprintf("Provided for backward compatibility. Client regional settings are not used"))
}

func setScriptVariable(v string) string {
Expand Down
27 changes: 13 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ require (
github.com/docker/go-connections v0.4.0
github.com/golang-sql/sqlexp v0.1.0
github.com/google/uuid v1.3.0
github.com/microsoft/go-mssqldb v1.0.0
github.com/microsoft/go-mssqldb v1.3.0
github.com/opencontainers/image-spec v1.0.2
github.com/peterh/liner v1.2.2
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.1
golang.org/x/sys v0.5.0
golang.org/x/text v0.7.0
golang.org/x/tools v0.1.12
golang.org/x/sys v0.8.0
golang.org/x/text v0.9.0
golang.org/x/tools v0.6.0
gopkg.in/yaml.v2 v2.4.0
)

require (
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.1.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.0.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v0.8.1 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
Expand All @@ -39,8 +39,8 @@ require (
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt/v4 v4.4.2 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -66,12 +66,11 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/crypto v0.9.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.10.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.4.0 // indirect
)
Loading