The answer depends crucially on the denotation of the terms elementary function and function.
Other answers have already explained what happens when said rational functions are viewed as (set-theoretic) functions. Here I discuss a more formal algebraic viewpoint, which is useful to keep in mind even when approaching analytic problems (e.g. below).
In algebra (and differential algebra), to obtain maximal generality (universality) such polynomial and rational "functions" are interpreted formally. In this case polynomials are not functions but instead are formal expressions (elements of certain free algebras). In turn, rational "functions" are also formal (not functional) objects, namely elements of the fraction field of formal polynomials. Thus, in $\rm\:\mathbb Q(x)\:,\:$ the fraction field of the polynomial ring $\rm\:\mathbb Q[x]\:,\:$ it is true that $\rm\ x\ =\ (x^2-x)/(x-1)\ $ since one can always cancel nonzero elements from fractions. More explicitly, if $\rm\ x,\:f\in F\: $ a field (or domain) then $\rm\: x\ne 1\ $ and $\rm\ (x-1)\ f\ =\ x^2-x\ \ \Rightarrow\ \ f\: =\: x\ $ by cancelling $\rm\ x-1\ne 0\:.\:$
It's remarkable that such formal algebra frequently enables slick proofs of results that would be cumbersome analytically. In particular, "generic" or "universal" proofs can yield quite nontrivial results, e.g. one can "generically" algebraically cancel "apparent singularities" in one fell swoop, before evaluation - thus avoiding alternative topological arguments (e.g. by density). For example, see this slick proof of Sylvester's determinant identity $\rm\ det\ (I+AB)=det\ (I+BA)\ $ that proceeds by universally cancelling $\rm\ det\ A\ $ from the $\rm\ det\ $ of $\rm\ \ (1+A\ B)\ A\ =\ A\ (1+B\ A)\:,\:$ thus trivially eliminating the "apparent singularity" at $\rm\ det\ A\: =\: 0\:.\:$ For further discussion see here.
NOTE $\ $ It is worth emphasizing that this equality, like many equalities, is a simple consequence of a uniqueness theorem, thus yielding yet another example of the power of uniqueness theorems for proving equalities. For the ring-theoretic property of being a domain is equivalent to the uniqueness of solutions to linear equations $\rm\ a\ x = b,\ a\ne 0\:.\: $ Your equality is a consequence of this simple uniqueness theorem, viz. both $\rm\:x\:$ and $\rm\:(x^2-1)/(x-1)\:$ are solutions $\rm\:f\:$ of $\rm\ (x-1)\ f\ =\ x^2-x\:,\:$ and $\rm\: x\ne 1\:,\:$ hence they are equal by uniqueness. Normally one deduces this using an equivalent property, namely that a ring is a domain iff all nonzero elements are cancellable. Thus in a domain one may deduce such equalities by cancelling nonzero factors from both sides of an equation. But it is essential to stress the uniqueness viewpoint since this applies in much more general contexts which may not enjoy an equivalent reformulation via cancellation, e.g. see above linked posts.
While such remarks may seem rather trivial if interpreted only in a specific ring, e.g. the ring of real rational functions (formal or functional), they are quite nontrivial when interpreted more generally, as illustrated quite forcefully in the above example employing formal vs. functional matrices and determinants - by working over a ring where the matrix entries are indeterminates. The abstraction from polynomial functions to formal polynomials, while it may seem rather impotent at first glance, yields great power when exploited to the hilt by universal reasoning. Alas, such universal viewpoints don't always receive the emphasis that they rightfully deserve in first algebra courses (if they did, my trivial remark here would not be one of my highest-voted posts!)