PythonNest / PyNest

PyNest is a Python framework built on top of FastAPI that follows the modular architecture of NestJS
https://pythonnest.github.io/PyNest
MIT License
737 stars 50 forks source link

Error Authentication failed on mongodb #21

Closed ghost closed 10 months ago

ghost commented 10 months ago

Hi,

My mongodb database does not have user and password, and the ODM config generate:

config_url: 'mongodb://None:None@127.0.0.1:27017'.

Evidently it is passing user and password with a value of' None', and it gives me an authentication error.

How do I resolve this?

Sorry for my bas english, I am Spanish man.

Best regards,

ghost commented 10 months ago

Hi, I install pynest with pip install and the problem is that version in /nest/core/database/odm_config.py the funcion get_engine_url() not update, I show it:

def get_engine_url(self) -> str:
    """
    Returns the engine URL for the ORM.

    Returns:
        str: The engine URL.

    """
    return f"mongodb{'+srv' if self.srv else ''}://{self.user}:{self.password}@{self.host}:{self.port}"

And the updated is modified the return sentence:

   if self.user and self.password:
        return f"mongodb{'+srv' if self.srv else ''}://{self.user}:{self.password}@{self.host}:{self.port}"
    return f"mongodb{'+srv' if self.srv else ''}://{self.host}:{self.port}"

Well, I solved it by modifying the installed site-package code, but you should fix the pip installation.

Greetings.