1Sa 23:12 Then David said, “Will the men of Keilah surrender me and my men into the hand of Saul?” And the LORD said, “They will surrender you.”
In 1Sa 23:12, King David has just saved the city of Keilah from the Philistines. King Saul hears about this and is delighted that David has picked a static location for Saul to attack. Saul has been jealous of David for some time and finally sees his opportunity to be rid of David. David, knowing of Saul’s pending attack consults God: Will the city of Keilah surrender David over to Saul if Saul appears. To whom do they show loyalty? God answers that Keilah will surrender David to Saul.
One way to read this passage is that God has in His mind every single path and outcome that can and will occur based on the free actions of human beings. If King David stays, he will be turned over to Saul (absent some other choice or intervention).
Another way to read this passage is that God is merely telling David to whom the city is loyal. The question functions in the same way as “is the city loyal to Saul or David?”. If this is the case, the question would be a current survey of the intentions of the key players in the city.
Both these readings are in contrast to any omniscience of all future events. God states what will happen. It does not happen. David was able to use knowledge of possible events to subvert those events, much like God leading Israel out of Egypt by a certain route which avoided the Philistines in case they would decide to return to Egypt (Exo 13:17).