-
Notifications
You must be signed in to change notification settings - Fork 351
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
uniqueidentifier formatting on sql server #439
Comments
Formatting issues like this are because that's what the underlying database driver is returning, in this case raw bytes. That gets escaped/displayed as shown. To get better formatting, try casting/converting this field. Microsoft's documentation gives this: CONVERT(CHAR(255), id_field) AS 'char' This should get back to |
Is there any way to customize (e.g. even a local build/patch/fork) usql to format it on the clientside without having to do the dance of modifying the query? I really like the look of usql, but if I get uniqueidentifiers formatted as binary blobs, that will severely limit the utility for my use-case at least. I'd have hoped that I could do stuff like |
@birkmose I've looked into the underlying type that should be returned by the driver, and it has a |
@birkmose I've been reading the SQL Server driver code, and it doesn't appear that it's ever allocating a |
This is the image i tested with on linux: mcr.microsoft.com/azure-sql-edge:latest |
Breakage: microsoft/mssql-docker#868 |
@birkmose After downgrading a kernel or two, I was able to get the container to run. The type being returned from the driver is indeed |
@birkmose I've dug deep into the SQL Server driver code, and it is not easy to fix this. From what I can tell, there's an internal call to I could add a hack to The SQL Server driver just isn't up to the same kind of functionality/support that other database drivers are. Other drivers will convert to the "best type" when presented with a That said, the ultimate resolution to this would be to politely ask Microsoft to fix this in their code. I will implement the hack and push it to the tree, but the |
@birkmose I think I have a non-hacky PR that I can get the MS repo to accept, which will require no changes to |
…ntifer for GUID types The Rows.ColumnScanType is returning `reflect.TypeOf([]byte{})` for GUID types (`typeGuid`). This changes it so that it instead returns `reflect.TypeOf(UniqueIdentifier{})`, which has the knock down effects of using packages being able to correctly ascertain the column type for for `UniqueIdentifier`'s. This is needed for use by `usql` (see xo/usql#439) in order to correctly format/display GUIDs cleanly and as users expect.
@birkmose you can compile/use this from source yourself: $ mkdir src
$ cd src
$ git clone https://github.com/kenshaw/go-mssqldb.git
$ git clone https://github.com/xo/usql.git
$ cd usql
$ go work init
$ go work use .
$ go work edit -replace github.com/microsoft/go-mssqldb=../go-mssqldb
$ go install |
Thanks @kenshaw! The uniqueidentifier now works, but seems that master is broken - getting errors like: (for a column |
@birkmose Ok; and that wasn't happening before? |
Not from the |
I'll look into it. |
@birkmose I pushed a new commit to fix this, without requiring any changes to the underlying driver. Please check it out and test it. |
Sorry for the late answer @kenshaw , got caught up in some other stuff. I can confirm that a simple |
Hi!,
When displaying
uniqueidentifier
columns on SQL server the output looks binary and not formatted?E.g.
Saw some upstream issue that might be related to this?: microsoft/go-mssqldb#92
The text was updated successfully, but these errors were encountered: