You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/01/02 16:56:05 UTC

[GitHub] griff122 opened a new pull request #4423: [AIRFLOW-3618] - Fix models.connection.Connection get_hook function

griff122 opened a new pull request #4423: [AIRFLOW-3618] - Fix models.connection.Connection get_hook function
URL: https://github.com/apache/incubator-airflow/pull/4423
 
 
   Make sure you have checked _all_ steps below.
   
   ### Jira
   
   - [x] https://issues.apache.org/jira/browse/AIRFLOW-3618
   
   ### Description
   
   - [x] The airflow.models.connection.Connection class function get_hook did not work as expected. The `conn_type` was not guaranteed to be lower case, and the get_hook function expected all lowercase type names. By updating the code so that the conditionals used `self.conn_type.lower()` instead of just `self.conn_type`, we can now make sure that the conditionals match the expected. 
   
   For example:
   ```
   >>> import airflow
   >>> from airflow.hooks.base_hook import BaseHook
   >>> airflow.__version__
   '1.10.1'
   >>> conn = BaseHook.get_connection('test_local_mysql')
   [2019-01-02 11:36:15,530] {base_hook.py:83} INFO - Using connection to: localhost
   >>> conn.conn_type
   'MySQL'
   >>> type(conn.get_hook())
   <class 'NoneType'>
   >>> conn.conn_type = conn.conn_type.lower()
   >>> conn.conn_type
   'mysql'
   >>> type(conn.get_hook())
   <class 'airflow.hooks.mysql_hook.MySqlHook'>
   ```
   
   ### Tests
   
   - [x] Does not need tests as it is updating existing functionality which should already have test associated.
   
   ### Commits
   
   - [x] My commits all reference Jira issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Documentation
   
   - [x] No new documentation is needed as the change is a bug fix which does not change the expected functionality of the function `Connection.get_hook`.
   
   ### Code Quality
   
   - [x] Passes `flake8`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services