I'm aware that I've likely made a very simple error/misunderstanding here, but I have some confusion about the divergence of an electric field of a point charge which should be zero at all points in space asides from the location of the charge. When I try to determine the divergence at some points I don't see the divergence becoming zero.
Suppose there's a stationary point charge $q$ at the origin of a cartesian system. Now consider a point on the x-axis. The electric field due to a this charge is $E= \frac{kq}{r^2}\hat r $. Here $\hat r$ and $\hat x$ point in the same direction and it seems that the field in the $y, z$ directions should be 0. So then $E=\frac{kq}{x^2}\hat x $, at least in the positive direction (the fact that this doesn't work for negative $x$ seems to suggest to me there might already be an issue). Taking the divergence (only x-component is nonzero) $\frac{\partial E_x }{\partial x} = \frac{-2kq}{x^3}\neq0$.
Is there some issue with applying the idea of 0 divergence of the electric field in fewer dimensions, or did I make a straightforward error somewhere?