wiki:FdoDataValueCompare

Version 1 (modified by gregboone, 17 years ago) ( diff )

--

FDO DataValue Comparison

Overview

There are a number of places in core FDO and Provider source code where data values are compared, which include but are not limited to:

  • in the FdoIInsert and FdoIUpdate implementations of non-RDBMS providers that support Property Value Constraints. When a property has a constraint, each property value being inserted or updated is validated against this constraint.
  • in the FdoIApplySchema implementation of the SDF Provider. This provider does not allow Value constraints, on Properties with data, to be made more restrictive, since the existing data might violate the updated constraint. Checking whether a range constraint is being made more restrictive, involves the comparing of its old and new range endpoints.

These data values include property values for features and property constraint values. Comparing data values is not a trivial operation because of the following:

  • there are 12 different types of data values. The numeric ones can be compared using basic operators ( >, <, ==, etc. ), but runtime functions are required for strings. For DateTimes each component ( year, month, etc. ) must be compared.
  • the data values to be compared might be of different types, meaning that type conversion may need to be done before the values can be compared. Some types are not compatible and cannot be compared.
  • one or both of the data values may be null. A null value cannot be compared to a not-null value even if both have the same data type.

Data value comparisons are currently implemented at various other spots in core FDO and the FDO providers. Implementing these conversions at different spots leads to the following problems:

  • there is no consistent handling of type comparisons. For example, different parts of FDO might handle null values differently.
  • code duplication. More expensive maintenance if the same fix has to be applied in multiple places (this can easily happen when the value comparison code is cloned to different places).
  • more difficult for developers to find the value comparison functions currently available, since these can be in various places.

Data values are encapsulated in the FdoDataValue class and its derivations. There is a derivation for each data type supported by FDO. An FDO data type is a scalar type that commonly occurs in the data sources supported by FDO. Examples include integer (8bit, 16bit, 32bit, 64bit), string and datetime.

This document proposes to add a comparison function to FdoDataValue. The function would take a second data value and return the result of comparing the current value to the second one. There would be 4 different possible results:

  • current value is greater than second value
  • both values are equal or both null
  • current value is less than second value
  • the two values cannot be compared

Attachments (1)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.