You need Probable Cause to justify why he pulled you over to begin with. It can be for anything from an equipment violation (Exp registration, brake light out) or a moving violation.
Once that is establish, if the Officer believes you to be Under the Influence, he can check your sobriety. BUT he has to have and give you a reason why he pulled you over, being near a bar DOES NOT give Probable Cause to check for sobriety.
Now, if he watched you stumble out of the bar and get into your car, that is enough Probable Cause to pull u over to check your sobriety.
Fight the ticket, you will get out of it