-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Sqlalchemy 2.0 #6671
Sqlalchemy 2.0 #6671
Conversation
fcb824b
to
3b9234b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndrewChubatiuk Thanks for the PR.
However, there are many changes and it appears that the SQL Alchemy version update includes unrelated refactorings...
We would like to accurately manage what modifications have been made with SQL Alchemy version upgrades, so could you please separate the PR? I apologize for asking you to do something troublesome, but it would be a great help if you could do that. thank you.
@guidopetri @konnectr If it is okay to merge this from your perspective, please let me know. If so, I will consider this again. |
@masayuki038 besides:
other changes were required:
sqlalchemy dependencies introduce lots of changes, which do not allow to prepare tiny diffs. god bless flask and all its dependencies was not required to be upgraded together with sqlalchemy deps |
@masayuki038 could you please trigger ci from the latest commit, I've fixed lint there |
It looks ci is running now... |
build for a latest commit was not triggered |
For some reason, CI stopped working, so I will cancel the review.
@AndrewChubatiuk I manually re-run Github Action, but I may not have been able to fetch the latest code. I tried deleting my review, but the status did not change. Could you try pushing something? Or could you please close this and create another PR? |
1c04150
to
d3391c3
Compare
@masayuki038 please approve this pipeline |
d3391c3
to
bfd23f6
Compare
@masayuki038 some changes were lost during rebase. pushed once again |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6671 +/- ##
==========================================
+ Coverage 63.80% 63.90% +0.09%
==========================================
Files 161 162 +1
Lines 13087 13175 +88
Branches 1812 1824 +12
==========================================
+ Hits 8350 8419 +69
- Misses 4434 4446 +12
- Partials 303 310 +7
|
I understand correctly that we are still abandoning simplejson ? |
I will try to test the operation in manual mode in the near future. It is unlikely that our auto-tests cover all possible problems |
@konnectr Thanks! I will start to review this next week as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndrewChubatiuk
Sorry for the delay. I have finished reviewing this for now. Please check the comments.
Regarding the following points, I am not pointing out every line. If you will fix it, fix it all.
- Please do not include updates that are not directly related to upgrading to SQLAlchemy 1.4 in this PR
- However, I agree with your updates almost. Please separate to another PR
- In some places,
count()
has been changed tolen(...)
. Please usecount()
thank you.
migrations/versions/98af61feea92_add_encrypted_options_to_data_sources.py
Outdated
Show resolved
Hide resolved
e6bd1a6
to
d46a475
Compare
6d6cdcf
to
dfa3da8
Compare
dfa3da8
to
8d118f2
Compare
66056ec
to
f30a674
Compare
@masayuki038 already checked them. answered or made code changes |
e897b4d
to
8398d6e
Compare
@@ -224,12 +222,10 @@ def run(self): | |||
utcnow(), | |||
) | |||
|
|||
updated_query_ids = models.Query.update_latest_result(query_result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed this update... Could you let me know why you removed this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueryResult and Query have relationship, there's no need to run multiple queries to store both separately (especially, when Query object already exists), doing everything in store_result
function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like that Query is updated in update_latest_result
.
redash/redash/models/__init__.py
Line 741 in b7f22b1
db.session.add(q) |
Can we skip this update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update_latest_result method was removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query was updated in the method(as below).
redash/redash/models/__init__.py
Lines 737 to 741 in bd17662
for q in queries: | |
q.latest_query_data = query_result | |
# don't auto-update the updated_at timestamp | |
q.skip_updated_at = True | |
db.session.add(q) |
Is there an alternative to this? Or have you decided that this process is not necessary? If you decide that it is unnecessary, please let us know the reason.
It seems to me that without this update, Redash's behavior will be affected. Isn't Query.lastest_query_data and some attributes no longer updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not see contradiction, from what you've posted.
Referenced by:
TABLE "queries" CONSTRAINT "queries_latest_query_data_id_fkey" FOREIGN KEY (latest_query_data_id) REFERENCES query_results(id)
so 1 QueryResult to many Queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Query has latest_query_data_id attribute, which references private key in QueryResult table, which means, that multiple Query object can set the same latest_query_data_id, which means that 1 QueryResult will be referred by multiple Queries - 1 QueryResults many queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hey @masayuki038
sorry for time you've spend in a review process, but closing this PR as not going to work on redash any further
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which means, that multiple Query object can set the same latest_query_data_id,
This is the case if different Queries have the same query_hash
. However, it is caused by hash value collisions, right? I don't think we should discuss it in this context.
1 Query - many QueryResults
Yes. Therefore, I think we should name query
instead of queries
in QueryResult. That is my point.
d743625
to
963fa82
Compare
5f3f973
to
80dab5a
Compare
@AndrewChubatiuk Could you stop to update the things other than "Sqlalchemy 2.0"? |
@masayuki038 i update only things, which are impacted by pr comments changes |
@AndrewChubatiuk OK. But, I don't think we need to update "assert_called_once_with("requests.redash_ping.get", ANY)" to "assert_called" like the above thread by upgrading to SQLAlchemy 2.0... Why did you update it yesterday? |
replied in a thread |
f547a75
to
e3cb28c
Compare
e3cb28c
to
05bbe48
Compare
What type of PR is this?
Upgraded SQLAlchemy 1.3 -> 2.0
How is this tested?