shotgunsoftware / python-api

A Python-based library for accessing Flow Production Tracking API.
https://developer.shotgridsoftware.com/python-api
Other
306 stars 198 forks source link

'name' and 'type' is missing when returning linked entities with custom fields #293

Closed manuelito02 closed 1 year ago

manuelito02 commented 1 year ago

Hi there!

There is a way to get additional fields of linked entities (not only 'id', 'name'/'code' and 'type') with the syntax

my_field.entity_type.entity_field

This is great to reduce the amount of queries to SG.

However, there seems to be a problem with the 'name' and 'type' field of that linked entity. Please check following code:

app.sgtk.shotgun.find(
  "Shot",
  [["id", "is", 39190]],
  ["sg_sequence"],
)

This returns:

# Results:
#  [{'type': 'Shot', 'id': 39190, 'sg_sequence': {'id': 17062, 'name': 'ANS_105_042', 'type': 'Sequence'}}]
app.sgtk.shotgun.find(
  "Shot",
  [["id", "is", 39190]],
  [
    "sg_sequence.Sequence.id",
    "sg_sequence.Sequence.name",
    "sg_sequence.Sequence.type",
    "sg_sequence.Sequence.task_template",
  ],
)```

Here, I'm specifically asking for the 'id', 'name', 'type' and 'task_template' fields, but I get back following:

Results:

[{'type': 'Shot', 'id': 39190, 'sg_sequence.Sequence.id': 17062, 'sg_sequence.Sequence.task_template': None}]```

I have my sequence 'id' and 'task_template', but not the 'name' and the 'type'.

Is this a bug or am I doing something wrong?

Greets, Carlo

stephenschick commented 1 year ago

The Sequence Name field is internally "code", not "name". The Type field is not native, so likely "sg_type".

Check any field internal names by right-clicking on the field header in list view, and choosing Configure Field. Then see the "Field code:" at the top right.

Stephen

From: Carlo Giesa @.> Sent: Tuesday, August 8, 2023 8:11 AM To: shotgunsoftware/python-api @.> Cc: Subscribed @.***> Subject: [shotgunsoftware/python-api] 'name' and 'type' is missing when returning linked entities with custom fields (Issue #293)

Hi there!

There is a way to get additional fields of linked entities (not only 'id', 'name'/'code' and 'type') with the syntax

my_field.entity_type.entity_field

This is great to reduce the amount of queries to SG.

However, there seems to be a problem with the 'name' and 'type' field of that linked entity. Please check following code:

"Shot",

[["id", "is", 39190]],

["sg_sequence"],

)

This returns:

[{'type': 'Shot', 'id': 39190, 'sg_sequence': {'id': 17062, 'name': 'ANS_105_042', 'type': 'Sequence'}}]

"Shot",

[["id", "is", 39190]],

[

"sg_sequence.Sequence.id",

"sg_sequence.Sequence.name",

"sg_sequence.Sequence.type",

"sg_sequence.Sequence.task_template",

],

)```

Here, I'm specifically asking for the 'id', 'name', 'type' and 'task_template' fields, but I get back following:



#  [{'type': 'Shot', 'id': 39190, 'sg_sequence.Sequence.id': 17062, 'sg_sequence.Sequence.task_template': None}]```

I have my sequence 'id' and 'task_template', but not the 'name' and the 'type'.

Is this a bug or am I doing something wrong?

Greets,

Carlo

-
Reply to this email directly, view it on GitHub<https://github.com/shotgunsoftware/python-api/issues/293>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABPA337UXSNJRI2PC3B6IYLXUJJHLANCNFSM6AAAAAA3IUENAQ>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.******@***.***>>
manuelito02 commented 1 year ago

Hi Stephen!

Thanks for your quick response!

Oh yes, of course, the code vs name. I'm always confused about this one. But type doesn't seem to be a proper field (tested with sg_type without success). This actually makes sense and gets probably automatically added when running the first request. The type should be the table. Would there be any way to get the 'default' fields (type, id, name) when querying a linked entity and request custom fields as well?

Greets, Carlo

manuelito02 commented 1 year ago

Oh, actually, it works. Following code does exactly what I want:

app.sgtk.shotgun.find(
  "Shot",
  [["id", "is", 39190]],
  [
    "sg_sequence",
    "sg_sequence.Sequence.task_template",
  ],
)