-
Notifications
You must be signed in to change notification settings - Fork 81
Description
Describe the bug
I have two entities, Tenancy and ApiKey, a service and collection. tenancyId acts as a common pk for both the Tenancy and ApiKey. The ApiKey uses its token as the sort key. A collection, settings pulls back the tenancy and associated api keys. This was working in 3.5.0, however in 3.5.1 and 3.5.2 the collection only fetches the "child" ApiKey, not the parent Tenancy.
ElectroDB Version
3.5.1
ElectroDB Playground Link
link here
Entity/Service Definitions
Include your entity model (or a model that sufficiently recreates your issue) to help troubleshoot.
const tenancy = new Entity(
{
model: {
entity: "tenancy",
version: "1",
service: "tenancy"
},
attributes: {
tenancyId: {
type: "string",
required: true
},
name: {
type: "string",
required: true
}
},
indexes: {
primary: {
pk: {
field: "pk",
composite: ["tenancyId"]
},
sk: {
field: "sk",
// create composite keys for partial sort key queries
composite: []
}
},
settings: {
// collections allow for queries across multiple entities
collection: "settings",
index: "gsi1pk-gsi1sk-index",
pk: {
// map to your GSI Hash/Partition key
field: "gsi1pk",
composite: ["tenancyId"]
},
sk: {
// map to your GSI Range/Sort key
field: "gsi1sk",
composite: []
}
},
}
},
{ table }
);
const apiKey = new Entity(
{
model: {
entity: "apiKey",
service: "tenancy",
version: "1"
},
attributes: {
tenancyId: {
type: "string",
required: true
},
apiKeyId: {
type: "string",
required: true
},
token: {
type: "string",
required: true
}
},
indexes: {
primary: {
pk: {
composite: ["tenancyId"],
field: "pk"
},
sk: {
composite: ["token"],
field: "sk"
}
},
settings: {
collection: "settings",
index: "gsi1pk-gsi1sk-index",
pk: {
composite: ["tenancyId"],
field: "gsi1pk"
},
sk: {
field: "gsi1sk",
composite: []
}
}
}
},
{ table }
);
const tenancyId = "myTenancyId"
app.collections.settings({ tenancyId }).go()
Expected behavior
Should return the tenancy and api key
Errors
3.5.1 only returns the apiKey, the tenancy array is empty
Additional context
Tenancy pk & sk:
$tenancy#tenancyid_h83imegk8jb6
$tenancy_1
Api Key pk & sk:
$tenancy#tenancyid_h83imegk8jb6
$apikey_1#token_42wecu3oj-iztdtwhtn-ad3fankya