Skip to content

HasRows, RecordsAffected, GetFieldType for OCTETS and RemoveAt(int) depart from the ADO.NET contract #1282

Open

Description

@alaricd

FirebirdClient 10.3 (Firebird 4.0 and 5.0) departs from the documented ADO.NET contract in four places. I have a pull request ready with a fix and tests for each, and I'll link it here. I'm opening this first, as CONTRIBUTING asks.

  1. HasRows is true for an empty result. It returns _command.HasFields, which says whether the statement has columns, not whether it has rows.
    DbDataReader.HasRows: "true if the DbDataReader contains one or more rows; otherwise false."
  2. RecordsAffected is 0 for a SELECT. _recordsAffected starts at 0, although UpdateRecordsAffected treats -1 as "no count yet", and the reader adds the statement's count whatever the statement type.
    DbDataReader.RecordsAffected: "-1 for SELECT statements; 0 if no rows were affected or the statement failed."
  3. GetFieldType reports String for CHAR/VARCHAR ... CHARACTER SET OCTETS, but GetValue returns byte[] (DbField.SetValue stores octets as bytes).
    IDataRecord.GetFieldType: "the type of Object that would be returned from GetValue."
  4. FbParameterCollection.RemoveAt(int) throws IndexOutOfRangeException for an invalid index. The range check is also off by one (index > Count), so RemoveAt(Count) fails later, in the indexer.
    DbParameterCollection.RemoveAt(Int32) implements IList.RemoveAt: ArgumentOutOfRangeException when "index is not a valid index in the IList."

Found by the pengdows ADO.NET conformance suite: HasRows_returns_false_when_no_rows, RecordsAffected_returns_negative_1_after_close_when_no_rows, GetFieldType_matches_GetValue_for_supported_values, ParameterCollection_RemoveAt_negative_one_throws.

AI disclosure: the analysis, the fix and this text were produced with Claude Code (an AI assistant).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions