Page MenuHomePhabricator

Refactor rekey media containers query not to use ORM
ClosedPublic

Authored by marcin on Jan 18 2024, 9:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 6, 5:17 PM
Unknown Object (File)
Tue, Oct 22, 11:28 PM
Unknown Object (File)
Tue, Oct 22, 8:52 PM
Unknown Object (File)
Mon, Oct 21, 9:11 PM
Unknown Object (File)
Mon, Oct 21, 7:02 PM
Unknown Object (File)
Oct 15 2024, 4:47 PM
Unknown Object (File)
Oct 15 2024, 4:44 PM
Unknown Object (File)
Oct 15 2024, 12:39 PM
Subscribers

Details

Summary

This differential refactors rekey media containers query not to use ORM.

Test Plan

Execute tests in https://phab.comm.dev/D10711. This query is covered there

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

Fix rekey all entities template

kamil added inline comments.
native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
1294 ↗(On Diff #35894)

I am wondering if this is safe - here it should work because container is not the primary key. But overall it could cause unique constraint violation

native/cpp/CommonCpp/DatabaseManagers/entities/EntityQueryHelpers.h
146 ↗(On Diff #35894)

shouldn't we also check result of this bind operation?

This revision is now accepted and ready to land.Jan 25 2024, 7:06 AM
native/cpp/CommonCpp/DatabaseManagers/entities/EntityQueryHelpers.h
146 ↗(On Diff #35894)

I don't think that checking for every bind operation is necessary. If the query is malformated then the second bind should also fail. Even if not then in worst case scenario query execution will fail.

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
1294 ↗(On Diff #35894)

According to SQLite docs there are a couple of options for unique constraint violation resolution: https://www.sqlite.org/lang_conflict.html. However we don't know which one we would like to use if we ever introduce unique constraint on container field so I would leave it as it is. If this query violates something in future we will be informed from error message and then decide on the best conflict resolution strategy.

  1. Add moveDraft and rekeyMessage refactor to this diff.
  2. Refactor functions above to use one sql query