"And afterward she bore a daughter" (Genesis 30:21). Leah was fit to bear seven sons. She said: "Twelve tribes are destined to come forth from Jacob, and I have already borne six, and the two maidservants four — behold, ten. And if I still bear the seventh, it will turn out that my sister will not be even like one of the maidservants." She prayed for mercy that the fetus in her womb be turned into a daughter, and the Holy One, blessed be He, consented and did according to her words. Therefore it is written, "And afterward she bore a daughter" — that the son was turned into a daughter.
Leah Prays Her Unborn Son Become Dinah So Rachel Is Not Shamed
Midrash Aggadah, Genesis 30:21
ואחר ילדה בת. ראויה היתה לאה לילד ז' בנים, אמרה י"ב שבטים עתידין לצאת מיעקב וכבר ילדתי ששה ושתי השפחות ד' הרי עשרה, ואם עדיין אלד השביעי נמצא שלא תהא אחותי אפילו כאחת השפחות, ובקשה רחמים שיתהפך העובר שבמיעה לבת, והסכים הקב"ה ועשה כדבריה לכך כתיב ואחר ילדה בת, שנהפך הבן לבת: