Skip to content

Conversation

svdgraaf
Copy link

@svdgraaf svdgraaf commented Aug 4, 2022

This adds support for the init_command option, which is used in other mysql connectors (and in the Django Database config setting).

In the _post_connection method, it now calls the _execute_query to run the given sql commands in init_command.

Adding this option inside the Django database config now works, previously this was ignored.

{
    "default": {
        "ENGINE": "mysql.connector.django",
        "NAME": DBCONFIG["database"],
        "USER": "user",
        "PASSWORD": "password",
        "HOST": DBCONFIG["host"],
        "PORT": DBCONFIG["port"],
        "OPTIONS": {
            "init_command": "SET foo='bar';"
        }
    }
}

I've added a test for the Django connector, but I had a hard time getting all tests for the other parts to work locally. Things "should be fine though (tm)", but that's probably not good enough :D Any pointers to where I should implement the unit tests are welcome.

Any comments or feedback in general is much appreciated.

I've filled out and signed the OCA.
I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

@mysql-oca-bot
Copy link

Hi, thank you for your contribution. Your code has been assigned to an internal queue. Please follow
bug http://bugs.mysql.com/bug.php?id=108076 for updates.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants