Bug #108076 Contribution: If extra init_command options are given for the Django connec ...
Submitted: 4 Aug 2022 18:31 Modified: 28 Oct 2022 19:24
Reporter: OCA Admin (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / Python Severity:S3 (Non-critical)
Version:8.0.31 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

Contributions can be accepted to Open bugs only.

[4 Aug 2022 18:31] OCA Admin
Contribution submitted via Github - If extra init_command options are given for the Django connector, load them 
(*) Contribution by Sander van de Graaf (Github svdgraaf, mysql-connector-python/pull/80): 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.

Attachment: git_patch_1017518160.txt (text/plain), 3.69 KiB.