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

add support for fetching values via GetFieldValue<T> #1910

Merged
merged 5 commits into from
Jun 9, 2023
Merged

Conversation

mgravell
Copy link
Member

@mgravell mgravell commented Jun 9, 2023

this requires DbDataReader, but in reality the reader is always DbDataReader; acknowledge this, and stop pretending to use IDataReader internally

The primary use for this is things like SqlDecimal which cannot be accessed other than via DbDataReader.GetFieldValue<T> or via SqlDataReader.GetSqlDecimal

fix #1907

the most relevant parts are:

  • for things like Query<SqlDecimal>, the addition of ReadViaGetFieldValueFactory which is a per-T cached factory method that works a lot like the old logic (now enshrined in ReadViaGetValue), but using IsDbNull and GetFieldValue<T>
  • the addition of LoadReaderValueViaGetFieldValue, which reads a value in IL via IsDbNull and GetFieldValue<T>; the use of IsDbNull means that we won't have anything to pop on the stack (unlike the old with did a read, dup, test, branch - leaving the original copy on the stack if we branched), which is tracked via popWhenNull

DbDataReader, but in reality the reader is *always* DbDataReader;
acknowledge this, and stop pretending to use IDataReader internally
(no breaks to public API)
@mgravell
Copy link
Member Author

mgravell commented Jun 9, 2023

Emphasis: this PR proves everything I am saying in #1909 - maintaining IL emit code is hard

@mgravell
Copy link
Member Author

mgravell commented Jun 9, 2023

all CI is green @NickCraver

Copy link
Member

@NickCraver NickCraver left a comment

Choose a reason for hiding this comment

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

👍 Looking good - thanks for the test tweaks!

@mgravell mgravell merged commit 01f03ef into main Jun 9, 2023
2 checks passed
@mgravell mgravell deleted the sqldecimal branch June 9, 2023 13:02
@PauloHMattos
Copy link

@mgravell This should also close #1644?

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.

No way to store big numbers with a lot of decimal spaces (without storing it in the database as text)
3 participants