-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Upgrade SQLAlchemy to 2.0 #8452
Conversation
ec25651
to
8e67bea
Compare
@@ -9,12 +9,12 @@ class Timestamps: | |||
created = sa.Column( | |||
sa.DateTime, | |||
default=datetime.datetime.utcnow, | |||
server_default=sa.func.now(), |
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.
Annoying pylint disables all around for these.
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.
@@ -33,7 +33,7 @@ def group_search( | |||
""" | |||
|
|||
query = ( | |||
sa.select([Group.authority_provided_id]) | |||
sa.select(Group.authority_provided_id) |
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.
Use the args, not list style of call
"annotation_id", Annotation.id, "force", bool(force) | ||
), | ||
] | ||
literal_column(f"'{name}'"), |
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.
No list here either
UserIdentity( | ||
user=user, | ||
provider=i_args["provider"], | ||
provider_unique_id=str(i_args["provider_unique_id"]), |
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.
Added a bit more context on the commit message for this but we need this type cast for SQLA to produce the right SQL.
transaction.nested and not transaction._parent.nested | ||
): | ||
session.begin_nested() | ||
session = db_sessionfactory( |
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.
The 2.0 version is much simpler.
@@ -293,6 +293,7 @@ def test_if_the_annotation_isnt_in_the_DB_it_deletes_the_job_from_the_queue( | |||
job = factories.SyncAnnotationJob(annotation=annotation) | |||
queue_service.get.return_value = [job] | |||
db_session.delete(annotation) | |||
db_session.commit() |
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.
Need to commit for the object to be actually deleted and the test to see it gone.
def mock_transaction(db_session): | ||
transaction = mock.Mock(spec=db_session.transaction) | ||
def mock_transaction(): | ||
transaction = mock.Mock(spec=SessionTransaction) |
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.
Use the class for the spec info. It's no longer accessible via the session.
52a5ccc
to
d6da25e
Compare
d6da25e
to
5e2821e
Compare
Oh, we should delete this now: Lines 5 to 35 in 534cca8
|
…are passed positionally
Not sure if this is a bug in SQLA but while inserting more than one element in a relationship the generated statement seems to add typecasts based on the values, not the column definition. Casting provider_unique_id to a string here to fix the issue.
Without the explicit commit create_all fails because the UUID extension is not present.
5e2821e
to
40430f5
Compare
Suspect IssuesThis pull request was deployed and Sentry observed the following issues:
Did you find this useful? React with a 👍 or 👎 |
For #7973