Page MenuHomePhabricator

[native] Add `avatar` column to clientDB `threads` table
ClosedPublic

Authored by atul on Mar 30 2023, 12:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 11, 11:40 PM
Unknown Object (File)
Wed, Apr 10, 5:01 AM
Unknown Object (File)
Tue, Apr 9, 1:03 AM
Unknown Object (File)
Mon, Apr 8, 4:45 AM
Unknown Object (File)
Wed, Apr 3, 5:52 PM
Unknown Object (File)
Thu, Mar 28, 1:05 AM
Unknown Object (File)
Thu, Mar 28, 1:05 AM
Unknown Object (File)
Thu, Mar 28, 1:05 AM
Subscribers

Details

Summary

We are adding an avatar column to the threads table in the clientDB and including an avatar field in the Thread struct. At the moment, the value of this field will always be NULL until we make some necessary changes. These changes involve modifying:

  1. The translation functions that convert between ClientDBThreadInfo and ThreadInfo.
  2. The C++ code responsible for constructing JSI ClientDBThreadInfo objects from the threads table rows retrieved from the database on the "JS side."

Once these changes have been made, we will be able to update the avatar field in the threads table and properly persist data in the new avatar column.

Test Plan
  1. Verify that the migration was successful:

Before:

dcc448.png (708×514 px, 77 KB)

After:

30fc81.png (762×1 px, 90 KB)

64daff.png (162×1 px, 45 KB)

  1. Ensure that freshly created clientDB includes avatar column in the threads table:

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

atul published this revision for review.Mar 30 2023, 12:31 PM
atul edited the summary of this revision. (Show Details)
ashoat added inline comments.
native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
382 ↗(On Diff #24443)

Please line it up with the others

This revision is now accepted and ready to land.Mar 30 2023, 4:46 PM
native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
382 ↗(On Diff #24443)

weird, it looked right in my editor

native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
382 ↗(On Diff #24443)

editor being Xcode

45bb10.png (382×1 px, 126 KB)

will update nonetheless

fix formatting (I guess it was a tab and space instead of two spaces? thought we stuck to spaces generally but made it consistent)

kamil requested changes to this revision.Mar 30 2023, 11:38 PM

Requesting changes to push it back to you, but if I am missing something re-request review and I will unblock this as soon as possible.

native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h
23 ↗(On Diff #24449)

I think this is unsafe and might crash or cause undefined behavior.

If I understand this correctly, and looking at the current pattern here you should use std::string and add a NOT NULL constraint to the table definition or in other cases use a pointer that is safer for assigning nullable values.

When sqlite_orm creates storage the docs say "not_null is deduced from type automatically", and the non-pointer value will be deduced as NOT NULL.

This revision now requires changes to proceed.Mar 30 2023, 11:38 PM
native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h
23 ↗(On Diff #24449)

Good catch!

native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h
23 ↗(On Diff #24449)

Thanks for pointing that out! Totally forgot about this subtlety so 1000x appreciate that you flagged this before I broke something.

Updating to:

std::unique_ptr<std::string> avatar;

Which seems like what we're doing with messages table:

32fb72.png (544×842 px, 129 KB)

std::unique_ptr<std::string> instead of std::string>

This revision is now accepted and ready to land.Apr 3 2023, 12:33 AM