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

[4 Aug 2022 18:31] OCA Admin
Description:
This bug tracks a contribution by Sander van de Graaf (Github user: svdgraaf) as described in http://github.com/mysql/mysql-connector-python/pull/80

How to repeat:
See description

Suggested fix:
See contribution code attached
[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.

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

[5 Aug 2022 5:22] MySQL Verification Team
Hello Sander van de Graaf,

Thank you for the contribution.

regards,
Umesh
[26 Oct 2022 13:51] Oscar Pacheco
Posted by developer:
 
Thanks, Sander van de Graaf for the contribution.
[28 Oct 2022 19:24] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Connection/Python 8.0.32 release, and here's the proposed changelog entry from the documentation team:
---
Added a new init_command connection option; an SQL query that's
immediately executed after the connection is established. 

Thanks to Sander van de Graaf for the contribution.
---

Thank you for the bug report.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.058 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.