Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Connection: Added logic to query if a connection id exists before creating one #18161

Merged
merged 26 commits into from
Oct 9, 2021
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
adacc83
Added logic to query if a connection id exists before creating one in…
subkanthi Sep 11, 2021
4be3293
Merge branch 'master' of github.com:subkanthi/airflow into fix_duplic…
subkanthi Sep 15, 2021
183f373
Merge branch 'master' of github.com:subkanthi/airflow into fix_duplic…
subkanthi Sep 15, 2021
5ff48f8
Merge branch 'master' of github.com:subkanthi/airflow into fix_duplic…
subkanthi Sep 16, 2021
fdfe0f7
Merge branch 'master' of github.com:subkanthi/airflow into fix_duplic…
subkanthi Sep 17, 2021
aeab641
Added logic to create query for checking duplicate connections
subkanthi Sep 18, 2021
9cee8b3
Merge branch 'master' of github.com:subkanthi/airflow into fix_duplic…
subkanthi Sep 18, 2021
af5b389
Merge branch 'fix_duplicate_connections' of github.com:subkanthi/airf…
subkanthi Sep 18, 2021
f420d4c
Merge branch 'fix_duplicate_connections' of github.com:subkanthi/airf…
subkanthi Sep 18, 2021
09d1ec3
Added logic to query existing connections copy(1 to 10)
subkanthi Sep 23, 2021
d087cea
Added logic to query for copy connections from 1 to 10 and use the lo…
subkanthi Sep 23, 2021
a8e86fe
Merge branch 'fix_duplicate_connections' of github.com:subkanthi/airf…
subkanthi Sep 23, 2021
fc20af1
Rolled back changes to tests
subkanthi Sep 23, 2021
d906fb9
Rolled back changes to tests
subkanthi Sep 23, 2021
9bf4edb
Merge branch 'master' of github.com:subkanthi/airflow into fix_duplic…
subkanthi Sep 24, 2021
3d33569
Refactored duplicate logic based on PR review comments
subkanthi Oct 2, 2021
7520cef
Fixed indentation errors
subkanthi Oct 3, 2021
0027e10
Fixed indentation errors
subkanthi Oct 3, 2021
9b91ac6
Fixed indentation errors
subkanthi Oct 3, 2021
c3e3e03
Fixed flake8 errors
subkanthi Oct 4, 2021
f1f727b
Added test case to cover the logic when 10 copies already exists, no …
subkanthi Oct 8, 2021
bca28ef
Update tests/www/views/test_views_connection.py
subkanthi Oct 8, 2021
8257854
Update tests/www/views/test_views_connection.py
subkanthi Oct 8, 2021
0f93f8e
Addressed PR review comments
subkanthi Oct 8, 2021
fd0470c
Merge branch 'fix_duplicate_connections' of github.com:subkanthi/airf…
subkanthi Oct 8, 2021
95630d6
Fixed test and removed unused code in views.py
subkanthi Oct 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions airflow/www/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3320,28 +3320,38 @@ def action_mulduplicate(self, connections, session=None):
else:
new_conn_id += '_copy1'

dup_conn = Connection(
new_conn_id,
selected_conn.conn_type,
selected_conn.description,
selected_conn.host,
selected_conn.login,
selected_conn.password,
selected_conn.schema,
selected_conn.port,
selected_conn.extra,
)

try:
session.add(dup_conn)
session.commit()
flash(f"Connection {new_conn_id} added successfully.", "success")
except IntegrityError:
# Before creating a new connection
# Query to see if connection exists.
connection = session.query(Connection).filter(Connection.conn_id == new_conn_id).one_or_none()
if connection is not None:
flash(
f"Connection {new_conn_id} can't be added. Integrity error, probably unique constraint.",
f"Connection {new_conn_id} can't be added because it lready exists",
potiuk marked this conversation as resolved.
Show resolved Hide resolved
"warning",
)
session.rollback()
else:

dup_conn = Connection(
new_conn_id,
selected_conn.conn_type,
selected_conn.description,
selected_conn.host,
selected_conn.login,
selected_conn.password,
selected_conn.schema,
selected_conn.port,
selected_conn.extra,
)

try:
session.add(dup_conn)
session.commit()
flash(f"Connection {new_conn_id} added successfully.", "success")
except IntegrityError:
flash(
f"Connection {new_conn_id} can't be added. Integrity error, probably unique constraint.",
"warning",
)
session.rollback()

self.update_redirect()
return redirect(self.get_redirect())
Expand Down