Wolfram Language (Mathematica), 33 2626 31 bytes
Fixed an error noted by Kelly Lowder in the comments.
x/.{}⋃Solve[#==0,x,Integers]&
Previous incorrect solutions:
I just noticed that for no integer solution, the output is undefined instead of empty list; that allows to remove a few bytes.
x/.Solve[#==0,x,Integers]&
Now if no integer solution exists, the function returns x
.
Previously:
x/.Solve[#==0,x,Integers]/.x->{}&