On May 3, 1913, J. B. Robinson executed.and delivered to appellant a mortgage covering a lot in the town site of Burley. On Oct. 13, 1913, respondent filed in the office of the -recorder of Cassia county a claim of lien for material furnished in the construction of a building located upon the premises. Prior to April 1, 1914, respondent commenced an action against Robinson for the foreclosure of its lien. Appellant was not made a party defendant in that action. Appellant commenced this action for the foreclosure of its mortgage Sept. 7, 1914. Robinson and his wife defaulted. *499Respondent answered, and with its answer filed a cross-complaint, in which, it set out its claim of lien and asked for a foreclosure thereof against appellant. The trial court found that the lien of respondent was prior to that of the mortgagee, and decree was entered accordingly, from which plaintiff appealed. >
The record does not contain a demurrer to the cross-complaint. However, an objection that the complaint does not state facts sufficient to constitute a cause of action is never waived. (C. S., sec. 6693.) The court should not affirm a judgment where it is apparent that the facte stated in the complaint do not present a sufficient foundation to sustain it, even though the insufficiency of the complaint is not assigned as error. (Wyatt v. Henderson, 31 Or. 48, 48 Pac. 790; Hankamer v. County Commrs. Court (Tex. Civ.), 154 S. W. 623; Whitten v. Whitten (Tex. Civ.), 157 S. W. 277.)
C. S., sec. 7349, reads as follows: “No lien provided for in this chapter binds any building, mining claim, improvement or structure for a longer period than six months after the claim has been filed, unless proceedings be commenced in a proper court within that time to enforce such lien; or if credit be given, then six months after the expiration of such credit; but no lien shall continue in force under this chapter for a longer period than two years from the time the work is completed, or credit given, unless proceedings to enforce the same shall have been commenced.”
It appears from the record in this case that no credit was given to the owner of the building, and hence the six months’ period of limitation applies.
Section 7349 has not been construed by this court with relation to the right of a claimant of a mechanic’s lien to foreclose the same against a mortgagee unless his action is commenced against the mortgagee within six months after the claim has been filed. It has been construed, however, by the federal court in the cases of Utah Implement-Vehicle Co. v. Bowman, 209 Fed. 942; Continental etc. Bank v. Pacific Coast Pipe Co., 222 Fed. 781, 138 C. C. A. 329; D. W. Standrod & *500Co. v. Utah Implement-Vehicle Co., 223 Fed. 517, 139 C. C. A. 65.
In the case of Utah Implement-Vehicle Co. v. Bowman, supra, the question involved was stated as follows: ‘ ‘ The precise question therefore, is whether or not a lien claimant under the mechanic’s lien law of Idaho loses his priority of lien as against a junior mortgagee, by foreclosing his lien without bringing in and making a party to such foreclosure suit the mortgagee, the period provided by the statute in which the proceedings may be commenced for the enforcement of the lien, expiring during the pendency of the suit.”
It was held in these cases'that the section should be construed as though it provided that the lien should not continue unless proceedings were commenced in the proper court “against the person or persons against whose interest the lieno is asserted,” and hence, where a mortgagee of property was not made a party to the suit to enforce the mechanic’s lien, he was not bound by the judgment, nor was the lien, after the expiration of the statutory period, of any effect as against the mortgagee’s interest.
We are satisfied that the construction placed upon the statute by the federal courts is sound. We refer to the eases themselves for the reason upon which the construction of the statute is based. The following eases from other jurisdictions support the rule above stated: Davis v. Bartz, 65 Wash. 395, 118 Pac. 334; Smith v. Hurd, 50 Minn. 503, 36 Am. St. 661, 52 N. W. 922; Hokanson v. Gunderson, 54 Minn. 499, 40 Am. St. 354, 56 N. W. 172; Martin v. Berry, 159 Ind. 566, 64 N. E. 912; Stoermer v. People’s Sav. Bank, 152 Ind. 104, 52 N. E. 606; Union Nat. Sav. & Loan Assn. v. Halberg, 152 Ind. 139, 51 N. E. 916; Green v. Sanford, 34 Neb. 363, 51 N. W. 967; Falconer v. Cochran, 68 Minn. 405, 71 N. W. 386 ; Badger Lumber Co. v. Staley, 141 Mo. App. 595, 125 S. W. 779; Dunphy v. Riddle, 86 Ill. 22; McGraw v. Bayard, 96 Ill. 146; Ballard v. Thompson, 40 Neb. 529, 58 N. W. 1133; Bitter v. Mouat Lmbr. & Inv. Co., 10 Colo. App. 307, 51 Pac. 519.
In this case, the mortgage was duly recorded, so that no question of secret equities is involved. As against the mort*501gage lien, the lien for material furnished, if any existed, is lost because the action to foreclose the same was not commenced within the time limited by the statute.
The limitation prescribed by statute of the time within which an action must be brought in a proper court for the foreclosure of a mechanic’s lien is not the ordinary statute of limitation which is waived if not pleaded. “The time within which a suit must be brought operates as a limitation of the liability itself as created, and not of the remedy alone. It is a condition attached to the right to sue at all.” (The Harrisburg v. Rickards, 119 U. S. 199, 7 Sup. Ct. 140, 30 L. ed. 358. See, also, Continental etc. Bank v. Pacific Coast Pipe Co., supra.)
The judgment is reversed and the cause remanded, with instructions to the district court to enter a decree foreclosing appellant’s mortgage and adjudging it to be a prior lien to that of respondent for the material furnished. Costs awarded to appellant.
Morgan, C. J., and Budge, J., concur.