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 2021/01/20 00:50:15 UTC

[GitHub] [airflow] kaxil opened a new pull request #13783: Fix SQL syntax to check duplicate connections

kaxil opened a new pull request #13783:
URL: https://github.com/apache/airflow/pull/13783


   closes https://github.com/apache/airflow/issues/13679
   
   Tested it:
   
   ```
   self = <tests.utils.test_db.TestDb testMethod=test_check_conn_id_duplicates>
   
       def test_check_conn_id_duplicates(self):
           with create_session() as session:
               session.add(Connection('test10', conn_type='test_conn'))
               session.add(Connection('test10', conn_type='test_conn2'))
   
               session.flush()
               dups = check_conn_id_duplicates(session)
   >           assert dups == []
   E           AssertionError: assert ('Seems you have non unique conn_id in connection table.\n'\n 'You have to manage those duplicate connections before upgrading the '\n 'database.\n'\n "Duplicated conn_id: ['test10', 'test3']") == []
   E             +"Seems you have non unique conn_id in connection table.\nYou have to manage those duplicate connections before upgrading the database.\nDuplicated conn_id: ['test10', 'test3']"
   E             -[]
   
   ```
   
   Test I used after dropping constraint:
   
   ```python
       def test_check_conn_id_duplicates(self):
           with create_session() as session:
               session.add(Connection('test10', conn_type='test_conn'))
               session.add(Connection('test10', conn_type='test_conn2'))
   
               session.flush()
               dups = check_conn_id_duplicates(session)
               assert dups == []
   
               session.rollback()
   
   ```
   
   Query Run:
   
   ```sql
   SELECT connection.conn_id AS connection_conn_id  FROM connection GROUP BY connection.conn_id  HAVING count(*) > %(count_1)s
   ```
   
   cc @msardana94 
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [airflow] XD-DENG merged pull request #13783: Fix SQL syntax to check duplicate connections

Posted by GitBox <gi...@apache.org>.
XD-DENG merged pull request #13783:
URL: https://github.com/apache/airflow/pull/13783


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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