Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(personhog): field masking (#60284)

Nick Best2f16be4f52ff
diff --git a/nodejs/src/generated/personhog/personhog/types/v1/common_pb.ts b/nodejs/src/generated/personhog/personhog/types/v1/common_pb.ts
index d41cc8935e0f..d9f7212b68f6 100644
--- a/nodejs/src/generated/personhog/personhog/types/v1/common_pb.ts
+++ b/nodejs/src/generated/personhog/personhog/types/v1/common_pb.ts
@@ -10,7 +10,7 @@ import { enumDesc, fileDesc, messageDesc } from '@bufbuild/protobuf/codegenv2'
export const file_personhog_types_v1_common: GenFile =
/*@__PURE__*/
fileDesc(
- 'Ch9wZXJzb25ob2cvdHlwZXMvdjEvY29tbW9uLnByb3RvEhJwZXJzb25ob2cudHlwZXMudjEiSAoLUmVhZE9wdGlvbnMSOQoLY29uc2lzdGVuY3kYASABKA4yJC5wZXJzb25ob2cudHlwZXMudjEuQ29uc2lzdGVuY3lMZXZlbCI2Cg5UZWFtRGlzdGluY3RJZBIPCgd0ZWFtX2lkGAEgASgDEhMKC2Rpc3RpbmN0X2lkGAIgASgJIkgKCEdyb3VwS2V5Eg8KB3RlYW1faWQYASABKAMSGAoQZ3JvdXBfdHlwZV9pbmRleBgCIAEoBRIRCglncm91cF9rZXkYAyABKAkiPgoPR3JvdXBJZGVudGlmaWVyEhgKEGdyb3VwX3R5cGVfaW5kZXgYASABKAUSEQoJZ3JvdXBfa2V5GAIgASgJKnMKEENvbnNpc3RlbmN5TGV2ZWwSIQodQ09OU0lTVEVOQ1lfTEVWRUxfVU5TUEVDSUZJRUQQABIeChpDT05TSVNURU5DWV9MRVZFTF9FVkVOVFVBTBABEhwKGENPTlNJU1RFTkNZX0xFVkVMX1NUUk9ORxACYgZwcm90bzM'
+ 'Ch9wZXJzb25ob2cvdHlwZXMvdjEvY29tbW9uLnByb3RvEhJwZXJzb25ob2cudHlwZXMudjEiXAoLUmVhZE9wdGlvbnMSOQoLY29uc2lzdGVuY3kYASABKA4yJC5wZXJzb25ob2cudHlwZXMudjEuQ29uc2lzdGVuY3lMZXZlbBISCgpmaWVsZF9tYXNrGAIgAygJIjYKDlRlYW1EaXN0aW5jdElkEg8KB3RlYW1faWQYASABKAMSEwoLZGlzdGluY3RfaWQYAiABKAkiSAoIR3JvdXBLZXkSDwoHdGVhbV9pZBgBIAEoAxIYChBncm91cF90eXBlX2luZGV4GAIgASgFEhEKCWdyb3VwX2tleRgDIAEoCSI+Cg9Hcm91cElkZW50aWZpZXISGAoQZ3JvdXBfdHlwZV9pbmRleBgBIAEoBRIRCglncm91cF9rZXkYAiABKAkqcwoQQ29uc2lzdGVuY3lMZXZlbBIhCh1DT05TSVNURU5DWV9MRVZFTF9VTlNQRUNJRklFRBAAEh4KGkNPTlNJU1RFTkNZX0xFVkVMX0VWRU5UVUFMEAESHAoYQ09OU0lTVEVOQ1lfTEVWRUxfU1RST05HEAJiBnByb3RvMw'
)
/**
@@ -23,6 +23,18 @@ export type ReadOptions = Message<'personhog.types.v1.ReadOptions'> & {
* @generated from field: personhog.types.v1.ConsistencyLevel consistency = 1;
*/
consistency: ConsistencyLevel
+
+ /**
+ * Top-level proto field names to include in response entities (Person, Group).
+ * Empty means all fields are returned (backward-compatible default).
+ * Unknown field names are silently ignored.
+ * When the properties-related fields ("properties"/"group_properties",
+ * "properties_last_updated_at", "properties_last_operation") are all excluded,
+ * the server skips reading them from the database entirely.
+ *
+ * @generated from field: repeated string field_mask = 2;
+ */
+ fieldMask: string[]
}
/**
diff --git a/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.py b/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.py
index 4fb0cc311786..09f650c34a07 100644
--- a/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.py
+++ b/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.py
@@ -13,20 +13,20 @@ _runtime_version.ValidateProtobufRuntimeVersion(
)
_sym_db = _symbol_database.Default()
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(
- b'\n\x1fpersonhog/types/v1/common.proto\x12\x12personhog.types.v1"H\n\x0bReadOptions\x129\n\x0bconsistency\x18\x01 \x01(\x0e2$.personhog.types.v1.ConsistencyLevel"6\n\x0eTeamDistinctId\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x13\n\x0bdistinct_id\x18\x02 \x01(\t"H\n\x08GroupKey\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x18\n\x10group_type_index\x18\x02 \x01(\x05\x12\x11\n\tgroup_key\x18\x03 \x01(\t">\n\x0fGroupIdentifier\x12\x18\n\x10group_type_index\x18\x01 \x01(\x05\x12\x11\n\tgroup_key\x18\x02 \x01(\t*s\n\x10ConsistencyLevel\x12!\n\x1dCONSISTENCY_LEVEL_UNSPECIFIED\x10\x00\x12\x1e\n\x1aCONSISTENCY_LEVEL_EVENTUAL\x10\x01\x12\x1c\n\x18CONSISTENCY_LEVEL_STRONG\x10\x02b\x06proto3'
+ b'\n\x1fpersonhog/types/v1/common.proto\x12\x12personhog.types.v1"\\\n\x0bReadOptions\x129\n\x0bconsistency\x18\x01 \x01(\x0e2$.personhog.types.v1.ConsistencyLevel\x12\x12\n\nfield_mask\x18\x02 \x03(\t"6\n\x0eTeamDistinctId\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x13\n\x0bdistinct_id\x18\x02 \x01(\t"H\n\x08GroupKey\x12\x0f\n\x07team_id\x18\x01 \x01(\x03\x12\x18\n\x10group_type_index\x18\x02 \x01(\x05\x12\x11\n\tgroup_key\x18\x03 \x01(\t">\n\x0fGroupIdentifier\x12\x18\n\x10group_type_index\x18\x01 \x01(\x05\x12\x11\n\tgroup_key\x18\x02 \x01(\t*s\n\x10ConsistencyLevel\x12!\n\x1dCONSISTENCY_LEVEL_UNSPECIFIED\x10\x00\x12\x1e\n\x1aCONSISTENCY_LEVEL_EVENTUAL\x10\x01\x12\x1c\n\x18CONSISTENCY_LEVEL_STRONG\x10\x02b\x06proto3'
)
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "personhog.types.v1.common_pb2", _globals)
if not _descriptor._USE_C_DESCRIPTORS:
DESCRIPTOR._loaded_options = None
- _globals["_CONSISTENCYLEVEL"]._serialized_start = 323
- _globals["_CONSISTENCYLEVEL"]._serialized_end = 438
+ _globals["_CONSISTENCYLEVEL"]._serialized_start = 343
+ _globals["_CONSISTENCYLEVEL"]._serialized_end = 458
_globals["_READOPTIONS"]._serialized_start = 55
- _globals["_READOPTIONS"]._serialized_end = 127
- _globals["_TEAMDISTINCTID"]._serialized_start = 129
- _globals["_TEAMDISTINCTID"]._serialized_end = 183
- _globals["_GROUPKEY"]._serialized_start = 185
- _globals["_GROUPKEY"]._serialized_end = 257
- _globals["_GROUPIDENTIFIER"]._serialized_start = 259
- _globals["_GROUPIDENTIFIER"]._serialized_end = 321
+ _globals["_READOPTIONS"]._serialized_end = 147
+ _globals["_TEAMDISTINCTID"]._serialized_start = 149
+ _globals["_TEAMDISTINCTID"]._serialized_end = 203
+ _globals["_GROUPKEY"]._serialized_start = 205
+ _globals["_GROUPKEY"]._serialized_end = 277
+ _globals["_GROUPIDENTIFIER"]._serialized_start = 279
+ _globals["_GROUPIDENTIFIER"]._serialized_end = 341
diff --git a/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.pyi b/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.pyi
index a4634d5712bf..30dda91c6770 100644
--- a/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.pyi
+++ b/posthog/personhog_client/proto/generated/personhog/types/v1/common_pb2.pyi
@@ -1,3 +1,4 @@
+from collections.abc import Iterable as _Iterable
from typing import (
ClassVar as _ClassVar,
Optional as _Optional,
@@ -8,7 +9,10 @@ from google.protobuf import (
descriptor as _descriptor,
message as _message,
)
-from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
+from google.protobuf.internal import (
+ containers as _containers,
+ enum_type_wrapper as _enum_type_wrapper,
+)
DESCRIPTOR: _descriptor.FileDescriptor
@@ -23,11 +27,15 @@ CONSISTENCY_LEVEL_EVENTUAL: ConsistencyLevel
CONSISTENCY_LEVEL_STRONG: ConsistencyLevel
class ReadOptions(_message.Message):
- __slots__ = ("consistency",)
+ __slots__ = ("consistency", "field_mask")
CONSISTENCY_FIELD_NUMBER: _ClassVar[int]
+ FIELD_MASK_FIELD_NUMBER: _ClassVar[int]
consistency: ConsistencyLevel
+ field_mask: _containers.RepeatedScalarFieldContainer[str]
- def __init__(self, consistency: _Optional[_Union[ConsistencyLevel, str]] = ...) -> None: ...
+ def __init__(
+ self, consistency: _Optional[_Union[ConsistencyLevel, str]] = ..., field_mask: _Optional[_Iterable[str]] = ...
+ ) -> None: ...
class TeamDistinctId(_message.Message):
__slots__ = ("team_id", "distinct_id")
diff --git a/proto/personhog/types/v1/common.proto b/proto/personhog/types/v1/common.proto
index a5758d0710b4..d4532ea0cd8d 100644
--- a/proto/personhog/types/v1/common.proto
+++ b/proto/personhog/types/v1/common.proto
@@ -13,6 +13,22 @@ enum ConsistencyLevel {
// ReadOptions configures read operation behavior.
message ReadOptions {
ConsistencyLevel consistency = 1;
+ // Top-level proto field names to include in response entities (Person, Group).
+ // Empty means all fields are returned (backward-compatible default).
+ // Unknown field names are silently ignored.
+ //
+ // Honored by batch/list RPCs only: GetPersons, GetPersonsByUuids,
+ // GetPersonsByDistinctIdsInTeam, GetPersonsByDistinctIds, GetGroups,
+ // GetGroupsBatch, ListGroups.
+ // Single-entity RPCs (GetPerson, GetPersonByUuid, GetPersonByDistinctId,
+ // GetGroup) always return all fields regardless of this mask.
+ //
+ // When the properties-related fields ("properties"/"group_properties",
+ // "properties_last_updated_at", "properties_last_operation") are all excluded,
+ // the server skips fetching them in SELECT clauses. Note: ListGroups with a
+ // non-empty `search` still reads group_properties in the WHERE filter even
+ // when these fields are excluded from the mask.
+ repeated string field_mask = 2;
}
// TeamDistinctId is a cross-team lookup key for person resolution
diff --git a/rust/personhog-replica/.sqlx/query-73a0e91e0d6f971bf07ad975a662e903a898f8d4b6807304b2f57c93b9b045a6.json b/rust/personhog-replica/.sqlx/query-06a8856bb5b29df0a84818ce2dbf7a7866ef734ba8765c5b842e8120a680c5ca.json
similarity index 92%
rename from rust/personhog-replica/.sqlx/query-73a0e91e0d6f971bf07ad975a662e903a898f8d4b6807304b2f57c93b9b045a6.json
rename to rust/personhog-replica/.sqlx/query-06a8856bb5b29df0a84818ce2dbf7a7866ef734ba8765c5b842e8120a680c5ca.json
index 9cf0cd25f7f1..7ff98d656df8 100644
--- a/rust/personhog-replica/.sqlx/query-73a0e91e0d6f971bf07ad975a662e903a898f8d4b6807304b2f57c93b9b045a6.json
+++ b/rust/personhog-replica/.sqlx/query-06a8856bb5b29df0a84818ce2dbf7a7866ef734ba8765c5b842e8120a680c5ca.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n UPDATE posthog_group\n SET group_properties = CASE WHEN $4 THEN $5 ELSE group_properties END,\n properties_last_updated_at = CASE WHEN $6 THEN $7 ELSE properties_last_updated_at END,\n properties_last_operation = CASE WHEN $8 THEN $9 ELSE properties_last_operation END,\n created_at = CASE WHEN $10 THEN $11 ELSE created_at END,\n version = version + 1\n WHERE team_id = $1 AND group_type_index = $2 AND group_key = $3\n RETURNING id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key, group_properties::text as \"group_properties!\",\n created_at,\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n version\n ",
+ "query": "\n UPDATE posthog_group\n SET group_properties = CASE WHEN $4 THEN $5 ELSE group_properties END,\n properties_last_updated_at = CASE WHEN $6 THEN $7 ELSE properties_last_updated_at END,\n properties_last_operation = CASE WHEN $8 THEN $9 ELSE properties_last_operation END,\n created_at = CASE WHEN $10 THEN $11 ELSE created_at END,\n version = version + 1\n WHERE team_id = $1 AND group_type_index = $2 AND group_key = $3\n RETURNING id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key, group_properties::text as \"group_properties?\",\n created_at,\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n version\n ",
"describe": {
"columns": [
{
@@ -25,7 +25,7 @@
},
{
"ordinal": 4,
- "name": "group_properties!",
+ "name": "group_properties?",
"type_info": "Text"
},
{
@@ -76,5 +76,5 @@
false
]
},
- "hash": "73a0e91e0d6f971bf07ad975a662e903a898f8d4b6807304b2f57c93b9b045a6"
+ "hash": "06a8856bb5b29df0a84818ce2dbf7a7866ef734ba8765c5b842e8120a680c5ca"
}
diff --git a/rust/personhog-replica/.sqlx/query-495a965269a34f368ae76ceb61e956fa0dfa6b9bfa3d909497ddd6f02f6b6438.json b/rust/personhog-replica/.sqlx/query-0878f57fcfedbfb95e16f5eb0fd90ed15cbb0850dc727c39073e346d9736358c.json
similarity index 58%
rename from rust/personhog-replica/.sqlx/query-495a965269a34f368ae76ceb61e956fa0dfa6b9bfa3d909497ddd6f02f6b6438.json
rename to rust/personhog-replica/.sqlx/query-0878f57fcfedbfb95e16f5eb0fd90ed15cbb0850dc727c39073e346d9736358c.json
index fb40405051da..e79ef21e6419 100644
--- a/rust/personhog-replica/.sqlx/query-495a965269a34f368ae76ceb61e956fa0dfa6b9bfa3d909497ddd6f02f6b6438.json
+++ b/rust/personhog-replica/.sqlx/query-0878f57fcfedbfb95e16f5eb0fd90ed15cbb0850dc727c39073e346d9736358c.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT p.id, p.uuid as \"uuid!\", p.team_id::bigint as \"team_id!\",\n p.properties::text as \"properties!\",\n p.properties_last_updated_at::text as \"properties_last_updated_at?\",\n p.properties_last_operation::text as \"properties_last_operation?\",\n p.created_at as \"created_at!\", p.version, p.is_identified as \"is_identified!\",\n CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,\n p.last_seen_at,\n d.distinct_id as \"distinct_id!\"\n FROM posthog_person p\n INNER JOIN posthog_persondistinctid d ON p.id = d.person_id AND p.team_id = d.team_id\n WHERE p.team_id = $1 AND d.distinct_id = ANY($2)\n ",
+ "query": "\n SELECT p.id, p.uuid as \"uuid!\", p.team_id::bigint as \"team_id!\",\n CASE WHEN $3::boolean THEN p.properties::text ELSE NULL END as \"properties?\",\n CASE WHEN $3::boolean THEN p.properties_last_updated_at::text ELSE NULL END as \"properties_last_updated_at?\",\n CASE WHEN $3::boolean THEN p.properties_last_operation::text ELSE NULL END as \"properties_last_operation?\",\n p.created_at as \"created_at!\", p.version, p.is_identified as \"is_identified!\",\n CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,\n p.last_seen_at,\n d.distinct_id as \"distinct_id!\"\n FROM posthog_person p\n INNER JOIN posthog_persondistinctid d ON p.id = d.person_id AND p.team_id = d.team_id\n WHERE p.team_id = $1 AND d.distinct_id = ANY($2)\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
},
{
"ordinal": 3,
- "name": "properties!",
+ "name": "properties?",
"type_info": "Text"
},
{
@@ -67,7 +67,8 @@
"parameters": {
"Left": [
"Int4",
- "TextArray"
+ "TextArray",
+ "Bool"
]
},
"nullable": [
@@ -85,5 +86,5 @@
false
]
},
- "hash": "495a965269a34f368ae76ceb61e956fa0dfa6b9bfa3d909497ddd6f02f6b6438"
+ "hash": "0878f57fcfedbfb95e16f5eb0fd90ed15cbb0850dc727c39073e346d9736358c"
}
diff --git a/rust/personhog-replica/.sqlx/query-d4c0aa5ea2b985d679a67e7e748302f588d68c7351158c67b51daa0b110bddc3.json b/rust/personhog-replica/.sqlx/query-47de7f26f3570df554211b079bae88cfd3e1bef045350a82ddc0357b449b34b8.json
similarity index 59%
rename from rust/personhog-replica/.sqlx/query-d4c0aa5ea2b985d679a67e7e748302f588d68c7351158c67b51daa0b110bddc3.json
rename to rust/personhog-replica/.sqlx/query-47de7f26f3570df554211b079bae88cfd3e1bef045350a82ddc0357b449b34b8.json
index 957f85d135b4..827b8a98996c 100644
--- a/rust/personhog-replica/.sqlx/query-d4c0aa5ea2b985d679a67e7e748302f588d68c7351158c67b51daa0b110bddc3.json
+++ b/rust/personhog-replica/.sqlx/query-47de7f26f3570df554211b079bae88cfd3e1bef045350a82ddc0357b449b34b8.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key, group_properties::text as \"group_properties!\",\n created_at,\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n version\n FROM posthog_group\n WHERE team_id = $1\n AND group_type_index = $2\n AND (NOT $3 OR group_key ILIKE $4)\n AND (NOT $5 OR (group_properties::text ILIKE $6 OR group_key = $7))\n AND (NOT $8 OR (created_at, id) < ($9, $10::bigint))\n ORDER BY created_at DESC, id DESC\n LIMIT $11\n ",
+ "query": "\n SELECT id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key,\n CASE WHEN $12::boolean THEN group_properties::text ELSE NULL END as \"group_properties?\",\n created_at,\n CASE WHEN $12::boolean THEN properties_last_updated_at::text ELSE NULL END as \"properties_last_updated_at?\",\n CASE WHEN $12::boolean THEN properties_last_operation::text ELSE NULL END as \"properties_last_operation?\",\n version\n FROM posthog_group\n WHERE team_id = $1\n AND group_type_index = $2\n AND (NOT $3 OR group_key ILIKE $4)\n AND (NOT $5 OR (group_properties::text ILIKE $6 OR group_key = $7))\n AND (NOT $8 OR (created_at, id) < ($9, $10::bigint))\n ORDER BY created_at DESC, id DESC\n LIMIT $11\n ",
"describe": {
"columns": [
{
@@ -25,7 +25,7 @@
},
{
"ordinal": 4,
- "name": "group_properties!",
+ "name": "group_properties?",
"type_info": "Text"
},
{
@@ -61,7 +61,8 @@
"Bool",
"Timestamptz",
"Int8",
- "Int8"
+ "Int8",
+ "Bool"
]
},
"nullable": [
@@ -76,5 +77,5 @@
false
]
},
- "hash": "d4c0aa5ea2b985d679a67e7e748302f588d68c7351158c67b51daa0b110bddc3"
+ "hash": "47de7f26f3570df554211b079bae88cfd3e1bef045350a82ddc0357b449b34b8"
}
diff --git a/rust/personhog-replica/.sqlx/query-ee50f29646d5a831699fd5250d61c42d0a21adb5dc92a89c88cc0b949beb8321.json b/rust/personhog-replica/.sqlx/query-4c0c3346da0fe3bdbb0f923e6e18e1c7d145aac3f2b1df234854b98a9342cbd0.json
similarity index 59%
rename from rust/personhog-replica/.sqlx/query-ee50f29646d5a831699fd5250d61c42d0a21adb5dc92a89c88cc0b949beb8321.json
rename to rust/personhog-replica/.sqlx/query-4c0c3346da0fe3bdbb0f923e6e18e1c7d145aac3f2b1df234854b98a9342cbd0.json
index 8e793d99411e..d72dca93ba70 100644
--- a/rust/personhog-replica/.sqlx/query-ee50f29646d5a831699fd5250d61c42d0a21adb5dc92a89c88cc0b949beb8321.json
+++ b/rust/personhog-replica/.sqlx/query-4c0c3346da0fe3bdbb0f923e6e18e1c7d145aac3f2b1df234854b98a9342cbd0.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT g.id::bigint as \"id!\", g.team_id::bigint as \"team_id!\",\n g.group_type_index, g.group_key, g.group_properties::text as \"group_properties!\",\n g.created_at,\n g.properties_last_updated_at::text as \"properties_last_updated_at?\",\n g.properties_last_operation::text as \"properties_last_operation?\",\n g.version\n FROM posthog_group g\n INNER JOIN UNNEST($1::integer[], $2::integer[], $3::text[]) AS t(team_id, group_type_index, group_key)\n ON g.team_id = t.team_id AND g.group_type_index = t.group_type_index AND g.group_key = t.group_key\n ",
+ "query": "\n SELECT g.id::bigint as \"id!\", g.team_id::bigint as \"team_id!\",\n g.group_type_index, g.group_key,\n CASE WHEN $4::boolean THEN g.group_properties::text ELSE NULL END as \"group_properties?\",\n g.created_at,\n CASE WHEN $4::boolean THEN g.properties_last_updated_at::text ELSE NULL END as \"properties_last_updated_at?\",\n CASE WHEN $4::boolean THEN g.properties_last_operation::text ELSE NULL END as \"properties_last_operation?\",\n g.version\n FROM posthog_group g\n INNER JOIN UNNEST($1::integer[], $2::integer[], $3::text[]) AS t(team_id, group_type_index, group_key)\n ON g.team_id = t.team_id AND g.group_type_index = t.group_type_index AND g.group_key = t.group_key\n ",
"describe": {
"columns": [
{
@@ -25,7 +25,7 @@
},
{
"ordinal": 4,
- "name": "group_properties!",
+ "name": "group_properties?",
"type_info": "Text"
},
{
@@ -53,7 +53,8 @@
"Left": [
"Int4Array",
"Int4Array",
- "TextArray"
+ "TextArray",
+ "Bool"
]
},
"nullable": [
@@ -68,5 +69,5 @@
false
]
},
- "hash": "ee50f29646d5a831699fd5250d61c42d0a21adb5dc92a89c88cc0b949beb8321"
+ "hash": "4c0c3346da0fe3bdbb0f923e6e18e1c7d145aac3f2b1df234854b98a9342cbd0"
}
diff --git a/rust/personhog-replica/.sqlx/query-a59e592438b345b7f56a76b230871ceca7d98b20b03caa8f467aa08768ca82cf.json b/rust/personhog-replica/.sqlx/query-51f57e401ee7c496f44a3bd38c0a761dbcafa2d3b56a5fc855b2909b76a7e70f.json
similarity index 59%
rename from rust/personhog-replica/.sqlx/query-a59e592438b345b7f56a76b230871ceca7d98b20b03caa8f467aa08768ca82cf.json
rename to rust/personhog-replica/.sqlx/query-51f57e401ee7c496f44a3bd38c0a761dbcafa2d3b56a5fc855b2909b76a7e70f.json
index d0a6444ac301..7732bb5c1fb9 100644
--- a/rust/personhog-replica/.sqlx/query-a59e592438b345b7f56a76b230871ceca7d98b20b03caa8f467aa08768ca82cf.json
+++ b/rust/personhog-replica/.sqlx/query-51f57e401ee7c496f44a3bd38c0a761dbcafa2d3b56a5fc855b2909b76a7e70f.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT g.id::bigint as \"id!\", g.team_id::bigint as \"team_id!\",\n g.group_type_index, g.group_key, g.group_properties::text as \"group_properties!\",\n g.created_at,\n g.properties_last_updated_at::text as \"properties_last_updated_at?\",\n g.properties_last_operation::text as \"properties_last_operation?\",\n g.version\n FROM posthog_group g\n INNER JOIN UNNEST($2::integer[], $3::text[]) AS t(group_type_index, group_key)\n ON g.group_type_index = t.group_type_index AND g.group_key = t.group_key\n WHERE g.team_id = $1\n ",
+ "query": "\n SELECT g.id::bigint as \"id!\", g.team_id::bigint as \"team_id!\",\n g.group_type_index, g.group_key,\n CASE WHEN $4::boolean THEN g.group_properties::text ELSE NULL END as \"group_properties?\",\n g.created_at,\n CASE WHEN $4::boolean THEN g.properties_last_updated_at::text ELSE NULL END as \"properties_last_updated_at?\",\n CASE WHEN $4::boolean THEN g.properties_last_operation::text ELSE NULL END as \"properties_last_operation?\",\n g.version\n FROM posthog_group g\n INNER JOIN UNNEST($2::integer[], $3::text[]) AS t(group_type_index, group_key)\n ON g.group_type_index = t.group_type_index AND g.group_key = t.group_key\n WHERE g.team_id = $1\n ",
"describe": {
"columns": [
{
@@ -25,7 +25,7 @@
},
{
"ordinal": 4,
- "name": "group_properties!",
+ "name": "group_properties?",
"type_info": "Text"
},
{
@@ -53,7 +53,8 @@
"Left": [
"Int4",
"Int4Array",
- "TextArray"
+ "TextArray",
+ "Bool"
]
},
"nullable": [
@@ -68,5 +69,5 @@
false
]
},
- "hash": "a59e592438b345b7f56a76b230871ceca7d98b20b03caa8f467aa08768ca82cf"
+ "hash": "51f57e401ee7c496f44a3bd38c0a761dbcafa2d3b56a5fc855b2909b76a7e70f"
}
diff --git a/rust/personhog-replica/.sqlx/query-b9eb46c8f06bff3ad4ecdaee45f9d3e6c51ebf37b448a0652798b6c155972c6d.json b/rust/personhog-replica/.sqlx/query-6e250de7e8abd522979f516bd5236cff84021b41a8662c088e3cf6c9fb42b6dc.json
similarity index 57%
rename from rust/personhog-replica/.sqlx/query-b9eb46c8f06bff3ad4ecdaee45f9d3e6c51ebf37b448a0652798b6c155972c6d.json
rename to rust/personhog-replica/.sqlx/query-6e250de7e8abd522979f516bd5236cff84021b41a8662c088e3cf6c9fb42b6dc.json
index 53b6f8ae3571..3ad93e470338 100644
--- a/rust/personhog-replica/.sqlx/query-b9eb46c8f06bff3ad4ecdaee45f9d3e6c51ebf37b448a0652798b6c155972c6d.json
+++ b/rust/personhog-replica/.sqlx/query-6e250de7e8abd522979f516bd5236cff84021b41a8662c088e3cf6c9fb42b6dc.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT p.id, p.uuid as \"uuid!\", p.team_id::bigint as \"team_id!\",\n p.properties::text as \"properties!\",\n p.properties_last_updated_at::text as \"properties_last_updated_at?\",\n p.properties_last_operation::text as \"properties_last_operation?\",\n p.created_at as \"created_at!\", p.version, p.is_identified as \"is_identified!\",\n CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,\n p.last_seen_at,\n d.distinct_id as \"distinct_id!\"\n FROM posthog_person p\n INNER JOIN posthog_persondistinctid d ON d.person_id = p.id AND d.team_id = p.team_id\n INNER JOIN UNNEST($1::integer[], $2::text[]) AS batch(team_id, distinct_id)\n ON d.team_id = batch.team_id AND d.distinct_id = batch.distinct_id\n ",
+ "query": "\n SELECT p.id, p.uuid as \"uuid!\", p.team_id::bigint as \"team_id!\",\n CASE WHEN $3::boolean THEN p.properties::text ELSE NULL END as \"properties?\",\n CASE WHEN $3::boolean THEN p.properties_last_updated_at::text ELSE NULL END as \"properties_last_updated_at?\",\n CASE WHEN $3::boolean THEN p.properties_last_operation::text ELSE NULL END as \"properties_last_operation?\",\n p.created_at as \"created_at!\", p.version, p.is_identified as \"is_identified!\",\n CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,\n p.last_seen_at,\n d.distinct_id as \"distinct_id!\"\n FROM posthog_person p\n INNER JOIN posthog_persondistinctid d ON d.person_id = p.id AND d.team_id = p.team_id\n INNER JOIN UNNEST($1::integer[], $2::text[]) AS batch(team_id, distinct_id)\n ON d.team_id = batch.team_id AND d.distinct_id = batch.distinct_id\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
},
{
"ordinal": 3,
- "name": "properties!",
+ "name": "properties?",
"type_info": "Text"
},
{
@@ -67,7 +67,8 @@
"parameters": {
"Left": [
"Int4Array",
- "TextArray"
+ "TextArray",
+ "Bool"
]
},
"nullable": [
@@ -85,5 +86,5 @@
false
]
},
- "hash": "b9eb46c8f06bff3ad4ecdaee45f9d3e6c51ebf37b448a0652798b6c155972c6d"
+ "hash": "6e250de7e8abd522979f516bd5236cff84021b41a8662c088e3cf6c9fb42b6dc"
}
diff --git a/rust/personhog-replica/.sqlx/query-615f7144531be919f6d8e47fefc1ae6603bb521280162b13751bb864581e8bb1.json b/rust/personhog-replica/.sqlx/query-82503be15bb0e86f5674a8d16a7b87d235a21cb2a8039848f2e3d59937e78713.json
similarity index 91%
rename from rust/personhog-replica/.sqlx/query-615f7144531be919f6d8e47fefc1ae6603bb521280162b13751bb864581e8bb1.json
rename to rust/personhog-replica/.sqlx/query-82503be15bb0e86f5674a8d16a7b87d235a21cb2a8039848f2e3d59937e78713.json
index 83cfd2d9d780..2a8f849f7574 100644
--- a/rust/personhog-replica/.sqlx/query-615f7144531be919f6d8e47fefc1ae6603bb521280162b13751bb864581e8bb1.json
+++ b/rust/personhog-replica/.sqlx/query-82503be15bb0e86f5674a8d16a7b87d235a21cb2a8039848f2e3d59937e78713.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\", properties::text as \"properties!\",\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND id = $2\n ",
+ "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\", properties::text as \"properties?\",\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND id = $2\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
},
{
"ordinal": 3,
- "name": "properties!",
+ "name": "properties?",
"type_info": "Text"
},
{
@@ -79,5 +79,5 @@
true
]
},
- "hash": "615f7144531be919f6d8e47fefc1ae6603bb521280162b13751bb864581e8bb1"
+ "hash": "82503be15bb0e86f5674a8d16a7b87d235a21cb2a8039848f2e3d59937e78713"
}
diff --git a/rust/personhog-replica/.sqlx/query-87fc14840c8c78a6d88a93868e31b432ab98ad71f0ec4d348598082ef5ba4787.json b/rust/personhog-replica/.sqlx/query-82dae613d9bee4f21326109a939bba3c124c0b82e0d8f495661038b307e4c219.json
similarity index 91%
rename from rust/personhog-replica/.sqlx/query-87fc14840c8c78a6d88a93868e31b432ab98ad71f0ec4d348598082ef5ba4787.json
rename to rust/personhog-replica/.sqlx/query-82dae613d9bee4f21326109a939bba3c124c0b82e0d8f495661038b307e4c219.json
index 069055b76edc..3442ccf9deb8 100644
--- a/rust/personhog-replica/.sqlx/query-87fc14840c8c78a6d88a93868e31b432ab98ad71f0ec4d348598082ef5ba4787.json
+++ b/rust/personhog-replica/.sqlx/query-82dae613d9bee4f21326109a939bba3c124c0b82e0d8f495661038b307e4c219.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\", properties::text as \"properties!\",\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND uuid = $2\n ",
+ "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\", properties::text as \"properties?\",\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND uuid = $2\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
},
{
"ordinal": 3,
- "name": "properties!",
+ "name": "properties?",
"type_info": "Text"
},
{
@@ -79,5 +79,5 @@
true
]
},
- "hash": "87fc14840c8c78a6d88a93868e31b432ab98ad71f0ec4d348598082ef5ba4787"
+ "hash": "82dae613d9bee4f21326109a939bba3c124c0b82e0d8f495661038b307e4c219"
}
diff --git a/rust/personhog-replica/.sqlx/query-71edb79c6808f467307e051bf29514c2e31473d02255ef7650e5b6f28eb55d81.json b/rust/personhog-replica/.sqlx/query-a2430bffe9dd221cedb9883b777b59f1f33715d4aff7a35d44adadc62ea890b3.json
similarity index 91%
rename from rust/personhog-replica/.sqlx/query-71edb79c6808f467307e051bf29514c2e31473d02255ef7650e5b6f28eb55d81.json
rename to rust/personhog-replica/.sqlx/query-a2430bffe9dd221cedb9883b777b59f1f33715d4aff7a35d44adadc62ea890b3.json
index a2a60d7d3d0e..b20d88ee5c40 100644
--- a/rust/personhog-replica/.sqlx/query-71edb79c6808f467307e051bf29514c2e31473d02255ef7650e5b6f28eb55d81.json
+++ b/rust/personhog-replica/.sqlx/query-a2430bffe9dd221cedb9883b777b59f1f33715d4aff7a35d44adadc62ea890b3.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO posthog_group (team_id, group_type_index, group_key, group_properties, created_at, properties_last_updated_at, properties_last_operation, version)\n VALUES ($1, $2, $3, $4, $5, '{}'::jsonb, '{}'::jsonb, 0)\n RETURNING id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key, group_properties::text as \"group_properties!\",\n created_at,\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n version\n ",
+ "query": "\n INSERT INTO posthog_group (team_id, group_type_index, group_key, group_properties, created_at, properties_last_updated_at, properties_last_operation, version)\n VALUES ($1, $2, $3, $4, $5, '{}'::jsonb, '{}'::jsonb, 0)\n RETURNING id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key, group_properties::text as \"group_properties?\",\n created_at,\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n version\n ",
"describe": {
"columns": [
{
@@ -25,7 +25,7 @@
},
{
"ordinal": 4,
- "name": "group_properties!",
+ "name": "group_properties?",
"type_info": "Text"
},
{
@@ -70,5 +70,5 @@
false
]
},
- "hash": "71edb79c6808f467307e051bf29514c2e31473d02255ef7650e5b6f28eb55d81"
+ "hash": "a2430bffe9dd221cedb9883b777b59f1f33715d4aff7a35d44adadc62ea890b3"
}
diff --git a/rust/personhog-replica/.sqlx/query-43acf336bedec8a3529ce380bb6525315ca329b5d8f558ca7a6f8acaffe9d194.json b/rust/personhog-replica/.sqlx/query-a5fc4252aef5baeebd3f3578273763b871f1144dcb0569d568dba71b0c1a8027.json
similarity index 90%
rename from rust/personhog-replica/.sqlx/query-43acf336bedec8a3529ce380bb6525315ca329b5d8f558ca7a6f8acaffe9d194.json
rename to rust/personhog-replica/.sqlx/query-a5fc4252aef5baeebd3f3578273763b871f1144dcb0569d568dba71b0c1a8027.json
index dc55aa173b62..b3bdd5562e9e 100644
--- a/rust/personhog-replica/.sqlx/query-43acf336bedec8a3529ce380bb6525315ca329b5d8f558ca7a6f8acaffe9d194.json
+++ b/rust/personhog-replica/.sqlx/query-a5fc4252aef5baeebd3f3578273763b871f1144dcb0569d568dba71b0c1a8027.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key, group_properties::text as \"group_properties!\",\n created_at,\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n version\n FROM posthog_group\n WHERE team_id = $1 AND group_type_index = $2 AND group_key = $3\n ",
+ "query": "\n SELECT id::bigint as \"id!\", team_id::bigint as \"team_id!\",\n group_type_index, group_key, group_properties::text as \"group_properties?\",\n created_at,\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n version\n FROM posthog_group\n WHERE team_id = $1 AND group_type_index = $2 AND group_key = $3\n ",
"describe": {
"columns": [
{
@@ -25,7 +25,7 @@
},
{
"ordinal": 4,
- "name": "group_properties!",
+ "name": "group_properties?",
"type_info": "Text"
},
{
@@ -68,5 +68,5 @@
false
]
},
- "hash": "43acf336bedec8a3529ce380bb6525315ca329b5d8f558ca7a6f8acaffe9d194"
+ "hash": "a5fc4252aef5baeebd3f3578273763b871f1144dcb0569d568dba71b0c1a8027"
}
diff --git a/rust/personhog-replica/.sqlx/query-b03692c528fa947f6decbe1f4bdc7d32027c85a51e14238945ed3443de9a5204.json b/rust/personhog-replica/.sqlx/query-b6d62a371a12a86e28487c9cbdaefee50ed10f15e6fadb3b791efe7c26282cca.json
similarity index 62%
rename from rust/personhog-replica/.sqlx/query-b03692c528fa947f6decbe1f4bdc7d32027c85a51e14238945ed3443de9a5204.json
rename to rust/personhog-replica/.sqlx/query-b6d62a371a12a86e28487c9cbdaefee50ed10f15e6fadb3b791efe7c26282cca.json
index 793915805275..6853459982e3 100644
--- a/rust/personhog-replica/.sqlx/query-b03692c528fa947f6decbe1f4bdc7d32027c85a51e14238945ed3443de9a5204.json
+++ b/rust/personhog-replica/.sqlx/query-b6d62a371a12a86e28487c9cbdaefee50ed10f15e6fadb3b791efe7c26282cca.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\", properties::text as \"properties!\",\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND uuid = ANY($2)\n ",
+ "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\",\n CASE WHEN $3::boolean THEN properties::text ELSE NULL END as \"properties?\",\n CASE WHEN $3::boolean THEN properties_last_updated_at::text ELSE NULL END as \"properties_last_updated_at?\",\n CASE WHEN $3::boolean THEN properties_last_operation::text ELSE NULL END as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND id = ANY($2)\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
},
{
"ordinal": 3,
- "name": "properties!",
+ "name": "properties?",
"type_info": "Text"
},
{
@@ -62,7 +62,8 @@
"parameters": {
"Left": [
"Int4",
- "UuidArray"
+ "Int8Array",
+ "Bool"
]
},
"nullable": [
@@ -79,5 +80,5 @@
true
]
},
- "hash": "b03692c528fa947f6decbe1f4bdc7d32027c85a51e14238945ed3443de9a5204"
+ "hash": "b6d62a371a12a86e28487c9cbdaefee50ed10f15e6fadb3b791efe7c26282cca"
}
diff --git a/rust/personhog-replica/.sqlx/query-93a691c94a59ef7bb53626ab7bc5b5c1c0f419e4719b9d6b5cf6a77a8e021f59.json b/rust/personhog-replica/.sqlx/query-d6c4b0469b4c82657c213fbf265a58eb553db86f0a117f2c3b2abaa56be5bb0a.json
similarity index 61%
rename from rust/personhog-replica/.sqlx/query-93a691c94a59ef7bb53626ab7bc5b5c1c0f419e4719b9d6b5cf6a77a8e021f59.json
rename to rust/personhog-replica/.sqlx/query-d6c4b0469b4c82657c213fbf265a58eb553db86f0a117f2c3b2abaa56be5bb0a.json
index a30d8be893f0..369bc8de8017 100644
--- a/rust/personhog-replica/.sqlx/query-93a691c94a59ef7bb53626ab7bc5b5c1c0f419e4719b9d6b5cf6a77a8e021f59.json
+++ b/rust/personhog-replica/.sqlx/query-d6c4b0469b4c82657c213fbf265a58eb553db86f0a117f2c3b2abaa56be5bb0a.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\", properties::text as \"properties!\",\n properties_last_updated_at::text as \"properties_last_updated_at?\",\n properties_last_operation::text as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND id = ANY($2)\n ",
+ "query": "\n SELECT id, uuid, team_id::bigint as \"team_id!\",\n CASE WHEN $3::boolean THEN properties::text ELSE NULL END as \"properties?\",\n CASE WHEN $3::boolean THEN properties_last_updated_at::text ELSE NULL END as \"properties_last_updated_at?\",\n CASE WHEN $3::boolean THEN properties_last_operation::text ELSE NULL END as \"properties_last_operation?\",\n created_at, version, is_identified,\n CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,\n last_seen_at\n FROM posthog_person\n WHERE team_id = $1 AND uuid = ANY($2)\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
},
{
"ordinal": 3,
- "name": "properties!",
+ "name": "properties?",
"type_info": "Text"
},
{
@@ -62,7 +62,8 @@
"parameters": {
"Left": [
"Int4",
- "Int8Array"
+ "UuidArray",
+ "Bool"
]
},
"nullable": [
@@ -79,5 +80,5 @@
true
]
},
- "hash": "93a691c94a59ef7bb53626ab7bc5b5c1c0f419e4719b9d6b5cf6a77a8e021f59"
+ "hash": "d6c4b0469b4c82657c213fbf265a58eb553db86f0a117f2c3b2abaa56be5bb0a"
}
diff --git a/rust/personhog-replica/.sqlx/query-0f3385bfea22438ccc365da5ecca78530e1f61f334661fc69bc0d4cdb8848f06.json b/rust/personhog-replica/.sqlx/query-f0c3b45d37c742f954fbfac66d4bc46a5922c950f8ebb3662194ee42590f5331.json
similarity index 92%
rename from rust/personhog-replica/.sqlx/query-0f3385bfea22438ccc365da5ecca78530e1f61f334661fc69bc0d4cdb8848f06.json
rename to rust/personhog-replica/.sqlx/query-f0c3b45d37c742f954fbfac66d4bc46a5922c950f8ebb3662194ee42590f5331.json
index 08051d2f3972..636c44b20ee5 100644
--- a/rust/personhog-replica/.sqlx/query-0f3385bfea22438ccc365da5ecca78530e1f61f334661fc69bc0d4cdb8848f06.json
+++ b/rust/personhog-replica/.sqlx/query-f0c3b45d37c742f954fbfac66d4bc46a5922c950f8ebb3662194ee42590f5331.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT p.id, p.uuid, p.team_id::bigint as \"team_id!\", p.properties::text as \"properties!\",\n p.properties_last_updated_at::text as \"properties_last_updated_at?\",\n p.properties_last_operation::text as \"properties_last_operation?\",\n p.created_at, p.version, p.is_identified,\n CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,\n p.last_seen_at\n FROM posthog_person p\n INNER JOIN posthog_persondistinctid d ON p.id = d.person_id AND p.team_id = d.team_id\n WHERE p.team_id = $1 AND d.distinct_id = $2\n LIMIT 1\n ",
+ "query": "\n SELECT p.id, p.uuid, p.team_id::bigint as \"team_id!\", p.properties::text as \"properties?\",\n p.properties_last_updated_at::text as \"properties_last_updated_at?\",\n p.properties_last_operation::text as \"properties_last_operation?\",\n p.created_at, p.version, p.is_identified,\n CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,\n p.last_seen_at\n FROM posthog_person p\n INNER JOIN posthog_persondistinctid d ON p.id = d.person_id AND p.team_id = d.team_id\n WHERE p.team_id = $1 AND d.distinct_id = $2\n LIMIT 1\n ",
"describe": {
"columns": [
{
@@ -20,7 +20,7 @@
},
{
"ordinal": 3,
- "name": "properties!",
+ "name": "properties?",
"type_info": "Text"
},
{
@@ -79,5 +79,5 @@
true
]
},
- "hash": "0f3385bfea22438ccc365da5ecca78530e1f61f334661fc69bc0d4cdb8848f06"
+ "hash": "f0c3b45d37c742f954fbfac66d4bc46a5922c950f8ebb3662194ee42590f5331"
}
diff --git a/rust/personhog-replica/src/service/field_mask.rs b/rust/personhog-replica/src/service/field_mask.rs
new file mode 100644
index 000000000000..e351f04fed57
--- /dev/null
+++ b/rust/personhog-replica/src/service/field_mask.rs
@@ -0,0 +1,571 @@
+use std::collections::HashSet;
+
+use personhog_proto::personhog::types::v1::{Group, Person, ReadOptions};
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+enum PersonField {
+ Id,
+ Uuid,
+ TeamId,
+ Properties,
+ PropertiesLastUpdatedAt,
+ PropertiesLastOperation,
+ CreatedAt,
+ Version,
+ IsIdentified,
+ IsUserId,
+ LastSeenAt,
+}
+
+impl PersonField {
+ const ALL: &[Self] = &[
+ Self::Id,
+ Self::Uuid,
+ Self::TeamId,
+ Self::Properties,
+ Self::PropertiesLastUpdatedAt,
+ Self::PropertiesLastOperation,
+ Self::CreatedAt,
+ Self::Version,
+ Self::IsIdentified,
+ Self::IsUserId,
+ Self::LastSeenAt,
+ ];
+
+ fn from_wire(s: &str) -> Option<Self> {
+ match s {
+ "id" => Some(Self::Id),
+ "uuid" => Some(Self::Uuid),
+ "team_id" => Some(Self::TeamId),
+ "properties" => Some(Self::Properties),
+ "properties_last_updated_at" => Some(Self::PropertiesLastUpdatedAt),
+ "properties_last_operation" => Some(Self::PropertiesLastOperation),
+ "created_at" => Some(Self::CreatedAt),
+ "version" => Some(Self::Version),
+ "is_identified" => Some(Self::IsIdentified),
+ "is_user_id" => Some(Self::IsUserId),
+ "last_seen_at" => Some(Self::LastSeenAt),
+ _ => None,
+ }
+ }
+
+ fn is_property_field(self) -> bool {
+ matches!(
+ self,
+ Self::Properties | Self::PropertiesLastUpdatedAt | Self::PropertiesLastOperation
+ )
+ }
+
+ fn clear(self, person: &mut Person) {
+ match self {
+ Self::Id => person.id = 0,
+ Self::Uuid => person.uuid.clear(),
+ Self::TeamId => person.team_id = 0,
+ Self::Properties => person.properties.clear(),
+ Self::PropertiesLastUpdatedAt => person.properties_last_updated_at.clear(),
+ Self::PropertiesLastOperation => person.properties_last_operation.clear(),
+ Self::CreatedAt => person.created_at = 0,
+ Self::Version => person.version = 0,
+ Self::IsIdentified => person.is_identified = false,
+ Self::IsUserId => person.is_user_id = None,
+ Self::LastSeenAt => person.last_seen_at = None,
+ }
+ }
+}
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+enum GroupField {
+ Id,
+ TeamId,
+ GroupTypeIndex,
+ GroupKey,
+ GroupProperties,
+ PropertiesLastUpdatedAt,
+ PropertiesLastOperation,
+ CreatedAt,
+ Version,
+}
+
+impl GroupField {
+ const ALL: &[Self] = &[
+ Self::Id,
+ Self::TeamId,
+ Self::GroupTypeIndex,
+ Self::GroupKey,
+ Self::GroupProperties,
+ Self::PropertiesLastUpdatedAt,
+ Self::PropertiesLastOperation,
+ Self::CreatedAt,
+ Self::Version,
+ ];
+
+ fn from_wire(s: &str) -> Option<Self> {
+ match s {
+ "id" => Some(Self::Id),
+ "team_id" => Some(Self::TeamId),
+ "group_type_index" => Some(Self::GroupTypeIndex),
+ "group_key" => Some(Self::GroupKey),
+ "group_properties" => Some(Self::GroupProperties),
+ "properties_last_updated_at" => Some(Self::PropertiesLastUpdatedAt),
+ "properties_last_operation" => Some(Self::PropertiesLastOperation),
+ "created_at" => Some(Self::CreatedAt),
+ "version" => Some(Self::Version),
+ _ => None,
+ }
+ }
+
+ fn is_property_field(self) -> bool {
+ matches!(
+ self,
+ Self::GroupProperties | Self::PropertiesLastUpdatedAt | Self::PropertiesLastOperation
+ )
+ }
+
+ fn clear(self, group: &mut Group) {
+ match self {
+ Self::Id => group.id = 0,
+ Self::TeamId => group.team_id = 0,
+ Self::GroupTypeIndex => group.group_type_index = 0,
+ Self::GroupKey => group.group_key.clear(),
+ Self::GroupProperties => group.group_properties.clear(),
+ Self::PropertiesLastUpdatedAt => group.properties_last_updated_at.clear(),
+ Self::PropertiesLastOperation => group.properties_last_operation.clear(),
+ Self::CreatedAt => group.created_at = 0,
+ Self::Version => group.version = 0,
+ }
+ }
+}
+
+/// Returns true if the field mask requires person properties columns.
+pub fn person_needs_properties(read_options: &Option<ReadOptions>) -> bool {
+ let mask = match read_options.as_ref() {
+ Some(opts) if !opts.field_mask.is_empty() => &opts.field_mask,
+ _ => return true,
+ };
+ mask.iter()
+ .any(|f| PersonField::from_wire(f).is_some_and(|f| f.is_property_field()))
+}
+
+/// Returns true if the field mask requires group properties columns.
+pub fn group_needs_properties(read_options: &Option<ReadOptions>) -> bool {
+ let mask = match read_options.as_ref() {
+ Some(opts) if !opts.field_mask.is_empty() => &opts.field_mask,
+ _ => return true,
+ };
+ mask.iter()
+ .any(|f| GroupField::from_wire(f).is_some_and(|f| f.is_property_field()))
+}
+
+/// Build a field mask set from read options. Returns None if all fields should be kept.
+pub fn build_field_mask(read_options: &Option<ReadOptions>) -> Option<HashSet<String>> {
+ match read_options.as_ref() {
+ Some(opts) if !opts.field_mask.is_empty() => {
+ Some(opts.field_mask.iter().cloned().collect())
+ }
+ _ => None,
+ }
+}
+
+/// Apply the field mask to a Person proto, zeroing out fields not in the mask.
+pub fn apply_person_field_mask(person: &mut Person, fields: &Option<HashSet<String>>) {
+ let Some(fields) = fields else { return };
+ let requested: HashSet<PersonField> = fields
+ .iter()
+ .filter_map(|s| PersonField::from_wire(s))
+ .collect();
+ for &field in PersonField::ALL {
+ if !requested.contains(&field) {
+ field.clear(person);
+ }
+ }
+}
+
+/// Apply the field mask to a Group proto, zeroing out fields not in the mask.
+pub fn apply_group_field_mask(group: &mut Group, fields: &Option<HashSet<String>>) {
+ let Some(fields) = fields else { return };
+ let requested: HashSet<GroupField> = fields
+ .iter()
+ .filter_map(|s| GroupField::from_wire(s))
+ .collect();
+ for &field in GroupField::ALL {
+ if !requested.contains(&field) {
+ field.clear(group);
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn read_options_with_mask(fields: Vec<&str>) -> Option<ReadOptions> {
+ Some(ReadOptions {
+ consistency: 0,
+ field_mask: fields.into_iter().map(String::from).collect(),
+ })
+ }
+
+ // These constructors use explicit named fields so that adding a field to
+ // the proto causes a compile error here, reminding you to update the enum.
+ fn populated_person() -> Person {
+ Person {
+ id: 42,
+ uuid: "some-uuid".to_string(),
+ team_id: 7,
+ properties: b"{}".to_vec(),
+ properties_last_updated_at: b"ts".to_vec(),
+ properties_last_operation: b"op".to_vec(),
+ created_at: 1000,
+ version: 3,
+ is_identified: true,
+ is_user_id: Some(false),
+ last_seen_at: Some(9999),
+ }
+ }
+
+ fn populated_group() -> Group {
+ Group {
+ id: 10,
+ team_id: 5,
+ group_type_index: 2,
+ group_key: "acme".to_string(),
+ group_properties: b"{\"k\":\"v\"}".to_vec(),
+ properties_last_updated_at: b"ts".to_vec(),
+ properties_last_operation: b"op".to_vec(),
+ created_at: 2000,
+ version: 1,
+ }
+ }
+
+ // ============================================================
+ // Drift guards — ensure enums stay in sync with proto structs.
+ // The populated_* constructors above use named fields (no `..Default`),
+ // so adding a proto field without updating the constructor is a compile
+ // error. These tests additionally verify that ALL covers every field.
+ // ============================================================
+
+ #[test]
+ fn person_field_all_covers_every_proto_field() {
+ assert_eq!(
+ PersonField::ALL.len(),
+ 11,
+ "PersonField::ALL count doesn't match Person proto field count — \
+ did you add a field to the Person proto without updating PersonField?"
+ );
+ let mut person = populated_person();
+ let no_fields: HashSet<String> = HashSet::new();
+ apply_person_field_mask(&mut person, &Some(no_fields));
+ assert_eq!(
+ person,
+ Person::default(),
+ "masking with an empty set should zero every field"
+ );
+ }
+
+ #[test]
+ fn group_field_all_covers_every_proto_field() {
+ assert_eq!(
+ GroupField::ALL.len(),
+ 9,
+ "GroupField::ALL count doesn't match Group proto field count — \
+ did you add a field to the Group proto without updating GroupField?"
+ );
+ let mut group = populated_group();
+ let no_fields: HashSet<String> = HashSet::new();
+ apply_group_field_mask(&mut group, &Some(no_fields));
+ assert_eq!(
+ group,
+ Group::default(),
+ "masking with an empty set should zero every field"
+ );
+ }
+
+ // ============================================================
+ // build_field_mask
+ // ============================================================
+
+ #[test]
+ fn build_field_mask_returns_none_when_read_options_is_none() {
+ let result = build_field_mask(&None);
+ assert!(result.is_none());
+ }
+
+ #[test]
+ fn build_field_mask_returns_none_when_field_mask_is_empty() {
+ let result = build_field_mask(&read_options_with_mask(vec![]));
+ assert!(result.is_none());
+ }
+
+ #[test]
+ fn build_field_mask_returns_set_of_requested_fields() {
+ let result = build_field_mask(&read_options_with_mask(vec!["id", "uuid", "team_id"]));
+ let set = result.expect("should return Some");
+ assert_eq!(set.len(), 3);
+ assert!(set.contains("id"));
+ assert!(set.contains("uuid"));
+ assert!(set.contains("team_id"));
+ }
+
+ #[test]
+ fn build_field_mask_deduplicates_repeated_fields() {
+ let result = build_field_mask(&read_options_with_mask(vec!["id", "id", "uuid"]));
+ let set = result.expect("should return Some");
+ assert_eq!(set.len(), 2);
+ }
+
+ // ============================================================
+ // person_needs_properties / group_needs_properties
+ // ============================================================
+
+ use rstest::rstest;
+
+ #[rstest]
+ #[case::no_read_options(None, true)]
+ #[case::empty_mask(Some(vec![]), true)]
+ #[case::mask_includes_properties(Some(vec!["properties"]), true)]
+ #[case::mask_includes_properties_last_updated_at(Some(vec!["properties_last_updated_at"]), true)]
+ #[case::mask_includes_properties_last_operation(Some(vec!["properties_last_operation"]), true)]
+ #[case::mask_with_only_non_property_fields(Some(vec!["id", "uuid"]), false)]
+ fn person_needs_properties_reflects_whether_mask_requests_property_fields(
+ #[case] mask_fields: Option<Vec<&str>>,
+ #[case] expected: bool,
+ ) {
+ let read_options = mask_fields.and_then(read_options_with_mask);
+ assert_eq!(person_needs_properties(&read_options), expected);
+ }
+
+ #[rstest]
+ #[case::no_read_options(None, true)]
+ #[case::empty_mask(Some(vec![]), true)]
+ #[case::mask_includes_group_properties(Some(vec!["group_properties"]), true)]
+ #[case::mask_includes_properties_last_updated_at(Some(vec!["properties_last_updated_at"]), true)]
+ #[case::mask_includes_properties_last_operation(Some(vec!["properties_last_operation"]), true)]
+ #[case::mask_with_only_non_property_fields(Some(vec!["id", "group_key"]), false)]
+ fn group_needs_properties_reflects_whether_mask_requests_property_fields(
+ #[case] mask_fields: Option<Vec<&str>>,
+ #[case] expected: bool,
+ ) {
+ let read_options = mask_fields.and_then(read_options_with_mask);
+ assert_eq!(group_needs_properties(&read_options), expected);
+ }
+
+ // ============================================================
+ // apply_person_field_mask
+ // ============================================================
+
+ #[test]
+ fn apply_person_field_mask_preserves_all_fields_when_mask_is_none() {
+ let mut person = populated_person();
+ apply_person_field_mask(&mut person, &None);
+ let expected = populated_person();
+ assert_eq!(person.id, expected.id);
+ assert_eq!(person.uuid, expected.uuid);
+ assert_eq!(person.team_id, expected.team_id);
+ assert_eq!(person.properties, expected.properties);
+ assert_eq!(
+ person.properties_last_updated_at,
+ expected.properties_last_updated_at
+ );
+ assert_eq!(
+ person.properties_last_operation,
+ expected.properties_last_operation
+ );
+ assert_eq!(person.created_at, expected.created_at);
+ assert_eq!(person.version, expected.version);
+ assert_eq!(person.is_identified, expected.is_identified);
+ assert_eq!(person.is_user_id, expected.is_user_id);
+ assert_eq!(person.last_seen_at, expected.last_seen_at);
+ }
+
+ #[test]
+ fn apply_person_field_mask_keeps_only_id_when_mask_contains_only_id() {
+ let mut person = populated_person();
+ let fields = Some(HashSet::from(["id".to_string()]));
+ apply_person_field_mask(&mut person, &fields);
+
+ assert_eq!(person.id, 42, "id should be preserved");
+ assert!(person.uuid.is_empty(), "uuid should be zeroed");
+ assert_eq!(person.team_id, 0, "team_id should be zeroed");
+ assert!(person.properties.is_empty(), "properties should be zeroed");
+ assert!(
+ person.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ person.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(person.created_at, 0, "created_at should be zeroed");
+ assert_eq!(person.version, 0, "version should be zeroed");
+ assert!(!person.is_identified, "is_identified should be zeroed");
+ assert!(person.is_user_id.is_none(), "is_user_id should be zeroed");
+ assert!(
+ person.last_seen_at.is_none(),
+ "last_seen_at should be zeroed"
+ );
+ }
+
+ #[rstest]
+ #[case::id("id", |p: &Person| p.id == 42)]
+ #[case::uuid("uuid", |p: &Person| p.uuid == "some-uuid")]
+ #[case::team_id("team_id", |p: &Person| p.team_id == 7)]
+ #[case::properties("properties", |p: &Person| !p.properties.is_empty())]
+ #[case::properties_last_updated_at("properties_last_updated_at", |p: &Person| !p.properties_last_updated_at.is_empty())]
+ #[case::properties_last_operation("properties_last_operation", |p: &Person| !p.properties_last_operation.is_empty())]
+ #[case::created_at("created_at", |p: &Person| p.created_at == 1000)]
+ #[case::version("version", |p: &Person| p.version == 3)]
+ #[case::is_identified("is_identified", |p: &Person| p.is_identified)]
+ #[case::is_user_id("is_user_id", |p: &Person| p.is_user_id.is_some())]
+ #[case::last_seen_at("last_seen_at", |p: &Person| p.last_seen_at.is_some())]
+ fn apply_person_field_mask_preserves_single_requested_field(
+ #[case] field: &str,
+ #[case] check: impl Fn(&Person) -> bool,
+ ) {
+ let mut person = populated_person();
+ let fields = Some(HashSet::from([field.to_string()]));
+ apply_person_field_mask(&mut person, &fields);
+ assert!(check(&person), "field '{field}' should be preserved");
+ }
+
+ #[test]
+ fn apply_person_field_mask_with_subset_preserves_only_requested_fields() {
+ let mut person = populated_person();
+ let fields = Some(HashSet::from([
+ "id".to_string(),
+ "is_identified".to_string(),
+ ]));
+ apply_person_field_mask(&mut person, &fields);
+
+ assert_eq!(person.id, 42, "id should be preserved");
+ assert!(person.is_identified, "is_identified should be preserved");
+ assert!(person.uuid.is_empty(), "uuid should be zeroed");
+ assert_eq!(person.team_id, 0, "team_id should be zeroed");
+ assert_eq!(person.version, 0, "version should be zeroed");
+ }
+
+ #[test]
+ fn apply_person_field_mask_ignores_unknown_field_names() {
+ let mut person = populated_person();
+ let fields = Some(HashSet::from([
+ "id".to_string(),
+ "totally_unknown_field".to_string(),
+ ]));
+ apply_person_field_mask(&mut person, &fields);
+
+ assert_eq!(person.id, 42, "id should be preserved");
+ assert!(
+ person.uuid.is_empty(),
+ "uuid should be zeroed by the real mask logic"
+ );
+ }
+
+ // ============================================================
+ // apply_group_field_mask
+ // ============================================================
+
+ #[test]
+ fn apply_group_field_mask_preserves_all_fields_when_mask_is_none() {
+ let mut group = populated_group();
+ apply_group_field_mask(&mut group, &None);
+ let expected = populated_group();
+ assert_eq!(group.id, expected.id);
+ assert_eq!(group.team_id, expected.team_id);
+ assert_eq!(group.group_type_index, expected.group_type_index);
+ assert_eq!(group.group_key, expected.group_key);
+ assert_eq!(group.group_properties, expected.group_properties);
+ assert_eq!(
+ group.properties_last_updated_at,
+ expected.properties_last_updated_at
+ );
+ assert_eq!(
+ group.properties_last_operation,
+ expected.properties_last_operation
+ );
+ assert_eq!(group.created_at, expected.created_at);
+ assert_eq!(group.version, expected.version);
+ }
+
+ #[test]
+ fn apply_group_field_mask_keeps_only_id_when_mask_contains_only_id() {
+ let mut group = populated_group();
+ let fields = Some(HashSet::from(["id".to_string()]));
+ apply_group_field_mask(&mut group, &fields);
+
+ assert_eq!(group.id, 10, "id should be preserved");
+ assert_eq!(group.team_id, 0, "team_id should be zeroed");
+ assert_eq!(
+ group.group_type_index, 0,
+ "group_type_index should be zeroed"
+ );
+ assert!(group.group_key.is_empty(), "group_key should be zeroed");
+ assert!(
+ group.group_properties.is_empty(),
+ "group_properties should be zeroed"
+ );
+ assert!(
+ group.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ group.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(group.created_at, 0, "created_at should be zeroed");
+ assert_eq!(group.version, 0, "version should be zeroed");
+ }
+
+ #[rstest]
+ #[case::id("id", |g: &Group| g.id == 10)]
+ #[case::team_id("team_id", |g: &Group| g.team_id == 5)]
+ #[case::group_type_index("group_type_index", |g: &Group| g.group_type_index == 2)]
+ #[case::group_key("group_key", |g: &Group| g.group_key == "acme")]
+ #[case::group_properties("group_properties", |g: &Group| !g.group_properties.is_empty())]
+ #[case::properties_last_updated_at("properties_last_updated_at", |g: &Group| !g.properties_last_updated_at.is_empty())]
+ #[case::properties_last_operation("properties_last_operation", |g: &Group| !g.properties_last_operation.is_empty())]
+ #[case::created_at("created_at", |g: &Group| g.created_at == 2000)]
+ #[case::version("version", |g: &Group| g.version == 1)]
+ fn apply_group_field_mask_preserves_single_requested_field(
+ #[case] field: &str,
+ #[case] check: impl Fn(&Group) -> bool,
+ ) {
+ let mut group = populated_group();
+ let fields = Some(HashSet::from([field.to_string()]));
+ apply_group_field_mask(&mut group, &fields);
+ assert!(check(&group), "field '{field}' should be preserved");
+ }
+
+ #[test]
+ fn apply_group_field_mask_with_subset_preserves_only_requested_fields() {
+ let mut group = populated_group();
+ let fields = Some(HashSet::from([
+ "group_key".to_string(),
+ "group_type_index".to_string(),
+ ]));
+ apply_group_field_mask(&mut group, &fields);
+
+ assert_eq!(group.group_key, "acme", "group_key should be preserved");
+ assert_eq!(
+ group.group_type_index, 2,
+ "group_type_index should be preserved"
+ );
+ assert_eq!(group.id, 0, "id should be zeroed");
+ assert_eq!(group.team_id, 0, "team_id should be zeroed");
+ assert!(
+ group.group_properties.is_empty(),
+ "group_properties should be zeroed"
+ );
+ }
+
+ #[test]
+ fn apply_group_field_mask_ignores_unknown_field_names() {
+ let mut group = populated_group();
+ let fields = Some(HashSet::from([
+ "group_key".to_string(),
+ "totally_unknown_field".to_string(),
+ ]));
+ apply_group_field_mask(&mut group, &fields);
+
+ assert_eq!(group.group_key, "acme", "group_key should be preserved");
+ assert_eq!(group.id, 0, "id should be zeroed by the real mask logic");
+ }
+}
diff --git a/rust/personhog-replica/src/service/mod.rs b/rust/personhog-replica/src/service/mod.rs
index be776d2dbfd3..02dd3c322905 100644
--- a/rust/personhog-replica/src/service/mod.rs
+++ b/rust/personhog-replica/src/service/mod.rs
@@ -1,5 +1,6 @@
mod consistency;
mod error;
+pub mod field_mask;
mod types;
#[cfg(test)]
@@ -49,6 +50,10 @@ const MAX_LIST_GROUPS_LIMIT: i32 = 1_000;
use consistency::{reject_strong_consistency, to_storage_consistency};
use error::log_and_convert_error;
+use field_mask::{
+ apply_group_field_mask, apply_person_field_mask, build_field_mask, group_needs_properties,
+ person_needs_properties,
+};
pub struct PersonHogReplicaService {
storage: Arc<dyn FullStorage>,
@@ -91,9 +96,10 @@ impl PersonHogReplica for PersonHogReplicaService {
let req = request.into_inner();
reject_strong_consistency(&req.read_options)?;
+ let include_props = person_needs_properties(&req.read_options);
let persons = self
.storage
- .get_persons_by_ids(req.team_id, &req.person_ids)
+ .get_persons_by_ids(req.team_id, &req.person_ids, include_props)
.await
.map_err(|e| log_and_convert_error(e, "get_persons"))?;
@@ -104,8 +110,14 @@ impl PersonHogReplica for PersonHogReplicaService {
.filter(|id| !found_ids.contains(id))
.collect();
+ let mask = build_field_mask(&req.read_options);
+ let mut proto_persons: Vec<_> = persons.into_iter().map(Into::into).collect();
+ for p in &mut proto_persons {
+ apply_person_field_mask(p, &mask);
+ }
+
Ok(Response::new(PersonsResponse {
- persons: persons.into_iter().map(Into::into).collect(),
+ persons: proto_persons,
missing_ids,
}))
}
@@ -145,14 +157,21 @@ impl PersonHogReplica for PersonHogReplicaService {
.collect::<Result<Vec<_>, _>>()
.map_err(|e| Status::invalid_argument(format!("Invalid UUID: {e}")))?;
+ let include_props = person_needs_properties(&req.read_options);
let persons = self
.storage
- .get_persons_by_uuids(req.team_id, &uuids)
+ .get_persons_by_uuids(req.team_id, &uuids, include_props)
.await
.map_err(|e| log_and_convert_error(e, "get_persons_by_uuids"))?;
+ let mask = build_field_mask(&req.read_options);
+ let mut proto_persons: Vec<_> = persons.into_iter().map(Into::into).collect();
+ for p in &mut proto_persons {
+ apply_person_field_mask(p, &mask);
+ }
+
Ok(Response::new(PersonsResponse {
- persons: persons.into_iter().map(Into::into).collect(),
+ persons: proto_persons,
missing_ids: Vec::new(),
}))
}
@@ -186,18 +205,26 @@ impl PersonHogReplica for PersonHogReplicaService {
let req = request.into_inner();
reject_strong_consistency(&req.read_options)?;
+ let include_props = person_needs_properties(&req.read_options);
let results = self
.storage
- .get_persons_by_distinct_ids_in_team(req.team_id, &req.distinct_ids)
+ .get_persons_by_distinct_ids_in_team(req.team_id, &req.distinct_ids, include_props)
.await
.map_err(|e| log_and_convert_error(e, "get_persons_by_distinct_ids_in_team"))?;
+ let mask = build_field_mask(&req.read_options);
Ok(Response::new(PersonsByDistinctIdsInTeamResponse {
results: results
.into_iter()
- .map(|(distinct_id, person)| PersonWithDistinctIds {
- distinct_id,
- person: person.map(Into::into),
+ .map(|(distinct_id, person)| {
+ let mut p: Option<_> = person.map(Into::into);
+ if let Some(ref mut person) = p {
+ apply_person_field_mask(person, &mask);
+ }
+ PersonWithDistinctIds {
+ distinct_id,
+ person: p,
+ }
})
.collect(),
}))
@@ -210,6 +237,7 @@ impl PersonHogReplica for PersonHogReplicaService {
let req = request.into_inner();
reject_strong_consistency(&req.read_options)?;
+ let include_props = person_needs_properties(&req.read_options);
let team_distinct_ids: Vec<(i64, String)> = req
.team_distinct_ids
.into_iter()
@@ -218,22 +246,27 @@ impl PersonHogReplica for PersonHogReplicaService {
let results = self
.storage
- .get_persons_by_distinct_ids_cross_team(&team_distinct_ids)
+ .get_persons_by_distinct_ids_cross_team(&team_distinct_ids, include_props)
.await
.map_err(|e| log_and_convert_error(e, "get_persons_by_distinct_ids"))?;
+ let mask = build_field_mask(&req.read_options);
Ok(Response::new(PersonsByDistinctIdsResponse {
results: results
.into_iter()
- .map(
- |((team_id, distinct_id), person)| PersonWithTeamDistinctId {
+ .map(|((team_id, distinct_id), person)| {
+ let mut p: Option<_> = person.map(Into::into);
+ if let Some(ref mut person) = p {
+ apply_person_field_mask(person, &mask);
+ }
+ PersonWithTeamDistinctId {
key: Some(TeamDistinctId {
team_id,
distinct_id,
}),
- person: person.map(Into::into),
- },
- )
+ person: p,
+ }
+ })
.collect(),
}))
}
@@ -640,6 +673,7 @@ impl PersonHogReplica for PersonHogReplicaService {
) -> Result<Response<GroupsResponse>, Status> {
let req = request.into_inner();
let consistency = to_storage_consistency(&req.read_options);
+ let include_props = group_needs_properties(&req.read_options);
let identifiers: Vec<storage::GroupIdentifier> = req
.group_identifiers
@@ -652,7 +686,7 @@ impl PersonHogReplica for PersonHogReplicaService {
let groups = self
.storage
- .get_groups(req.team_id, &identifiers, consistency)
+ .get_groups(req.team_id, &identifiers, consistency, include_props)
.await
.map_err(|e| log_and_convert_error(e, "get_groups"))?;
@@ -668,8 +702,14 @@ impl PersonHogReplica for PersonHogReplicaService {
.filter(|gi| !found_keys.contains(&(gi.group_type_index, gi.group_key.clone())))
.collect();
+ let mask = build_field_mask(&req.read_options);
+ let mut proto_groups: Vec<_> = groups.into_iter().map(Into::into).collect();
+ for g in &mut proto_groups {
+ apply_group_field_mask(g, &mask);
+ }
+
Ok(Response::new(GroupsResponse {
- groups: groups.into_iter().map(Into::into).collect(),
+ groups: proto_groups,
missing_groups,
}))
}
@@ -680,6 +720,7 @@ impl PersonHogReplica for PersonHogReplicaService {
) -> Result<Response<GetGroupsBatchResponse>, Status> {
let req = request.into_inner();
let consistency = to_storage_consistency(&req.read_options);
+ let include_props = group_needs_properties(&req.read_options);
let keys: Vec<storage::GroupKey> = req
.keys
@@ -693,7 +734,7 @@ impl PersonHogReplica for PersonHogReplicaService {
let results = self
.storage
- .get_groups_batch(&keys, consistency)
+ .get_groups_batch(&keys, consistency, include_props)
.await
.map_err(|e| log_and_convert_error(e, "get_groups_batch"))?;
@@ -704,18 +745,23 @@ impl PersonHogReplica for PersonHogReplicaService {
.collect();
// Return results for all requested keys
+ let mask = build_field_mask(&req.read_options);
let results = req
.keys
.into_iter()
.map(|k| {
let key = (k.team_id, k.group_type_index, k.group_key.clone());
+ let mut group: Option<_> = found.remove(&key).map(Into::into);
+ if let Some(ref mut g) = group {
+ apply_group_field_mask(g, &mask);
+ }
GroupWithKey {
key: Some(GroupKey {
team_id: k.team_id,
group_type_index: k.group_type_index,
group_key: k.group_key,
}),
- group: found.remove(&key).map(Into::into),
+ group,
}
})
.collect();
@@ -729,6 +775,7 @@ impl PersonHogReplica for PersonHogReplicaService {
) -> Result<Response<ListGroupsResponse>, Status> {
let req = request.into_inner();
let consistency = to_storage_consistency(&req.read_options);
+ let include_props = group_needs_properties(&req.read_options);
let limit = if req.limit <= 0 || req.limit > MAX_LIST_GROUPS_LIMIT {
MAX_LIST_GROUPS_LIMIT
@@ -753,12 +800,19 @@ impl PersonHogReplica for PersonHogReplicaService {
req.cursor_id,
limit,
consistency,
+ include_props,
)
.await
.map_err(|e| log_and_convert_error(e, "list_groups"))?;
+ let mask = build_field_mask(&req.read_options);
+ let mut proto_groups: Vec<_> = groups.into_iter().map(Into::into).collect();
+ for g in &mut proto_groups {
+ apply_group_field_mask(g, &mask);
+ }
+
Ok(Response::new(ListGroupsResponse {
- groups: groups.into_iter().map(Into::into).collect(),
+ groups: proto_groups,
has_more,
}))
}
diff --git a/rust/personhog-replica/src/service/tests/field_mask.rs b/rust/personhog-replica/src/service/tests/field_mask.rs
new file mode 100644
index 000000000000..d72e325bf151
--- /dev/null
+++ b/rust/personhog-replica/src/service/tests/field_mask.rs
@@ -0,0 +1,547 @@
+use std::sync::Arc;
+
+use personhog_proto::personhog::replica::v1::person_hog_replica_server::PersonHogReplica;
+use personhog_proto::personhog::types::v1::{
+ GetGroupsBatchRequest, GetGroupsRequest, GetPersonsByDistinctIdsInTeamRequest,
+ GetPersonsByDistinctIdsRequest, GetPersonsByUuidsRequest, GetPersonsRequest, GroupIdentifier,
+ GroupKey, ListGroupsRequest, ReadOptions, TeamDistinctId,
+};
+use rstest::rstest;
+use tonic::Request;
+
+use super::super::PersonHogReplicaService;
+use super::mocks::PopulatedStorage;
+
+fn read_options_with_mask(fields: &[&str]) -> Option<ReadOptions> {
+ Some(ReadOptions {
+ field_mask: fields.iter().map(|s| s.to_string()).collect(),
+ ..Default::default()
+ })
+}
+
+// ============================================================
+// get_persons field mask tests
+// ============================================================
+
+#[rstest]
+#[case::no_read_options(None)]
+#[tokio::test]
+async fn get_persons_without_field_mask_returns_all_person_fields_populated(
+ #[case] read_options: Option<ReadOptions>,
+) {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_persons(Request::new(GetPersonsRequest {
+ team_id: 1,
+ person_ids: vec![42],
+ read_options,
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.persons.len(), 1);
+ let person = &response.persons[0];
+ assert_ne!(person.id, 0, "id should be populated");
+ assert!(!person.uuid.is_empty(), "uuid should be populated");
+ assert_ne!(person.team_id, 0, "team_id should be populated");
+ assert!(
+ !person.properties.is_empty(),
+ "properties should be populated"
+ );
+ assert!(
+ !person.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be populated"
+ );
+ assert!(
+ !person.properties_last_operation.is_empty(),
+ "properties_last_operation should be populated"
+ );
+ assert_ne!(person.created_at, 0, "created_at should be populated");
+ assert_ne!(person.version, 0, "version should be populated");
+ assert!(person.is_identified, "is_identified should be populated");
+ assert!(
+ person.is_user_id.is_some(),
+ "is_user_id should be populated"
+ );
+ assert!(
+ person.last_seen_at.is_some(),
+ "last_seen_at should be populated"
+ );
+}
+
+#[rstest]
+#[case::id_and_uuid(&["id", "uuid"])]
+#[tokio::test]
+async fn get_persons_with_id_and_uuid_mask_returns_only_those_fields(#[case] mask_fields: &[&str]) {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_persons(Request::new(GetPersonsRequest {
+ team_id: 1,
+ person_ids: vec![42],
+ read_options: read_options_with_mask(mask_fields),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.persons.len(), 1);
+ let person = &response.persons[0];
+ assert_ne!(person.id, 0, "id should be preserved");
+ assert!(!person.uuid.is_empty(), "uuid should be preserved");
+ assert_eq!(person.team_id, 0, "team_id should be zeroed");
+ assert!(person.properties.is_empty(), "properties should be zeroed");
+ assert!(
+ person.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ person.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(person.created_at, 0, "created_at should be zeroed");
+ assert_eq!(person.version, 0, "version should be zeroed");
+ assert!(!person.is_identified, "is_identified should be zeroed");
+ assert!(person.is_user_id.is_none(), "is_user_id should be zeroed");
+ assert!(
+ person.last_seen_at.is_none(),
+ "last_seen_at should be zeroed"
+ );
+}
+
+#[rstest]
+#[case::properties_only(&["properties"])]
+#[tokio::test]
+async fn get_persons_with_properties_mask_returns_only_properties(#[case] mask_fields: &[&str]) {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_persons(Request::new(GetPersonsRequest {
+ team_id: 1,
+ person_ids: vec![42],
+ read_options: read_options_with_mask(mask_fields),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.persons.len(), 1);
+ let person = &response.persons[0];
+ assert!(
+ !person.properties.is_empty(),
+ "properties should be preserved"
+ );
+ assert_eq!(person.id, 0, "id should be zeroed");
+ assert!(person.uuid.is_empty(), "uuid should be zeroed");
+ assert_eq!(person.team_id, 0, "team_id should be zeroed");
+ assert_eq!(person.created_at, 0, "created_at should be zeroed");
+ assert_eq!(person.version, 0, "version should be zeroed");
+ assert!(!person.is_identified, "is_identified should be zeroed");
+ assert!(person.is_user_id.is_none(), "is_user_id should be zeroed");
+ assert!(
+ person.last_seen_at.is_none(),
+ "last_seen_at should be zeroed"
+ );
+}
+
+#[rstest]
+#[case::non_property_fields(&["id", "team_id", "created_at", "version", "is_identified", "is_user_id", "last_seen_at"])]
+#[tokio::test]
+async fn get_persons_with_non_property_mask_zeros_property_fields(#[case] mask_fields: &[&str]) {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_persons(Request::new(GetPersonsRequest {
+ team_id: 1,
+ person_ids: vec![42],
+ read_options: read_options_with_mask(mask_fields),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.persons.len(), 1);
+ let person = &response.persons[0];
+ assert_ne!(person.id, 0, "id should be preserved");
+ assert_ne!(person.team_id, 0, "team_id should be preserved");
+ assert_ne!(person.created_at, 0, "created_at should be preserved");
+ assert_ne!(person.version, 0, "version should be preserved");
+ assert!(person.is_identified, "is_identified should be preserved");
+ assert!(
+ person.is_user_id.is_some(),
+ "is_user_id should be preserved"
+ );
+ assert!(
+ person.last_seen_at.is_some(),
+ "last_seen_at should be preserved"
+ );
+ assert!(person.uuid.is_empty(), "uuid should be zeroed");
+ assert!(person.properties.is_empty(), "properties should be zeroed");
+ assert!(
+ person.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ person.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+}
+
+// ============================================================
+// get_persons_by_uuids field mask tests
+// ============================================================
+
+#[tokio::test]
+async fn get_persons_by_uuids_with_id_and_uuid_mask_applies_masking() {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_persons_by_uuids(Request::new(GetPersonsByUuidsRequest {
+ team_id: 1,
+ uuids: vec!["00000000-0000-0000-0000-000000000042".to_string()],
+ read_options: read_options_with_mask(&["id", "uuid"]),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.persons.len(), 1);
+ let person = &response.persons[0];
+ assert_ne!(person.id, 0, "id should be preserved");
+ assert!(!person.uuid.is_empty(), "uuid should be preserved");
+ assert_eq!(person.team_id, 0, "team_id should be zeroed");
+ assert!(person.properties.is_empty(), "properties should be zeroed");
+ assert_eq!(person.created_at, 0, "created_at should be zeroed");
+ assert_eq!(person.version, 0, "version should be zeroed");
+ assert!(!person.is_identified, "is_identified should be zeroed");
+ assert!(person.is_user_id.is_none(), "is_user_id should be zeroed");
+ assert!(
+ person.last_seen_at.is_none(),
+ "last_seen_at should be zeroed"
+ );
+}
+
+// ============================================================
+// get_persons_by_distinct_ids_in_team field mask tests
+// ============================================================
+
+#[tokio::test]
+async fn get_persons_by_distinct_ids_in_team_with_id_mask_returns_only_id() {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_persons_by_distinct_ids_in_team(Request::new(GetPersonsByDistinctIdsInTeamRequest {
+ team_id: 1,
+ distinct_ids: vec!["user-1".to_string()],
+ read_options: read_options_with_mask(&["id"]),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.results.len(), 1);
+ let person = response.results[0]
+ .person
+ .as_ref()
+ .expect("person should be present");
+ assert_ne!(person.id, 0, "id should be preserved");
+ assert!(person.uuid.is_empty(), "uuid should be zeroed");
+ assert_eq!(person.team_id, 0, "team_id should be zeroed");
+ assert!(person.properties.is_empty(), "properties should be zeroed");
+ assert!(
+ person.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ person.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(person.created_at, 0, "created_at should be zeroed");
+ assert_eq!(person.version, 0, "version should be zeroed");
+ assert!(!person.is_identified, "is_identified should be zeroed");
+ assert!(person.is_user_id.is_none(), "is_user_id should be zeroed");
+ assert!(
+ person.last_seen_at.is_none(),
+ "last_seen_at should be zeroed"
+ );
+}
+
+// ============================================================
+// get_persons_by_distinct_ids_cross_team field mask tests
+// ============================================================
+
+#[tokio::test]
+async fn get_persons_by_distinct_ids_cross_team_with_id_mask_returns_only_id() {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_persons_by_distinct_ids(Request::new(GetPersonsByDistinctIdsRequest {
+ team_distinct_ids: vec![TeamDistinctId {
+ team_id: 1,
+ distinct_id: "user-1".to_string(),
+ }],
+ read_options: read_options_with_mask(&["id"]),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.results.len(), 1);
+ let person = response.results[0]
+ .person
+ .as_ref()
+ .expect("person should be present");
+ assert_ne!(person.id, 0, "id should be preserved");
+ assert!(person.uuid.is_empty(), "uuid should be zeroed");
+ assert_eq!(person.team_id, 0, "team_id should be zeroed");
+ assert!(person.properties.is_empty(), "properties should be zeroed");
+ assert!(
+ person.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ person.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(person.created_at, 0, "created_at should be zeroed");
+ assert_eq!(person.version, 0, "version should be zeroed");
+ assert!(!person.is_identified, "is_identified should be zeroed");
+ assert!(person.is_user_id.is_none(), "is_user_id should be zeroed");
+ assert!(
+ person.last_seen_at.is_none(),
+ "last_seen_at should be zeroed"
+ );
+}
+
+// ============================================================
+// get_groups field mask tests
+// ============================================================
+
+#[rstest]
+#[case::no_read_options(None)]
+#[tokio::test]
+async fn get_groups_without_field_mask_returns_all_group_fields_populated(
+ #[case] read_options: Option<ReadOptions>,
+) {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_groups(Request::new(GetGroupsRequest {
+ team_id: 1,
+ group_identifiers: vec![GroupIdentifier {
+ group_type_index: 0,
+ group_key: "org-1".to_string(),
+ }],
+ read_options,
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.groups.len(), 1);
+ let group = &response.groups[0];
+ assert_ne!(group.id, 0, "id should be populated");
+ assert_ne!(group.team_id, 0, "team_id should be populated");
+ assert!(!group.group_key.is_empty(), "group_key should be populated");
+ assert!(
+ !group.group_properties.is_empty(),
+ "group_properties should be populated"
+ );
+ assert!(
+ !group.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be populated"
+ );
+ assert!(
+ !group.properties_last_operation.is_empty(),
+ "properties_last_operation should be populated"
+ );
+ assert_ne!(group.created_at, 0, "created_at should be populated");
+ assert_ne!(group.version, 0, "version should be populated");
+}
+
+#[rstest]
+#[case::id_and_group_key(&["id", "group_key"])]
+#[tokio::test]
+async fn get_groups_with_id_and_group_key_mask_returns_only_those_fields(
+ #[case] mask_fields: &[&str],
+) {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_groups(Request::new(GetGroupsRequest {
+ team_id: 1,
+ group_identifiers: vec![GroupIdentifier {
+ group_type_index: 0,
+ group_key: "org-1".to_string(),
+ }],
+ read_options: read_options_with_mask(mask_fields),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.groups.len(), 1);
+ let group = &response.groups[0];
+ assert_ne!(group.id, 0, "id should be preserved");
+ assert!(!group.group_key.is_empty(), "group_key should be preserved");
+ assert_eq!(group.team_id, 0, "team_id should be zeroed");
+ assert_eq!(
+ group.group_type_index, 0,
+ "group_type_index should be zeroed"
+ );
+ assert!(
+ group.group_properties.is_empty(),
+ "group_properties should be zeroed"
+ );
+ assert!(
+ group.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ group.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(group.created_at, 0, "created_at should be zeroed");
+ assert_eq!(group.version, 0, "version should be zeroed");
+}
+
+#[rstest]
+#[case::group_properties_only(&["group_properties"])]
+#[tokio::test]
+async fn get_groups_with_group_properties_mask_returns_only_group_properties(
+ #[case] mask_fields: &[&str],
+) {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_groups(Request::new(GetGroupsRequest {
+ team_id: 1,
+ group_identifiers: vec![GroupIdentifier {
+ group_type_index: 0,
+ group_key: "org-1".to_string(),
+ }],
+ read_options: read_options_with_mask(mask_fields),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.groups.len(), 1);
+ let group = &response.groups[0];
+ assert!(
+ !group.group_properties.is_empty(),
+ "group_properties should be preserved"
+ );
+ assert_eq!(group.id, 0, "id should be zeroed");
+ assert_eq!(group.team_id, 0, "team_id should be zeroed");
+ assert_eq!(
+ group.group_type_index, 0,
+ "group_type_index should be zeroed"
+ );
+ assert!(group.group_key.is_empty(), "group_key should be zeroed");
+ assert!(
+ group.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ group.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(group.created_at, 0, "created_at should be zeroed");
+ assert_eq!(group.version, 0, "version should be zeroed");
+}
+
+// ============================================================
+// get_groups_batch field mask tests
+// ============================================================
+
+#[tokio::test]
+async fn get_groups_batch_with_id_and_group_key_mask_applies_masking() {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .get_groups_batch(Request::new(GetGroupsBatchRequest {
+ keys: vec![GroupKey {
+ team_id: 1,
+ group_type_index: 0,
+ group_key: "org-1".to_string(),
+ }],
+ read_options: read_options_with_mask(&["id", "group_key"]),
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.results.len(), 1);
+ let group = response.results[0]
+ .group
+ .as_ref()
+ .expect("group should be present");
+ assert_ne!(group.id, 0, "id should be preserved");
+ assert!(!group.group_key.is_empty(), "group_key should be preserved");
+ assert_eq!(group.team_id, 0, "team_id should be zeroed");
+ assert_eq!(
+ group.group_type_index, 0,
+ "group_type_index should be zeroed"
+ );
+ assert!(
+ group.group_properties.is_empty(),
+ "group_properties should be zeroed"
+ );
+ assert!(
+ group.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ group.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(group.created_at, 0, "created_at should be zeroed");
+ assert_eq!(group.version, 0, "version should be zeroed");
+}
+
+// ============================================================
+// list_groups field mask tests
+// ============================================================
+
+#[tokio::test]
+async fn list_groups_with_id_and_team_id_mask_applies_masking() {
+ let service = PersonHogReplicaService::new(Arc::new(PopulatedStorage));
+
+ let response = service
+ .list_groups(Request::new(ListGroupsRequest {
+ team_id: 1,
+ group_type_index: 0,
+ read_options: read_options_with_mask(&["id", "team_id"]),
+ ..Default::default()
+ }))
+ .await
+ .unwrap()
+ .into_inner();
+
+ assert_eq!(response.groups.len(), 1);
+ let group = &response.groups[0];
+ assert_ne!(group.id, 0, "id should be preserved");
+ assert_ne!(group.team_id, 0, "team_id should be preserved");
+ assert_eq!(
+ group.group_type_index, 0,
+ "group_type_index should be zeroed"
+ );
+ assert!(group.group_key.is_empty(), "group_key should be zeroed");
+ assert!(
+ group.group_properties.is_empty(),
+ "group_properties should be zeroed"
+ );
+ assert!(
+ group.properties_last_updated_at.is_empty(),
+ "properties_last_updated_at should be zeroed"
+ );
+ assert!(
+ group.properties_last_operation.is_empty(),
+ "properties_last_operation should be zeroed"
+ );
+ assert_eq!(group.created_at, 0, "created_at should be zeroed");
+ assert_eq!(group.version, 0, "version should be zeroed");
+}
diff --git a/rust/personhog-replica/src/service/tests/mocks.rs b/rust/personhog-replica/src/service/tests/mocks.rs
index cc6620cf8602..db9c83ae82ba 100644
--- a/rust/personhog-replica/src/service/tests/mocks.rs
+++ b/rust/personhog-replica/src/service/tests/mocks.rs
@@ -52,6 +52,7 @@ impl storage::PersonLookup for FailingStorage {
&self,
_team_id: i64,
_person_ids: &[i64],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Person>> {
Err(self.error.clone())
}
@@ -60,6 +61,7 @@ impl storage::PersonLookup for FailingStorage {
&self,
_team_id: i64,
_uuids: &[Uuid],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Person>> {
Err(self.error.clone())
}
@@ -76,6 +78,7 @@ impl storage::PersonLookup for FailingStorage {
&self,
_team_id: i64,
_distinct_ids: &[String],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<(String, Option<storage::Person>)>> {
Err(self.error.clone())
}
@@ -83,6 +86,7 @@ impl storage::PersonLookup for FailingStorage {
async fn get_persons_by_distinct_ids_cross_team(
&self,
_team_distinct_ids: &[(i64, String)],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<((i64, String), Option<storage::Person>)>> {
Err(self.error.clone())
}
@@ -225,6 +229,7 @@ impl storage::GroupStorage for FailingStorage {
_team_id: i64,
_identifiers: &[storage::GroupIdentifier],
_consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Group>> {
Err(self.error.clone())
}
@@ -233,6 +238,7 @@ impl storage::GroupStorage for FailingStorage {
&self,
_keys: &[storage::GroupKey],
_consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<Vec<(storage::GroupKey, storage::Group)>> {
Err(self.error.clone())
}
@@ -247,6 +253,7 @@ impl storage::GroupStorage for FailingStorage {
_cursor_id: i64,
_limit: i32,
_consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<(Vec<storage::Group>, bool)> {
Err(self.error.clone())
}
@@ -380,6 +387,7 @@ impl storage::PersonLookup for SuccessStorage {
&self,
_team_id: i64,
_person_ids: &[i64],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Person>> {
Ok(Vec::new())
}
@@ -388,6 +396,7 @@ impl storage::PersonLookup for SuccessStorage {
&self,
_team_id: i64,
_uuids: &[Uuid],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Person>> {
Ok(Vec::new())
}
@@ -404,6 +413,7 @@ impl storage::PersonLookup for SuccessStorage {
&self,
_team_id: i64,
distinct_ids: &[String],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<(String, Option<storage::Person>)>> {
Ok(distinct_ids.iter().map(|d| (d.clone(), None)).collect())
}
@@ -411,6 +421,7 @@ impl storage::PersonLookup for SuccessStorage {
async fn get_persons_by_distinct_ids_cross_team(
&self,
team_distinct_ids: &[(i64, String)],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<((i64, String), Option<storage::Person>)>> {
Ok(team_distinct_ids
.iter()
@@ -562,6 +573,7 @@ impl storage::GroupStorage for SuccessStorage {
_team_id: i64,
_identifiers: &[storage::GroupIdentifier],
_consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Group>> {
Ok(Vec::new())
}
@@ -570,6 +582,7 @@ impl storage::GroupStorage for SuccessStorage {
&self,
_keys: &[storage::GroupKey],
_consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<Vec<(storage::GroupKey, storage::Group)>> {
Ok(Vec::new())
}
@@ -584,6 +597,7 @@ impl storage::GroupStorage for SuccessStorage {
_cursor_id: i64,
_limit: i32,
_consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<(Vec<storage::Group>, bool)> {
Ok((Vec::new(), false))
}
@@ -633,7 +647,404 @@ impl storage::GroupStorage for SuccessStorage {
team_id,
group_type_index,
group_key: group_key.to_string(),
- group_properties: group_properties.to_string(),
+ group_properties: Some(group_properties.to_string()),
+ created_at,
+ properties_last_updated_at: None,
+ properties_last_operation: None,
+ version: 0,
+ })
+ }
+
+ async fn update_group(
+ &self,
+ _team_id: i64,
+ _group_type_index: i32,
+ _group_key: &str,
+ _update_mask: &[String],
+ _group_properties: Option<&serde_json::Value>,
+ _properties_last_updated_at: Option<&serde_json::Value>,
+ _properties_last_operation: Option<&serde_json::Value>,
+ _created_at: Option<chrono::DateTime<chrono::Utc>>,
+ ) -> storage::StorageResult<Option<storage::Group>> {
+ Ok(None)
+ }
+
+ async fn delete_groups_batch_for_team(
+ &self,
+ _team_id: i64,
+ _batch_size: i64,
+ ) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+
+ async fn get_group_type_mapping_by_dashboard_id(
+ &self,
+ _team_id: i64,
+ _dashboard_id: i64,
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Option<storage::GroupTypeMapping>> {
+ Ok(None)
+ }
+
+ async fn update_group_type_mapping(
+ &self,
+ _project_id: i64,
+ _group_type_index: i32,
+ _update_mask: &[String],
+ _name_singular: Option<&str>,
+ _name_plural: Option<&str>,
+ _detail_dashboard_id: Option<i64>,
+ _default_columns: Option<&[String]>,
+ ) -> storage::StorageResult<Option<storage::GroupTypeMapping>> {
+ Ok(None)
+ }
+
+ async fn delete_group_type_mapping(
+ &self,
+ _project_id: i64,
+ _group_type_index: i32,
+ ) -> storage::StorageResult<bool> {
+ Ok(false)
+ }
+
+ async fn delete_group_type_mappings_batch_for_team(
+ &self,
+ _team_id: i64,
+ _batch_size: i64,
+ ) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+}
+
+/// Mock storage that returns pre-populated person and group data for field mask testing.
+pub struct PopulatedStorage;
+
+impl PopulatedStorage {
+ pub fn person() -> storage::Person {
+ storage::Person {
+ id: 42,
+ uuid: uuid::Uuid::parse_str("00000000-0000-0000-0000-000000000042").unwrap(),
+ team_id: 1,
+ properties: Some(r#"{"key":"value"}"#.to_string()),
+ properties_last_updated_at: Some(r#"{"key":"2024-01-01"}"#.to_string()),
+ properties_last_operation: Some(r#"{"key":"set"}"#.to_string()),
+ created_at: chrono::DateTime::parse_from_rfc3339("2024-06-15T12:00:00Z")
+ .unwrap()
+ .with_timezone(&chrono::Utc),
+ version: Some(5),
+ is_identified: true,
+ is_user_id: Some(true),
+ last_seen_at: Some(
+ chrono::DateTime::parse_from_rfc3339("2024-06-15T12:00:00Z")
+ .unwrap()
+ .with_timezone(&chrono::Utc),
+ ),
+ }
+ }
+
+ pub fn group() -> storage::Group {
+ storage::Group {
+ id: 100,
+ team_id: 1,
+ group_type_index: 0,
+ group_key: "org-1".to_string(),
+ group_properties: Some(r#"{"name":"Acme"}"#.to_string()),
+ created_at: chrono::DateTime::parse_from_rfc3339("2024-06-15T12:00:00Z")
+ .unwrap()
+ .with_timezone(&chrono::Utc),
+ properties_last_updated_at: Some(r#"{"name":"2024-01-01"}"#.to_string()),
+ properties_last_operation: Some(r#"{"name":"set"}"#.to_string()),
+ version: 3,
+ }
+ }
+}
+
+#[async_trait]
+impl storage::PersonLookup for PopulatedStorage {
+ async fn get_person_by_id(
+ &self,
+ _team_id: i64,
+ _person_id: i64,
+ ) -> storage::StorageResult<Option<storage::Person>> {
+ Ok(Some(Self::person()))
+ }
+
+ async fn get_person_by_uuid(
+ &self,
+ _team_id: i64,
+ _uuid: Uuid,
+ ) -> storage::StorageResult<Option<storage::Person>> {
+ Ok(Some(Self::person()))
+ }
+
+ async fn get_persons_by_ids(
+ &self,
+ _team_id: i64,
+ _person_ids: &[i64],
+ _include_properties: bool,
+ ) -> storage::StorageResult<Vec<storage::Person>> {
+ Ok(vec![Self::person()])
+ }
+
+ async fn get_persons_by_uuids(
+ &self,
+ _team_id: i64,
+ _uuids: &[Uuid],
+ _include_properties: bool,
+ ) -> storage::StorageResult<Vec<storage::Person>> {
+ Ok(vec![Self::person()])
+ }
+
+ async fn get_person_by_distinct_id(
+ &self,
+ _team_id: i64,
+ _distinct_id: &str,
+ ) -> storage::StorageResult<Option<storage::Person>> {
+ Ok(Some(Self::person()))
+ }
+
+ async fn get_persons_by_distinct_ids_in_team(
+ &self,
+ _team_id: i64,
+ distinct_ids: &[String],
+ _include_properties: bool,
+ ) -> storage::StorageResult<Vec<(String, Option<storage::Person>)>> {
+ Ok(distinct_ids
+ .iter()
+ .map(|d| (d.clone(), Some(Self::person())))
+ .collect())
+ }
+
+ async fn get_persons_by_distinct_ids_cross_team(
+ &self,
+ team_distinct_ids: &[(i64, String)],
+ _include_properties: bool,
+ ) -> storage::StorageResult<Vec<((i64, String), Option<storage::Person>)>> {
+ Ok(team_distinct_ids
+ .iter()
+ .map(|(t, d)| ((*t, d.clone()), Some(Self::person())))
+ .collect())
+ }
+
+ async fn delete_persons(&self, _team_id: i64, _uuids: &[Uuid]) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+
+ async fn delete_persons_batch_for_team(
+ &self,
+ _team_id: i64,
+ _batch_size: i64,
+ ) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+}
+
+#[async_trait]
+impl storage::DistinctIdLookup for PopulatedStorage {
+ async fn get_distinct_ids_for_person(
+ &self,
+ _team_id: i64,
+ _person_id: i64,
+ _consistency: storage::postgres::ConsistencyLevel,
+ _limit: Option<i64>,
+ ) -> storage::StorageResult<Vec<storage::DistinctIdWithVersion>> {
+ Ok(Vec::new())
+ }
+
+ async fn get_distinct_ids_for_persons(
+ &self,
+ _team_id: i64,
+ _person_ids: &[i64],
+ _consistency: storage::postgres::ConsistencyLevel,
+ _limit_per_person: Option<i64>,
+ ) -> storage::StorageResult<Vec<storage::DistinctIdMapping>> {
+ Ok(Vec::new())
+ }
+}
+
+#[async_trait]
+impl storage::FeatureFlagStorage for PopulatedStorage {
+ async fn get_hash_key_override_context(
+ &self,
+ _team_id: i64,
+ _distinct_ids: &[String],
+ _check_person_exists: bool,
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Vec<storage::HashKeyOverrideContext>> {
+ Ok(Vec::new())
+ }
+
+ async fn upsert_hash_key_overrides(
+ &self,
+ _team_id: i64,
+ _distinct_ids: &[String],
+ _feature_flag_keys: &[String],
+ _hash_key: &str,
+ ) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+
+ async fn delete_hash_key_overrides_by_teams(
+ &self,
+ _team_ids: &[i64],
+ ) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+}
+
+#[async_trait]
+impl storage::CohortStorage for PopulatedStorage {
+ async fn check_cohort_membership(
+ &self,
+ _person_id: i64,
+ cohort_ids: &[i64],
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Vec<storage::CohortMembership>> {
+ Ok(cohort_ids
+ .iter()
+ .map(|&id| storage::CohortMembership {
+ cohort_id: id,
+ is_member: false,
+ })
+ .collect())
+ }
+
+ async fn count_cohort_members(
+ &self,
+ _cohort_ids: &[i64],
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+
+ async fn delete_cohort_member(
+ &self,
+ _cohort_id: i64,
+ _person_id: i64,
+ ) -> storage::StorageResult<bool> {
+ Ok(false)
+ }
+
+ async fn delete_cohort_members_bulk(
+ &self,
+ _cohort_ids: &[i64],
+ _batch_size: i32,
+ ) -> storage::StorageResult<i64> {
+ Ok(0)
+ }
+
+ async fn insert_cohort_members(
+ &self,
+ _cohort_id: i64,
+ person_ids: &[i64],
+ _version: Option<i32>,
+ ) -> storage::StorageResult<i64> {
+ Ok(person_ids.len() as i64)
+ }
+
+ async fn list_cohort_member_ids(
+ &self,
+ _cohort_id: i64,
+ _cursor: i64,
+ _limit: i32,
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<(Vec<i64>, Option<i64>)> {
+ Ok((Vec::new(), None))
+ }
+}
+
+#[async_trait]
+impl storage::GroupStorage for PopulatedStorage {
+ async fn get_group(
+ &self,
+ _team_id: i64,
+ _group_type_index: i32,
+ _group_key: &str,
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Option<storage::Group>> {
+ Ok(Some(Self::group()))
+ }
+
+ async fn get_groups(
+ &self,
+ _team_id: i64,
+ _identifiers: &[storage::GroupIdentifier],
+ _consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
+ ) -> storage::StorageResult<Vec<storage::Group>> {
+ Ok(vec![Self::group()])
+ }
+
+ async fn get_groups_batch(
+ &self,
+ keys: &[storage::GroupKey],
+ _consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
+ ) -> storage::StorageResult<Vec<(storage::GroupKey, storage::Group)>> {
+ Ok(keys.iter().map(|k| (k.clone(), Self::group())).collect())
+ }
+
+ async fn list_groups(
+ &self,
+ _team_id: i64,
+ _group_type_index: i32,
+ _group_key_contains: &str,
+ _search: &str,
+ _cursor_created_at: Option<chrono::DateTime<chrono::Utc>>,
+ _cursor_id: i64,
+ _limit: i32,
+ _consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
+ ) -> storage::StorageResult<(Vec<storage::Group>, bool)> {
+ Ok((vec![Self::group()], false))
+ }
+
+ async fn get_group_type_mappings_by_team_id(
+ &self,
+ _team_id: i64,
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Vec<storage::GroupTypeMapping>> {
+ Ok(Vec::new())
+ }
+
+ async fn get_group_type_mappings_by_team_ids(
+ &self,
+ _team_ids: &[i64],
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Vec<storage::GroupTypeMapping>> {
+ Ok(Vec::new())
+ }
+
+ async fn get_group_type_mappings_by_project_id(
+ &self,
+ _project_id: i64,
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Vec<storage::GroupTypeMapping>> {
+ Ok(Vec::new())
+ }
+
+ async fn get_group_type_mappings_by_project_ids(
+ &self,
+ _project_ids: &[i64],
+ _consistency: storage::postgres::ConsistencyLevel,
+ ) -> storage::StorageResult<Vec<storage::GroupTypeMapping>> {
+ Ok(Vec::new())
+ }
+
+ async fn create_group(
+ &self,
+ team_id: i64,
+ group_type_index: i32,
+ group_key: &str,
+ group_properties: &serde_json::Value,
+ created_at: chrono::DateTime<chrono::Utc>,
+ ) -> storage::StorageResult<storage::Group> {
+ Ok(storage::Group {
+ id: 1,
+ team_id,
+ group_type_index,
+ group_key: group_key.to_string(),
+ group_properties: Some(group_properties.to_string()),
created_at,
properties_last_updated_at: None,
properties_last_operation: None,
@@ -746,6 +1157,7 @@ impl storage::PersonLookup for ConsistencyTrackingStorage {
&self,
_team_id: i64,
_person_ids: &[i64],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Person>> {
Ok(Vec::new())
}
@@ -754,6 +1166,7 @@ impl storage::PersonLookup for ConsistencyTrackingStorage {
&self,
_team_id: i64,
_uuids: &[Uuid],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Person>> {
Ok(Vec::new())
}
@@ -770,6 +1183,7 @@ impl storage::PersonLookup for ConsistencyTrackingStorage {
&self,
_team_id: i64,
distinct_ids: &[String],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<(String, Option<storage::Person>)>> {
Ok(distinct_ids.iter().map(|d| (d.clone(), None)).collect())
}
@@ -777,6 +1191,7 @@ impl storage::PersonLookup for ConsistencyTrackingStorage {
async fn get_persons_by_distinct_ids_cross_team(
&self,
team_distinct_ids: &[(i64, String)],
+ _include_properties: bool,
) -> storage::StorageResult<Vec<((i64, String), Option<storage::Person>)>> {
Ok(team_distinct_ids
.iter()
@@ -935,6 +1350,7 @@ impl storage::GroupStorage for ConsistencyTrackingStorage {
_team_id: i64,
_identifiers: &[storage::GroupIdentifier],
consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<Vec<storage::Group>> {
self.record(consistency);
Ok(Vec::new())
@@ -944,6 +1360,7 @@ impl storage::GroupStorage for ConsistencyTrackingStorage {
&self,
_keys: &[storage::GroupKey],
consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<Vec<(storage::GroupKey, storage::Group)>> {
self.record(consistency);
Ok(Vec::new())
@@ -995,6 +1412,7 @@ impl storage::GroupStorage for ConsistencyTrackingStorage {
_cursor_id: i64,
_limit: i32,
consistency: storage::postgres::ConsistencyLevel,
+ _include_properties: bool,
) -> storage::StorageResult<(Vec<storage::Group>, bool)> {
self.record(consistency);
Ok((Vec::new(), false))
@@ -1013,7 +1431,7 @@ impl storage::GroupStorage for ConsistencyTrackingStorage {
team_id,
group_type_index,
group_key: group_key.to_string(),
- group_properties: group_properties.to_string(),
+ group_properties: Some(group_properties.to_string()),
created_at,
properties_last_updated_at: None,
properties_last_operation: None,
diff --git a/rust/personhog-replica/src/service/tests/mod.rs b/rust/personhog-replica/src/service/tests/mod.rs
index 2ded607a0db0..89c5d001dbdf 100644
--- a/rust/personhog-replica/src/service/tests/mod.rs
+++ b/rust/personhog-replica/src/service/tests/mod.rs
@@ -1,3 +1,4 @@
+mod field_mask;
mod mocks;
mod routing;
diff --git a/rust/personhog-replica/src/service/tests/routing.rs b/rust/personhog-replica/src/service/tests/routing.rs
index 76fc381f607d..e433dd32577e 100644
--- a/rust/personhog-replica/src/service/tests/routing.rs
+++ b/rust/personhog-replica/src/service/tests/routing.rs
@@ -43,12 +43,14 @@ use crate::storage;
fn strong_consistency() -> Option<personhog_proto::personhog::types::v1::ReadOptions> {
Some(personhog_proto::personhog::types::v1::ReadOptions {
consistency: personhog_proto::personhog::types::v1::ConsistencyLevel::Strong.into(),
+ ..Default::default()
})
}
fn eventual_consistency() -> Option<personhog_proto::personhog::types::v1::ReadOptions> {
Some(personhog_proto::personhog::types::v1::ReadOptions {
consistency: personhog_proto::personhog::types::v1::ConsistencyLevel::Eventual.into(),
+ ..Default::default()
})
}
diff --git a/rust/personhog-replica/src/service/types/group.rs b/rust/personhog-replica/src/service/types/group.rs
index b40b0849ff2b..cdcaca668508 100644
--- a/rust/personhog-replica/src/service/types/group.rs
+++ b/rust/personhog-replica/src/service/types/group.rs
@@ -9,7 +9,10 @@ impl From<storage::Group> for Group {
team_id: group.team_id,
group_type_index: group.group_type_index,
group_key: group.group_key,
- group_properties: group.group_properties.into_bytes(),
+ group_properties: group
+ .group_properties
+ .map(|v| v.into_bytes())
+ .unwrap_or_default(),
created_at: group.created_at.timestamp_millis(),
properties_last_updated_at: group
.properties_last_updated_at
diff --git a/rust/personhog-replica/src/service/types/person.rs b/rust/personhog-replica/src/service/types/person.rs
index 6a7575cb2b54..99318a2a158a 100644
--- a/rust/personhog-replica/src/service/types/person.rs
+++ b/rust/personhog-replica/src/service/types/person.rs
@@ -8,7 +8,10 @@ impl From<storage::Person> for Person {
id: person.id,
uuid: person.uuid.to_string(),
team_id: person.team_id,
- properties: person.properties.into_bytes(),
+ properties: person
+ .properties
+ .map(|v| v.into_bytes())
+ .unwrap_or_default(),
properties_last_updated_at: person
.properties_last_updated_at
.map(|v| v.into_bytes())
diff --git a/rust/personhog-replica/src/storage/postgres/group.rs b/rust/personhog-replica/src/storage/postgres/group.rs
index 23ee78a957e3..9fdda6fe1bf7 100644
--- a/rust/personhog-replica/src/storage/postgres/group.rs
+++ b/rust/personhog-replica/src/storage/postgres/group.rs
@@ -33,7 +33,7 @@ impl GroupStorage for PostgresStorage {
Group,
r#"
SELECT id::bigint as "id!", team_id::bigint as "team_id!",
- group_type_index, group_key, group_properties::text as "group_properties!",
+ group_type_index, group_key, group_properties::text as "group_properties?",
created_at,
properties_last_updated_at::text as "properties_last_updated_at?",
properties_last_operation::text as "properties_last_operation?",
@@ -56,6 +56,7 @@ impl GroupStorage for PostgresStorage {
team_id: i64,
identifiers: &[GroupIdentifier],
consistency: ConsistencyLevel,
+ include_properties: bool,
) -> StorageResult<Vec<Group>> {
if identifiers.is_empty() {
return Ok(Vec::new());
@@ -80,10 +81,11 @@ impl GroupStorage for PostgresStorage {
Group,
r#"
SELECT g.id::bigint as "id!", g.team_id::bigint as "team_id!",
- g.group_type_index, g.group_key, g.group_properties::text as "group_properties!",
+ g.group_type_index, g.group_key,
+ CASE WHEN $4::boolean THEN g.group_properties::text ELSE NULL END as "group_properties?",
g.created_at,
- g.properties_last_updated_at::text as "properties_last_updated_at?",
- g.properties_last_operation::text as "properties_last_operation?",
+ CASE WHEN $4::boolean THEN g.properties_last_updated_at::text ELSE NULL END as "properties_last_updated_at?",
+ CASE WHEN $4::boolean THEN g.properties_last_operation::text ELSE NULL END as "properties_last_operation?",
g.version
FROM posthog_group g
INNER JOIN UNNEST($2::integer[], $3::text[]) AS t(group_type_index, group_key)
@@ -92,7 +94,8 @@ impl GroupStorage for PostgresStorage {
"#,
team_id as i32,
&group_type_indexes,
- &group_keys
+ &group_keys,
+ include_properties
)
.fetch_all(&mut *conn)
.await?;
@@ -113,6 +116,7 @@ impl GroupStorage for PostgresStorage {
&self,
keys: &[GroupKey],
consistency: ConsistencyLevel,
+ include_properties: bool,
) -> StorageResult<Vec<(GroupKey, Group)>> {
if keys.is_empty() {
return Ok(Vec::new());
@@ -138,10 +142,11 @@ impl GroupStorage for PostgresStorage {
Group,
r#"
SELECT g.id::bigint as "id!", g.team_id::bigint as "team_id!",
- g.group_type_index, g.group_key, g.group_properties::text as "group_properties!",
+ g.group_type_index, g.group_key,
+ CASE WHEN $4::boolean THEN g.group_properties::text ELSE NULL END as "group_properties?",
g.created_at,
- g.properties_last_updated_at::text as "properties_last_updated_at?",
- g.properties_last_operation::text as "properties_last_operation?",
+ CASE WHEN $4::boolean THEN g.properties_last_updated_at::text ELSE NULL END as "properties_last_updated_at?",
+ CASE WHEN $4::boolean THEN g.properties_last_operation::text ELSE NULL END as "properties_last_operation?",
g.version
FROM posthog_group g
INNER JOIN UNNEST($1::integer[], $2::integer[], $3::text[]) AS t(team_id, group_type_index, group_key)
@@ -149,7 +154,8 @@ impl GroupStorage for PostgresStorage {
"#,
&team_ids,
&group_type_indexes,
- &group_keys
+ &group_keys,
+ include_properties
)
.fetch_all(&mut *conn)
.await?;
@@ -443,6 +449,7 @@ impl GroupStorage for PostgresStorage {
cursor_id: i64,
limit: i32,
consistency: ConsistencyLevel,
+ include_properties: bool,
) -> StorageResult<(Vec<Group>, bool)> {
let client = current_client_name();
let pool_label = PostgresStorage::pool_label(consistency);
@@ -475,10 +482,11 @@ impl GroupStorage for PostgresStorage {
Group,
r#"
SELECT id::bigint as "id!", team_id::bigint as "team_id!",
- group_type_index, group_key, group_properties::text as "group_properties!",
+ group_type_index, group_key,
+ CASE WHEN $12::boolean THEN group_properties::text ELSE NULL END as "group_properties?",
created_at,
- properties_last_updated_at::text as "properties_last_updated_at?",
- properties_last_operation::text as "properties_last_operation?",
+ CASE WHEN $12::boolean THEN properties_last_updated_at::text ELSE NULL END as "properties_last_updated_at?",
+ CASE WHEN $12::boolean THEN properties_last_operation::text ELSE NULL END as "properties_last_operation?",
version
FROM posthog_group
WHERE team_id = $1
@@ -500,6 +508,7 @@ impl GroupStorage for PostgresStorage {
cursor_created_at,
cursor_id,
fetch_limit,
+ include_properties,
)
.fetch_all(&mut *conn)
.await?;
@@ -551,7 +560,7 @@ impl GroupStorage for PostgresStorage {
INSERT INTO posthog_group (team_id, group_type_index, group_key, group_properties, created_at, properties_last_updated_at, properties_last_operation, version)
VALUES ($1, $2, $3, $4, $5, '{}'::jsonb, '{}'::jsonb, 0)
RETURNING id::bigint as "id!", team_id::bigint as "team_id!",
- group_type_index, group_key, group_properties::text as "group_properties!",
+ group_type_index, group_key, group_properties::text as "group_properties?",
created_at,
properties_last_updated_at::text as "properties_last_updated_at?",
properties_last_operation::text as "properties_last_operation?",
@@ -604,7 +613,7 @@ impl GroupStorage for PostgresStorage {
version = version + 1
WHERE team_id = $1 AND group_type_index = $2 AND group_key = $3
RETURNING id::bigint as "id!", team_id::bigint as "team_id!",
- group_type_index, group_key, group_properties::text as "group_properties!",
+ group_type_index, group_key, group_properties::text as "group_properties?",
created_at,
properties_last_updated_at::text as "properties_last_updated_at?",
properties_last_operation::text as "properties_last_operation?",
diff --git a/rust/personhog-replica/src/storage/postgres/person.rs b/rust/personhog-replica/src/storage/postgres/person.rs
index 32761b9410b1..08a1b76cea58 100644
--- a/rust/personhog-replica/src/storage/postgres/person.rs
+++ b/rust/personhog-replica/src/storage/postgres/person.rs
@@ -35,7 +35,7 @@ impl PersonLookup for PostgresStorage {
let row = sqlx::query_as!(
Person,
r#"
- SELECT id, uuid, team_id::bigint as "team_id!", properties::text as "properties!",
+ SELECT id, uuid, team_id::bigint as "team_id!", properties::text as "properties?",
properties_last_updated_at::text as "properties_last_updated_at?",
properties_last_operation::text as "properties_last_operation?",
created_at, version, is_identified,
@@ -67,7 +67,7 @@ impl PersonLookup for PostgresStorage {
let row = sqlx::query_as!(
Person,
r#"
- SELECT id, uuid, team_id::bigint as "team_id!", properties::text as "properties!",
+ SELECT id, uuid, team_id::bigint as "team_id!", properties::text as "properties?",
properties_last_updated_at::text as "properties_last_updated_at?",
properties_last_operation::text as "properties_last_operation?",
created_at, version, is_identified,
@@ -89,6 +89,7 @@ impl PersonLookup for PostgresStorage {
&self,
team_id: i64,
person_ids: &[i64],
+ include_properties: bool,
) -> StorageResult<Vec<Person>> {
if person_ids.is_empty() {
return Ok(Vec::new());
@@ -120,9 +121,10 @@ impl PersonLookup for PostgresStorage {
let rows = sqlx::query_as!(
Person,
r#"
- SELECT id, uuid, team_id::bigint as "team_id!", properties::text as "properties!",
- properties_last_updated_at::text as "properties_last_updated_at?",
- properties_last_operation::text as "properties_last_operation?",
+ SELECT id, uuid, team_id::bigint as "team_id!",
+ CASE WHEN $3::boolean THEN properties::text ELSE NULL END as "properties?",
+ CASE WHEN $3::boolean THEN properties_last_updated_at::text ELSE NULL END as "properties_last_updated_at?",
+ CASE WHEN $3::boolean THEN properties_last_operation::text ELSE NULL END as "properties_last_operation?",
created_at, version, is_identified,
CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,
last_seen_at
@@ -130,7 +132,8 @@ impl PersonLookup for PostgresStorage {
WHERE team_id = $1 AND id = ANY($2)
"#,
team_id as i32,
- &chunk
+ &chunk,
+ include_properties
)
.fetch_all(&mut *conn)
.await?;
@@ -158,6 +161,7 @@ impl PersonLookup for PostgresStorage {
&self,
team_id: i64,
uuids: &[Uuid],
+ include_properties: bool,
) -> StorageResult<Vec<Person>> {
if uuids.is_empty() {
return Ok(Vec::new());
@@ -189,9 +193,10 @@ impl PersonLookup for PostgresStorage {
let rows = sqlx::query_as!(
Person,
r#"
- SELECT id, uuid, team_id::bigint as "team_id!", properties::text as "properties!",
- properties_last_updated_at::text as "properties_last_updated_at?",
- properties_last_operation::text as "properties_last_operation?",
+ SELECT id, uuid, team_id::bigint as "team_id!",
+ CASE WHEN $3::boolean THEN properties::text ELSE NULL END as "properties?",
+ CASE WHEN $3::boolean THEN properties_last_updated_at::text ELSE NULL END as "properties_last_updated_at?",
+ CASE WHEN $3::boolean THEN properties_last_operation::text ELSE NULL END as "properties_last_operation?",
created_at, version, is_identified,
CASE WHEN is_user_id IS NULL THEN NULL ELSE (is_user_id != 0) END as is_user_id,
last_seen_at
@@ -199,7 +204,8 @@ impl PersonLookup for PostgresStorage {
WHERE team_id = $1 AND uuid = ANY($2)
"#,
team_id as i32,
- &chunk
+ &chunk,
+ include_properties
)
.fetch_all(&mut *conn)
.await?;
@@ -244,7 +250,7 @@ impl PersonLookup for PostgresStorage {
let row = sqlx::query_as!(
Person,
r#"
- SELECT p.id, p.uuid, p.team_id::bigint as "team_id!", p.properties::text as "properties!",
+ SELECT p.id, p.uuid, p.team_id::bigint as "team_id!", p.properties::text as "properties?",
p.properties_last_updated_at::text as "properties_last_updated_at?",
p.properties_last_operation::text as "properties_last_operation?",
p.created_at, p.version, p.is_identified,
@@ -268,6 +274,7 @@ impl PersonLookup for PostgresStorage {
&self,
team_id: i64,
distinct_ids: &[String],
+ include_properties: bool,
) -> StorageResult<Vec<(String, Option<Person>)>> {
if distinct_ids.is_empty() {
return Ok(Vec::new());
@@ -306,9 +313,9 @@ impl PersonLookup for PostgresStorage {
let rows = sqlx::query!(
r#"
SELECT p.id, p.uuid as "uuid!", p.team_id::bigint as "team_id!",
- p.properties::text as "properties!",
- p.properties_last_updated_at::text as "properties_last_updated_at?",
- p.properties_last_operation::text as "properties_last_operation?",
+ CASE WHEN $3::boolean THEN p.properties::text ELSE NULL END as "properties?",
+ CASE WHEN $3::boolean THEN p.properties_last_updated_at::text ELSE NULL END as "properties_last_updated_at?",
+ CASE WHEN $3::boolean THEN p.properties_last_operation::text ELSE NULL END as "properties_last_operation?",
p.created_at as "created_at!", p.version, p.is_identified as "is_identified!",
CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,
p.last_seen_at,
@@ -318,7 +325,8 @@ impl PersonLookup for PostgresStorage {
WHERE p.team_id = $1 AND d.distinct_id = ANY($2)
"#,
team_id as i32,
- &chunk
+ &chunk,
+ include_properties
)
.fetch_all(&mut *conn)
.await?;
@@ -490,6 +498,7 @@ impl PersonLookup for PostgresStorage {
async fn get_persons_by_distinct_ids_cross_team(
&self,
team_distinct_ids: &[(i64, String)],
+ include_properties: bool,
) -> StorageResult<Vec<((i64, String), Option<Person>)>> {
if team_distinct_ids.is_empty() {
return Ok(Vec::new());
@@ -512,13 +521,12 @@ impl PersonLookup for PostgresStorage {
let team_ids: Vec<i32> = team_distinct_ids.iter().map(|(t, _)| *t as i32).collect();
let distinct_ids: Vec<String> = team_distinct_ids.iter().map(|(_, d)| d.clone()).collect();
- // Use query!() since we need distinct_id alongside Person fields
let rows = sqlx::query!(
r#"
SELECT p.id, p.uuid as "uuid!", p.team_id::bigint as "team_id!",
- p.properties::text as "properties!",
- p.properties_last_updated_at::text as "properties_last_updated_at?",
- p.properties_last_operation::text as "properties_last_operation?",
+ CASE WHEN $3::boolean THEN p.properties::text ELSE NULL END as "properties?",
+ CASE WHEN $3::boolean THEN p.properties_last_updated_at::text ELSE NULL END as "properties_last_updated_at?",
+ CASE WHEN $3::boolean THEN p.properties_last_operation::text ELSE NULL END as "properties_last_operation?",
p.created_at as "created_at!", p.version, p.is_identified as "is_identified!",
CASE WHEN p.is_user_id IS NULL THEN NULL ELSE (p.is_user_id != 0) END as is_user_id,
p.last_seen_at,
@@ -529,7 +537,8 @@ impl PersonLookup for PostgresStorage {
ON d.team_id = batch.team_id AND d.distinct_id = batch.distinct_id
"#,
&team_ids,
- &distinct_ids
+ &distinct_ids,
+ include_properties
)
.fetch_all(&mut *conn)
.await?;
diff --git a/rust/personhog-replica/src/storage/traits/group.rs b/rust/personhog-replica/src/storage/traits/group.rs
index 93b85b59a64c..3660a97da2ba 100644
--- a/rust/personhog-replica/src/storage/traits/group.rs
+++ b/rust/personhog-replica/src/storage/traits/group.rs
@@ -23,12 +23,14 @@ pub trait GroupStorage: Send + Sync {
team_id: i64,
identifiers: &[GroupIdentifier],
consistency: ConsistencyLevel,
+ include_properties: bool,
) -> StorageResult<Vec<Group>>;
async fn get_groups_batch(
&self,
keys: &[GroupKey],
consistency: ConsistencyLevel,
+ include_properties: bool,
) -> StorageResult<Vec<(GroupKey, Group)>>;
async fn list_groups(
@@ -41,6 +43,7 @@ pub trait GroupStorage: Send + Sync {
cursor_id: i64,
limit: i32,
consistency: ConsistencyLevel,
+ include_properties: bool,
) -> StorageResult<(Vec<Group>, bool)>;
// Group writes
diff --git a/rust/personhog-replica/src/storage/traits/person.rs b/rust/personhog-replica/src/storage/traits/person.rs
index 4ad4dabaa541..17f40c4e3f85 100644
--- a/rust/personhog-replica/src/storage/traits/person.rs
+++ b/rust/personhog-replica/src/storage/traits/person.rs
@@ -18,12 +18,14 @@ pub trait PersonLookup: Send + Sync {
&self,
team_id: i64,
person_ids: &[i64],
+ include_properties: bool,
) -> StorageResult<Vec<Person>>;
async fn get_persons_by_uuids(
&self,
team_id: i64,
uuids: &[Uuid],
+ include_properties: bool,
) -> StorageResult<Vec<Person>>;
// Lookups by distinct ID
@@ -38,11 +40,13 @@ pub trait PersonLookup: Send + Sync {
&self,
team_id: i64,
distinct_ids: &[String],
+ include_properties: bool,
) -> StorageResult<Vec<(String, Option<Person>)>>;
async fn get_persons_by_distinct_ids_cross_team(
&self,
team_distinct_ids: &[(i64, String)],
+ include_properties: bool,
) -> StorageResult<Vec<((i64, String), Option<Person>)>>;
// Deletes
diff --git a/rust/personhog-replica/src/storage/types/group.rs b/rust/personhog-replica/src/storage/types/group.rs
index c894980f50e3..48078ce7ddef 100644
--- a/rust/personhog-replica/src/storage/types/group.rs
+++ b/rust/personhog-replica/src/storage/types/group.rs
@@ -4,7 +4,7 @@ pub struct Group {
pub team_id: i64,
pub group_type_index: i32,
pub group_key: String,
- pub group_properties: String,
+ pub group_properties: Option<String>,
pub created_at: chrono::DateTime<chrono::Utc>,
pub properties_last_updated_at: Option<String>,
pub properties_last_operation: Option<String>,
diff --git a/rust/personhog-replica/src/storage/types/person.rs b/rust/personhog-replica/src/storage/types/person.rs
index b60a43df5bc1..b320f95b410f 100644
--- a/rust/personhog-replica/src/storage/types/person.rs
+++ b/rust/personhog-replica/src/storage/types/person.rs
@@ -5,7 +5,7 @@ pub struct Person {
pub id: i64,
pub uuid: Uuid,
pub team_id: i64,
- pub properties: String,
+ pub properties: Option<String>,
pub properties_last_updated_at: Option<String>,
pub properties_last_operation: Option<String>,
pub created_at: chrono::DateTime<chrono::Utc>,
diff --git a/rust/personhog-replica/tests/storage_tests.rs b/rust/personhog-replica/tests/storage_tests.rs
index 15d18aeefb8e..4c07247ad19b 100644
--- a/rust/personhog-replica/tests/storage_tests.rs
+++ b/rust/personhog-replica/tests/storage_tests.rs
@@ -81,7 +81,7 @@ async fn test_get_persons_by_ids() {
let result = ctx
.storage
- .get_persons_by_ids(ctx.team_id, &[person1.id, person2.id, 999999999])
+ .get_persons_by_ids(ctx.team_id, &[person1.id, person2.id, 999999999], true)
.await
.expect("Failed to get persons");
@@ -160,7 +160,8 @@ async fn test_get_group() {
let fetched = result.unwrap();
assert_eq!(fetched.group_key, "company_123");
assert_eq!(fetched.group_type_index, 0);
- let fetched_props: serde_json::Value = serde_json::from_str(&fetched.group_properties).unwrap();
+ let fetched_props: serde_json::Value =
+ serde_json::from_str(fetched.group_properties.as_deref().unwrap()).unwrap();
assert_eq!(fetched_props, properties);
ctx.cleanup().await.ok();
@@ -246,7 +247,8 @@ async fn test_person_properties() {
assert!(result.is_some());
let fetched = result.unwrap();
- let props: serde_json::Value = serde_json::from_str(&fetched.properties).unwrap();
+ let props: serde_json::Value =
+ serde_json::from_str(fetched.properties.as_deref().unwrap()).unwrap();
assert_eq!(props["email"], "[email protected]");
assert_eq!(props["plan"], "enterprise");
@@ -270,7 +272,11 @@ async fn test_get_persons_by_uuids() {
let result = ctx
.storage
- .get_persons_by_uuids(ctx.team_id, &[person1.uuid, person2.uuid, nonexistent_uuid])
+ .get_persons_by_uuids(
+ ctx.team_id,
+ &[person1.uuid, person2.uuid, nonexistent_uuid],
+ true,
+ )
.await
.expect("Failed to get persons by uuids");
@@ -364,7 +370,7 @@ async fn test_get_groups_batch() {
let result = ctx
.storage
- .get_groups_batch(&keys, ConsistencyLevel::Eventual)
+ .get_groups_batch(&keys, ConsistencyLevel::Eventual, true)
.await
.expect("Failed to get groups batch");
@@ -1434,7 +1440,7 @@ async fn test_get_persons_by_ids_chunked() {
let result = ctx
.storage
- .get_persons_by_ids(ctx.team_id, &ids)
+ .get_persons_by_ids(ctx.team_id, &ids, true)
.await
.expect("Failed to get persons by ids");
@@ -1462,7 +1468,7 @@ async fn test_get_persons_by_uuids_chunked() {
let result = ctx
.storage
- .get_persons_by_uuids(ctx.team_id, &uuids)
+ .get_persons_by_uuids(ctx.team_id, &uuids, true)
.await
.expect("Failed to get persons by uuids");
@@ -1488,7 +1494,7 @@ async fn test_get_persons_by_distinct_ids_in_team_chunked() {
let result = ctx
.storage
- .get_persons_by_distinct_ids_in_team(ctx.team_id, &distinct_ids)
+ .get_persons_by_distinct_ids_in_team(ctx.team_id, &distinct_ids, true)
.await
.expect("Failed to get persons by distinct ids");
@@ -1525,7 +1531,7 @@ async fn test_get_persons_by_distinct_ids_in_team_chunked_preserves_missing() {
let result = ctx
.storage
- .get_persons_by_distinct_ids_in_team(ctx.team_id, &distinct_ids)
+ .get_persons_by_distinct_ids_in_team(ctx.team_id, &distinct_ids, true)
.await
.expect("Failed to get persons");
@@ -1612,3 +1618,215 @@ async fn test_get_distinct_ids_for_persons_chunked_with_limit() {
ctx.cleanup().await.ok();
}
+
+// ============================================================
+// include_properties=false storage tests
+// ============================================================
+
+#[tokio::test]
+async fn test_get_persons_by_ids_without_properties() {
+ let ctx = TestContext::new().await;
+ let props = serde_json::json!({"email": "[email protected]"});
+ let person = ctx
+ .insert_person("props_test_1", Some(props))
+ .await
+ .expect("Failed to insert person");
+
+ let with_props = ctx
+ .storage
+ .get_persons_by_ids(ctx.team_id, &[person.id], true)
+ .await
+ .expect("Failed to get persons with props");
+ assert_eq!(with_props.len(), 1);
+ assert!(with_props[0].properties.is_some());
+
+ let without_props = ctx
+ .storage
+ .get_persons_by_ids(ctx.team_id, &[person.id], false)
+ .await
+ .expect("Failed to get persons without props");
+ assert_eq!(without_props.len(), 1);
+ assert_eq!(without_props[0].id, person.id);
+ assert!(without_props[0].properties.is_none());
+ assert!(without_props[0].properties_last_updated_at.is_none());
+ assert!(without_props[0].properties_last_operation.is_none());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_get_persons_by_uuids_without_properties() {
+ let ctx = TestContext::new().await;
+ let props = serde_json::json!({"email": "[email protected]"});
+ let person = ctx
+ .insert_person("props_test_2", Some(props))
+ .await
+ .expect("Failed to insert person");
+
+ let without_props = ctx
+ .storage
+ .get_persons_by_uuids(ctx.team_id, &[person.uuid], false)
+ .await
+ .expect("Failed to get persons without props");
+ assert_eq!(without_props.len(), 1);
+ assert_eq!(without_props[0].id, person.id);
+ assert!(without_props[0].properties.is_none());
+ assert!(without_props[0].properties_last_updated_at.is_none());
+ assert!(without_props[0].properties_last_operation.is_none());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_get_persons_by_distinct_ids_in_team_without_properties() {
+ let ctx = TestContext::new().await;
+ let props = serde_json::json!({"email": "[email protected]"});
+ ctx.insert_person("props_did_test", Some(props))
+ .await
+ .expect("Failed to insert person");
+
+ let results = ctx
+ .storage
+ .get_persons_by_distinct_ids_in_team(ctx.team_id, &["props_did_test".to_string()], false)
+ .await
+ .expect("Failed to get persons without props");
+ assert_eq!(results.len(), 1);
+ let person = results[0].1.as_ref().expect("Person should be found");
+ assert!(person.properties.is_none());
+ assert!(person.properties_last_updated_at.is_none());
+ assert!(person.properties_last_operation.is_none());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_get_persons_by_distinct_ids_cross_team_without_properties() {
+ let ctx = TestContext::new().await;
+ let props = serde_json::json!({"email": "[email protected]"});
+ ctx.insert_person("props_cross_test", Some(props))
+ .await
+ .expect("Failed to insert person");
+
+ let results = ctx
+ .storage
+ .get_persons_by_distinct_ids_cross_team(
+ &[(ctx.team_id, "props_cross_test".to_string())],
+ false,
+ )
+ .await
+ .expect("Failed to get persons without props");
+ assert_eq!(results.len(), 1);
+ let person = results[0].1.as_ref().expect("Person should be found");
+ assert!(person.properties.is_none());
+ assert!(person.properties_last_updated_at.is_none());
+ assert!(person.properties_last_operation.is_none());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_get_groups_without_properties() {
+ let ctx = TestContext::new().await;
+ let props = serde_json::json!({"name": "Acme Corp"});
+ ctx.insert_group(0, "grp_props_test", Some(props))
+ .await
+ .expect("Failed to insert group");
+
+ let with_props = ctx
+ .storage
+ .get_groups(
+ ctx.team_id,
+ &[personhog_replica::storage::GroupIdentifier {
+ group_type_index: 0,
+ group_key: "grp_props_test".to_string(),
+ }],
+ ConsistencyLevel::Eventual,
+ true,
+ )
+ .await
+ .expect("Failed to get groups with props");
+ assert_eq!(with_props.len(), 1);
+ assert!(with_props[0].group_properties.is_some());
+
+ let without_props = ctx
+ .storage
+ .get_groups(
+ ctx.team_id,
+ &[personhog_replica::storage::GroupIdentifier {
+ group_type_index: 0,
+ group_key: "grp_props_test".to_string(),
+ }],
+ ConsistencyLevel::Eventual,
+ false,
+ )
+ .await
+ .expect("Failed to get groups without props");
+ assert_eq!(without_props.len(), 1);
+ assert!(without_props[0].group_properties.is_none());
+ assert!(without_props[0].properties_last_updated_at.is_none());
+ assert!(without_props[0].properties_last_operation.is_none());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_get_groups_batch_without_properties() {
+ let ctx = TestContext::new().await;
+ let props = serde_json::json!({"name": "Batch Corp"});
+ ctx.insert_group(0, "grp_batch_props", Some(props))
+ .await
+ .expect("Failed to insert group");
+
+ let without_props = ctx
+ .storage
+ .get_groups_batch(
+ &[GroupKey {
+ team_id: ctx.team_id,
+ group_type_index: 0,
+ group_key: "grp_batch_props".to_string(),
+ }],
+ ConsistencyLevel::Eventual,
+ false,
+ )
+ .await
+ .expect("Failed to get groups batch without props");
+ assert_eq!(without_props.len(), 1);
+ assert!(without_props[0].1.group_properties.is_none());
+ assert!(without_props[0].1.properties_last_updated_at.is_none());
+ assert!(without_props[0].1.properties_last_operation.is_none());
+
+ ctx.cleanup().await.ok();
+}
+
+#[tokio::test]
+async fn test_list_groups_without_properties() {
+ let ctx = TestContext::new().await;
+ let props = serde_json::json!({"name": "Listed Corp"});
+ ctx.insert_group(0, "grp_list_props", Some(props))
+ .await
+ .expect("Failed to insert group");
+
+ let (groups, _) = ctx
+ .storage
+ .list_groups(
+ ctx.team_id,
+ 0,
+ "",
+ "",
+ None,
+ 0,
+ 100,
+ ConsistencyLevel::Eventual,
+ false,
+ )
+ .await
+ .expect("Failed to list groups without props");
+ assert!(!groups.is_empty());
+ for g in &groups {
+ assert!(g.group_properties.is_none());
+ assert!(g.properties_last_updated_at.is_none());
+ assert!(g.properties_last_operation.is_none());
+ }
+
+ ctx.cleanup().await.ok();
+}
diff --git a/rust/personhog-router/src/router/routing.rs b/rust/personhog-router/src/router/routing.rs
index f33fce98116c..0dfc5e1a7d9d 100644
--- a/rust/personhog-router/src/router/routing.rs
+++ b/rust/personhog-router/src/router/routing.rs
@@ -149,6 +149,7 @@ mod tests {
metadata.insert("x-read-consistency", "strong".parse().unwrap());
let body_options = Some(ReadOptions {
consistency: ConsistencyLevel::Eventual.into(),
+ ..Default::default()
});
assert_eq!(
resolve_consistency(&metadata, &body_options),
@@ -161,6 +162,7 @@ mod tests {
let metadata = MetadataMap::new();
let body_options = Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
});
assert_eq!(
resolve_consistency(&metadata, &body_options),
diff --git a/rust/personhog-router/src/service/tests/mod.rs b/rust/personhog-router/src/service/tests/mod.rs
index 7247820af010..889038831d99 100644
--- a/rust/personhog-router/src/service/tests/mod.rs
+++ b/rust/personhog-router/src/service/tests/mod.rs
@@ -120,6 +120,7 @@ async fn test_get_person_with_strong_consistency_returns_unimplemented() {
person_id: 1,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
});
@@ -142,6 +143,7 @@ async fn test_get_person_with_explicit_eventual_consistency_succeeds() {
person_id: 1,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Eventual.into(),
+ ..Default::default()
}),
});
diff --git a/rust/personhog-router/tests/integration.rs b/rust/personhog-router/tests/integration.rs
index b721dc37d24c..be76af759953 100644
--- a/rust/personhog-router/tests/integration.rs
+++ b/rust/personhog-router/tests/integration.rs
@@ -435,6 +435,7 @@ async fn test_get_person_with_unspecified_consistency() {
person_id: 42,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Unspecified.into(),
+ ..Default::default()
}),
})
.await
diff --git a/rust/personhog-router/tests/leader_integration.rs b/rust/personhog-router/tests/leader_integration.rs
index 179a0e12a46b..9b08c14471b0 100644
--- a/rust/personhog-router/tests/leader_integration.rs
+++ b/rust/personhog-router/tests/leader_integration.rs
@@ -60,6 +60,7 @@ async fn strong_read_routes_to_leader() {
person_id: 42,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
})
.await
@@ -134,6 +135,7 @@ async fn write_then_strong_read_roundtrip() {
person_id: 42,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
})
.await
@@ -188,6 +190,7 @@ async fn strong_read_fails_when_no_leader_configured() {
person_id: 42,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
})
.await;
@@ -232,6 +235,7 @@ async fn non_person_data_always_routes_to_replica() {
}],
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
})
.await
@@ -263,6 +267,7 @@ async fn leader_person_not_found_returns_not_found() {
person_id: 999,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
})
.await;
diff --git a/rust/personhog-router/tests/raw_proxy_integration.rs b/rust/personhog-router/tests/raw_proxy_integration.rs
index 81561fe175e2..6e9f5d7efa77 100644
--- a/rust/personhog-router/tests/raw_proxy_integration.rs
+++ b/rust/personhog-router/tests/raw_proxy_integration.rs
@@ -722,6 +722,7 @@ async fn parity_leader_strong_get_person() {
person_id: 42,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
};
let raw_req = with_consistency(
@@ -801,6 +802,7 @@ async fn parity_leader_person_not_found() {
person_id: 999,
read_options: Some(ReadOptions {
consistency: ConsistencyLevel::Strong.into(),
+ ..Default::default()
}),
};
let raw_req = with_consistency(
diff --git a/rust/property-defs-rs/src/group_type_resolver.rs b/rust/property-defs-rs/src/group_type_resolver.rs
index b10d7128aa03..84c02a9e3e76 100644
--- a/rust/property-defs-rs/src/group_type_resolver.rs
+++ b/rust/property-defs-rs/src/group_type_resolver.rs
@@ -145,6 +145,7 @@ impl GroupTypeResolver {
team_ids: unique_team_ids,
read_options: Some(ReadOptions {
consistency: consistency.into(),
+ ..Default::default()
}),
});
let metadata = request.metadata_mut();