Skip to content
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

Sybase float column read as double by AseDataReader #217

Open
alfhv opened this issue Aug 20, 2021 · 2 comments
Open

Sybase float column read as double by AseDataReader #217

alfhv opened this issue Aug 20, 2021 · 2 comments

Comments

@alfhv
Copy link

alfhv commented Aug 20, 2021

I have a SyBase DB table with field of type "float", so I have declared a C# backend field of type "float" also.

When I execute ExecuteReader(sqlQuery), in the retourned AseDataReader class, the column type of field is "double".
When converting this double value to backend "float" field I have precission loss.

How can I force AseDataReader to map column to "float" type as defined in DB ??

Environment

  • .NET Core version 3.1
  • AdoNetCore.AseClient : 0.19.2
@alfhv
Copy link
Author

alfhv commented Aug 20, 2021

Please check on this issue and let me know if we are in correct path: linq2db/linq2db#3183

@Ju42
Copy link

Ju42 commented Dec 5, 2023

Hello, I might be missing some informations but from what I can understand you're trying to use the GetFloat method of the AseDataReader class ?

if yes then you have 2 cases:

  1. the column you're dealing with is a float with a default precision strictly below 16: the your float is actually stored as a real (see https://infocenter-archive.sybase.com/help/topic/com.sybase.help.ase_15.0.blocks/blocks.pdf page 17, "Range, precision and storage size")
  2. the column you're dealing with is a float with a default precision greater or equal to 16 then your float is actually stored as a double

Now from my understanding of this driver implementation if you are in the first case then it will consider the value as TDS_FLT4 leading to being represented as a float while in the second case the value will be considered as TDS_FLT8 and will be represented as a double. Then if you call the GetFloat method on the second case you'll get a double that is then converted to a float.

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

No branches or pull requests

2 participants