Find all functions $f$ such that for any rationals $x$ and $y$, $f(x+y)=f(x)f(y)-f(xy)+1$. 
Find all functions $f$ such that for all rational numbers $x$, $y$, $$f(xy)+f(x+y)=f(x)f(y)+1\,.$$

I already asked the same question where $x$ and $y$ were integers, but this time I want to solve this functional equation over the rationals. The solutions when $x$ and $y$ are integers are $f(x)=1$, $f(x)=x+1$ and $f(x)=\frac{1+(-1)^x}{2}$. So far, I have been able to prove that $f(x)=1$ and $f(x)=x+1$ are also solutions over the rationals, but I am struggling to do the same for $f(x)=\frac{1+(-1)^x}{2}$, and I don't actually know if this is a solutions over the rationals
 A: Let $f:\mathbb{Q}\to\mathbb{R}$ be a function that satisfies 
$$f(xy)+f(x+y)=f(x)\,f(y)+1\tag{*}$$ for all $x,y\in\mathbb{Z}_{>0}$.  From the old link, we know (by studying $f|_{\mathbb{Z}_{>0}}$) that there are three possible values of $f(1)$: $0$, $1$, or $2$.  
If $f(1)=1$, then by setting $y:=1$ in the functional equation (*), we get
$f(x+1)=1$
for all $x\in\mathbb{Q}$.  That is, $$f(x)=1\text{ for all }x\in\mathbb{Q}\tag{#}$$
is the only solution in this case.  
We now assume that $f(1)=2$.  Again, setting $y:=1$ in the functional equation (*), we get $$f(x+1)=f(x)+1$$
for all $x\in\mathbb{Q}$.  This shows that the function $g:\mathbb{Q}\to\mathbb{R}$ defined by $$g(x):=f(x)-x-1\text{ for each }x\in\mathbb{Q}$$
is periodic with period $1$.  From (*), we have
$$g(xy)+g(x+y)=g(x)\,g(y)+(x+1)\,g(y)+(y+1)\,g(x)$$
for all $x,y\in\mathbb{Q}$.  Let $p$ and $q$ be coprime integers with $q>0$.  Setting $x:=\dfrac{p}{q}$ and $y:=q$ in the equation above (knowing that $g(1)=0$ and periodicity of $g$), we get
$$\begin{align}g\left(\frac{p}{q}\right)&=g\left(\frac{p}{q}\cdot q\right)+g\left(\frac{p}{q}+q\right)
\\&=g\left(\frac{p}{q}\right)\,g(q)+\left(\frac{p}{q}+1\right)\,g(q)+(q+1)\,g\left(\frac{p}{q}\right)\\&=(q+1)\,g\left(\frac{p}{q}\right)\,.\end{align}$$
This shows that $g\left(\dfrac{p}{q}\right)=0$.  That is, $g(x)=0$ for all $x\in\mathbb{Q}$.  Ergo,
$$f(x)=x+1\text{ for every }x\in\mathbb{Q}\tag{@}$$
is the only solution in this case.
We are left with the remaining case $f(1)=0$.  Plugging $y:=1$ in (*) yields
$$f(x+1)=1-f(x)$$
for all $x\in\mathbb{Q}$.  In particular, this means
$$f(x+2)=1-f(x+1)=1-\big(1-f(x)\big)=f(x)$$
for all $x\in\mathbb{Q}$.  Therefore, $f$ is periodic with period $2$.  Note that $f(0)=1-f(1)=1$.  Thus, $$f(n)=\frac{1+(-1)^n}{2}$$ for all $n\in\mathbb{Z}$.   Setting $x:=\dfrac{1}{2}$ and $y:=2$ in (*), we have
$$\begin{align}f\left(\frac{1}{2}\right)&=0+f\left(\frac12\right)=f(1)+f\left(\frac{1}{2}\right)\\&=f\left(\frac{1}{2}\cdot 2\right)+f\left(\frac{1}{2}+2\right)\\&=f\left(\frac{1}{2}\right)\,f(2)+1\\&=f\left(\frac{1}{2}\right)\,\left(\frac{1+(-1)^2}{2}\right)+1=f\left(\frac12\right)+1\,,\end{align}$$
which is absurd.  Therefore, there are no solutions in this case.  Thus, unlike the old link, there are only two solutions (#) and (@).
