Heat 5cm of oil in a small, deep, heavy-based frying pan until hot. Fry the diced aubergine in batches – do not crowd the pan – until golden brown, then drain on kitchen paper, sprinkle with salt and set aside. The oil can be strained and used to fry again.
Trim the celery stalks of any tough ends or strings and cut in half. Add the celery to a pan of boiling water and cook for about 5 minutes until tender, but still with bite. Drain. Once cool enough to handle, chop the celery into 1cm chunks and set aside. If the capers are salted, soak them for 2 minutes, then drain. If brined or in vinegar, drain and rinse. Pit the olives.
In a large, deep frying pan, warm 4 tbsp oil over a medium-low heat, add the onion and cook for 1-2 minutes. Add the tomato sauce and cook for another 2 minutes, then stir in the capers, olives, raisins and pine nuts.
Make a well in the middle of the pan and add the sugar and vinegar to it, allowing the sugar to dissolve in the heat. Stir and cook for 1-2 minutes, tasting to see if it needs more sugar or vinegar. Turn off the heat, add the aubergines and the celery and rip the basil into the pan.
Stir gently, so the aubergine remains in distinct pieces. Leave to sit for at least 2 hours, or better still several, stirring gently once or twice.