Skip to content

1.57.0 - Expose `Model._$idKeys` for a model's identifier field keys

Latest

Choose a tag to compare

@penny-for-vapor penny-for-vapor released this 02 Jul 10:02
ca609b2

What's Changed

Expose Model._$idKeys for a model's identifier field keys by @tarag in #654

Code that builds raw SQL against a model — e.g. an upsert with an ON CONFLICT target — needs the database FieldKeys of the model’s identifier, and must handle both @ID and @CompositeID. The only way to get them generically today is to reach the internal anyID property.

Add a public _$idKeys: [FieldKey] accessor, mirroring the existing _$idExists escape hatch: it works for both @ID and @CompositeID, whereas _$id traps on composite models. AnyID is refined to AnyDatabaseProperty — both IDProperty and CompositeIDProperty already conform — so the accessor reads anyID.keys without a cast while AnyID and anyID stay internal.

This patch was released by @gwynne

Full Changelog: 1.56.0...1.57.0