-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Duplicating the same connection twice gives "Integrity error, probably unique constraint" #18050
Comments
Thanks for opening your first issue here! Be sure to follow the issue template! |
Is it possible that you make a PR fixing it? Seems like simple issue to fix? |
Airflow is build by the community - so anyone can make such fixes. |
@potiuk can I take this please. |
Please do! |
I think we have to query the connections anyway ;) so why not a short loop :) |
The problem with quering is it could be quite expensive to find the correct number if you have a ton of existing |
Copies will be created after a user action so I can't imagine ever having to query for e.g. 10000 connections to find N. In my opinion it's not very user-friendly to refuse To mitigate querying the DB for every copy we could implement e.g. a |
Pragmatic proposal (which I mentioned in the PR) is to have for loop with 1-10 and try them in sequence (and fail if we already have 10 copies). I can imagine someone making 2-3 copies, but really if someone tries to create 10th copy from the UI, it can fail. I am mostly thinking about a user trying to have several variants of the same connection one after another, which is rather likely (but unlikely to scale up) |
My opinion also sides with @BasPH , to query with a regex pattern to find all the connections which has _copy[0-9], but should we add a column to indicate that it was a duplicate, what are the chances that the user will also create a connection with the same syntax |
The problem with a partial match is that
|
Apache Airflow version
2.2.0
Operating System
Debian buster
Versions of Apache Airflow Providers
No response
Deployment
Astronomer
Deployment details
astro dev start
What happened
When I have tried to duplicate a connection first time it has created a connection with hello_copy1 and duplicating the same connection second time giving me an error of
Connection hello_copy2 can't be added. Integrity error, probably unique constraint.
What you expected to happen
It should create a connection with name hello_copy3 or the error message should be more user friendly.
How to reproduce
#15574 (comment)
Anything else
Suggested Error
or
Change the number logic in _copyN so the new name will be always unique.
Are you willing to submit PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: