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

Ntj/nuo db data reader #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Ntj/nuo db data reader #37

wants to merge 3 commits into from

Conversation

NikTJ777
Copy link

Implement NuoDbDataReader.HasRows

Newer EFCore code relies on DataReader.hasRows.
However, our original implementation in NuoDbDataReader threw a NotImplemented exception.

This implementation correctly handles the case where the response from the TE contains zero (0) rows.

Copy link

@kontaras kontaras left a comment

Choose a reason for hiding this comment

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

I have never done C# development or made changes to this repo, so feel free to ignore my input, but I had a couple of code style comments.

@@ -76,7 +76,7 @@ private void InitResultSet(int handle, EncodedDataStream dataStream, bool readCo
this.values = new Value[numberColumns];
this.closed = false;
this.currentRow = 0;
this.afterLast = false;
// this.afterLast = false;

Choose a reason for hiding this comment

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

Why leave code commented out?

Copy link
Author

Choose a reason for hiding this comment

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

This line was in a block that previously set ALL the member fields.

I agree that leaving a commented line is poor style.
I'll replace the commented line with a comment that explains why afterLast is not being set now.

The alternative was to set afterLast = false here, as originally done, and then set its value later.
But, I thought was was potentially confusing.

return false;

//int maxRows = statement == null ? 0 : statement.MaxRows;
int maxRows = 0;
int maxRows = 0; // this local maxRows HIDES this.maxRows

Choose a reason for hiding this comment

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

If this variable is hiding a class field, why not rename it?

Copy link
Author

Choose a reason for hiding this comment

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

I regard this as a hack,

It was in the original code - I didn't make this change originally.

I left this highly dubious code for now, because I wanted just to implement the needed feature in this PR - and not get embroiled in cleaning this code up and ensuring the correct behaviour remains.

In a later PR, I will fix this code by removing the hiding, and cleaning up the code that relies on the hidden var.

To answer you question, there is a condition later in this method that tests maxRows, so hiding maxRows with a local zero (0) value effectively disables that test.
Which is the intention of this code.

I think the long term solution is to just make sure this class works correctly in the absence of a reliable maxRows value.

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.

2 participants