Invalid Cast from FilterQueryHandler


I needed to get the fix for the incorrect identification of Primary Keys and retrieved changeset 28600 from svn (after newest builds failed to install). When I ran this code I was getting casting errors from [ST].[FilterQuery] on tables with 32 bit primary keys.
The error appears to due to reader.GetInt64(0) in the FilterQueryHandler(SqlDataReader reader, IGeometry geometry, SpatialQuery.Arguments args) of FilterQuery.cs.
The reader.GetInt64(0) performs no casting and requires the underlying datatype to be int64 in SQL which fails to work on all tables using 32bit integer primary keys. I am new to modifying the MsSqlSpatial code so I am not sure if you were intending to force 64 bit int primary keys or not, but if you are not the following code change resolves this error and will work with 16, 32 & 64 bit integers.
I made this change to all instances of reader.GetInt64 in the project maintaining the column ordinals. My testing confirms this resolved the casting issues we were experiencing and does not appear to have had any negative side effects.
Please review and consider adding this change to the project if there was a reason to remove support for 32 bit integers keys.
Best Regards,
Closed Jun 7, 2008 at 4:21 PM by JohnDiss
fixed in changeset 33847