The buyer takes the property subject to the lease
California Civil Code section 821 gives a buyer who takes property subject to a lease the same rights to collect rent and enforce the lease. The sale alone does not end the rental agreement; any change in possession is a separate question under the lease and applicable rules.
Read California Civil Code section 821