Skip to content

Commit 66458aa

Browse files
migeed-zmeta-codesync[bot]
authored andcommitted
Store pk info in the binding layer
Summary: in the slot we just added in the binding layer, we will store the pk info for the class Reviewed By: rchen152 Differential Revision: D85480118 fbshipit-source-id: b3075a57dbca45dac4ccc85d338b15d69966aa8c
1 parent ae50612 commit 66458aa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pyrefly/lib/binding/class.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ impl<'a> BindingsBuilder<'a> {
233233
);
234234
let field_definitions = self.scopes.finish_class_and_get_field_definitions();
235235

236+
let mut django_primary_key_field: Option<Name> = None;
236237
let mut fields = SmallMap::with_capacity(field_definitions.len());
237238
for (name, (definition, range)) in field_definitions.into_iter_hashed() {
238239
if let ClassFieldDefinition::AssignedInBody {
@@ -242,8 +243,9 @@ impl<'a> BindingsBuilder<'a> {
242243
{
243244
self.extract_pydantic_config_dict(e, &name, &mut pydantic_config_dict);
244245

245-
// TODO: We will use this to populate the django metadata
246-
let _is_django_primary_key = self.extract_django_primary_key(e);
246+
if self.extract_django_primary_key(e) {
247+
django_primary_key_field = Some(name.clone().into_key());
248+
}
247249
}
248250
let (is_initialized_on_class, is_annotated) = match &definition {
249251
ClassFieldDefinition::DefinedInMethod { annotation, .. } => {
@@ -345,7 +347,7 @@ impl<'a> BindingsBuilder<'a> {
345347
decorators: decorators_with_ranges.clone().into_boxed_slice(),
346348
is_new_type: false,
347349
pydantic_config_dict,
348-
django_primary_key_field: None,
350+
django_primary_key_field,
349351
},
350352
);
351353
self.insert_binding_idx(

0 commit comments

Comments
 (0)