swift-tds icon indicating copy to clipboard operation
swift-tds copied to clipboard

SQL Server Varchar

Open richardpauljones opened this issue 2 years ago • 7 comments

I don't seem to be able to get a sensible value for the SQL Server Varchar Data Type.

AField = 'Hello World'. in database

// Swift Code let afield = rows[0].column("AField")?.string print("Field Value = (afield!)")

When run Field Value = 楗摮睯

I noted in the code TDSData+String.swift a Todo label - // TODO switch self.metadata.dataType { case .charLegacy, .varcharLegacy, .char, .varchar, .nvarchar, .nchar, .text, .nText:

If (pretty please), this could be resolved that would be fantastic. I would then have a solution I could use.

richardpauljones avatar Apr 04 '22 14:04 richardpauljones

I have a fix for this in my pull request for RPC implementation. All the strings were being decoded as the same so I separated out the 16bit from 8bit string types for decoding.

Maybe give it a try with my branch and see if it works for you as well. I've tested it against my companies db and a mock db I setup for testing RPC in my latest branch.

I also made changes to the TPC packet parsing because when I pulled large datasets (>1000 rows) I was losing some data during the parsing.

Copterdoctor avatar Apr 04 '22 17:04 Copterdoctor

Fantastic!   What’s the name of your branch?

Kind Regards

Richard

From: Jordan Anders @.> Reply to: aaronjedwards/swift-tds @.> Date: Monday, 4 April 2022 at 18:53 To: aaronjedwards/swift-tds @.> Cc: Richard Jones @.>, Author @.***> Subject: Re: [aaronjedwards/swift-tds] SQL Server Varchar (Issue #20)

I have a fix for this in my pull request for RPC implementation. All the strings were being decoded as the same so I separated out the 16bit from 8bit string types for decoding.

Maybe give it a try with my branch and see if it works for you as well. I've tested it against my companies db and a mock db I setup for testing RPC in my latest branch.

I also made changes to the TPC packet parsing because when I pulled large datasets (>1000 rows) I was losing some data during the parsing.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

richardpauljones avatar Apr 04 '22 18:04 richardpauljones

My fork has the branch merged to master already which I've been using for another project. The branch is ja-rpc.

I'm not sure if it will end up getting merged to this repo. Last time I talked with Aaron he mentioned he had plans to change the API interface a fair bit to function more like the js/tedius SQL library so my branch already be incompatible as I modelled it after the proof of concept implementation.

https://github.com/Copterdoctor/swift-tds

Copterdoctor avatar Apr 04 '22 18:04 Copterdoctor

Hi Jordan.

Any chance I can have a copy please of your TDSData+String.swift ?

Every branch I’ve looked at seems to have the original version in it.

Kind Regards

Richard

Richard Jones | +44 / 0 7795 276690

From: Jordan Anders @.> Reply to: aaronjedwards/swift-tds @.> Date: Monday, 4 April 2022 at 19:17 To: aaronjedwards/swift-tds @.> Cc: Richard Jones @.>, Author @.***> Subject: Re: [aaronjedwards/swift-tds] SQL Server Varchar (Issue #20)

My fork has the branch merged to master already which I've been using for another project. The branch is ja-rpc.

I'm not sure if it will end up getting merged to this repo. Last time I talked with Aaron he mentioned he had plans to change the API interface a fair bit to function more like the js/tedius SQL library so my branch already be incompatible as I modelled it after the proof of concept implementation.

https://github.com/Copterdoctor/swift-tds

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

richardpauljones avatar Apr 05 '22 10:04 richardpauljones

OK,  don’t worry,    I worked it out.

I took at copy from your ja-rpc fork.    All working now!   Many thanks.      

Success!

Kind Regards

Richard

Richard Jones | +44 / 0 7795 276690

From: Jordan Anders @.> Reply to: aaronjedwards/swift-tds @.> Date: Monday, 4 April 2022 at 19:17 To: aaronjedwards/swift-tds @.> Cc: Richard Jones @.>, Author @.***> Subject: Re: [aaronjedwards/swift-tds] SQL Server Varchar (Issue #20)

My fork has the branch merged to master already which I've been using for another project. The branch is ja-rpc.

I'm not sure if it will end up getting merged to this repo. Last time I talked with Aaron he mentioned he had plans to change the API interface a fair bit to function more like the js/tedius SQL library so my branch already be incompatible as I modelled it after the proof of concept implementation.

https://github.com/Copterdoctor/swift-tds

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

richardpauljones avatar Apr 05 '22 12:04 richardpauljones

@Copterdoctor while I haven't looked at your implementation yet, I will still likely be able to use any additional decoding logic that you have added.

aaronjedwards avatar Apr 05 '22 15:04 aaronjedwards

Hi Jordan.

No joy I’m afraid.  I changed my package to use yours.

Still returning 3 Chinese looking characters for varchar ☹

Thanks for getting back to me, I do appreciate it.

Kind Regards

Richard

From: Jordan Anders @.> Reply to: aaronjedwards/swift-tds @.> Date: Monday, 4 April 2022 at 19:17 To: aaronjedwards/swift-tds @.> Cc: Richard Jones @.>, Author @.***> Subject: Re: [aaronjedwards/swift-tds] SQL Server Varchar (Issue #20)

My fork has the branch merged to master already which I've been using for another project. The branch is ja-rpc.

I'm not sure if it will end up getting merged to this repo. Last time I talked with Aaron he mentioned he had plans to change the API interface a fair bit to function more like the js/tedius SQL library so my branch already be incompatible as I modelled it after the proof of concept implementation.

https://github.com/Copterdoctor/swift-tds

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

richardpauljones avatar Oct 11 '22 08:10 richardpauljones