would cause the object[] that is normally returned to always contain a null value for last parameter.
Reason:
In the document builder when getting the array position of a project the problem is in the GetFieldPosition method.
CURRENT
private static int GetFieldPosition(string[] fields, string fieldName) { int fieldNbr = fields.GetUpperBound(0); for (int index = 0; index < fieldNbr; index++) { if (fieldName.Equals(fields[index])) { return index; } }
return -1; }
FIX
change the line int fieldNbr = fields.GetUpperBound(0);
to int fieldNbr = fields.Length;
Details **
The GetUpperBound will return the ZERO based upper boundary of the array. Meaning it doesn't return the total number of items in the array, just the highest index in the array. Which means when iterating over these results we are not evaluating the last projection entry.
ALSO This is the corresponding line from the current java 3.0.1 GA release
private static int getFieldPosition(String[] fields, String fieldName) { int fieldNbr = fields.length; for (int index = 0; index < fieldNbr; index++) { if ( fieldName.equals( fields[index] ) ) return index; } return -1; }
which also states that this function should point to Length and not GetUpperBound(0);
While trying to do some tests I found a bug which causes all projections to lose their last value.
For example if you have an Employee class with the fields of "Id", "Lastname", and "Dept".
a query like this
IFullTextQuery hibQuery = s.CreateFullTextQuery(query, typeof(Employee));
hibQuery.SetProjection("Id", "Lastname", "Dept");
would cause the object[] that is normally returned to always contain a null value for last parameter.
Reason:
In the document builder when getting the array position of a project the problem is in the GetFieldPosition method.
CURRENT
private static int GetFieldPosition(string[] fields, string fieldName)
{
int fieldNbr = fields.GetUpperBound(0);
for (int index = 0; index < fieldNbr; index++)
{
if (fieldName.Equals(fields[index]))
{
return index;
}
}
return -1;
}
FIX
change the line
int fieldNbr = fields.GetUpperBound(0);
to
int fieldNbr = fields.Length;
Details **
The GetUpperBound will return the ZERO based upper boundary of the array. Meaning it doesn't return the total number of items in the array, just the highest index in the array. Which means when iterating over these results we are not evaluating the last projection entry.
ALSO This is the corresponding line from the current java 3.0.1 GA release
private static int getFieldPosition(String[] fields, String fieldName) {
int fieldNbr = fields.length;
for (int index = 0; index < fieldNbr; index++) {
if ( fieldName.equals( fields[index] ) ) return index;
}
return -1;
}
which also states that this function should point to Length and not GetUpperBound(0);
Patch is attached.