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
F1828981: D10708.diff
Thu, May 23, 6:20 AM
Unknown Object (File)
Tue, May 21, 11:32 AM
Unknown Object (File)
Tue, May 21, 11:32 AM
Unknown Object (File)
Tue, May 21, 11:32 AM
Unknown Object (File)
Mar 15 2024, 9:47 AM
Unknown Object (File)
Mar 7 2024, 11:52 AM
Unknown Object (File)
Mar 7 2024, 3:43 AM
Unknown Object (File)
Feb 15 2024, 11:25 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
Lint Not Applicable
Unit
Tests Not Applicable

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