Patch for issue #238: Check if primary ID column is available before trying to access it in the cursor.