question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unnecessary variable loaded_fields

See original GitHub issue

If no fields exist we return None and exist the bulk_update.

However later we try to get loaded_fields here. But as fields will never be None or empty we will never use evaluate the get_fields function again. So the variable loaded_fields should be unnecessary.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
arnau126commented, Aug 29, 2017

loaded_fields is actually necessary.

At this point fields can be None or an empty list. This difference is important.

  • If fields is an empty list we exit the bulk_update, as you said.
  • But if fields is None we go ahead. This happens when we don’t have meta nor update_fields. In this case we don’t know which fields we have to update, and since each object could have a different set of loaded variables, we have to call get_fields for each one.
0reactions
arnau126commented, Aug 31, 2017

[EDITED]

Thanks for the clarification! Out of curiosity at what point could it happen that meta doesn’t exist on an object?

bulk_update has an optional argument called meta. If meta is not None we will use it to update all objects in objs. But if we don’t have this “global” meta, we will use the meta from the first object.

When we don’t have this “global” meta nor update_fields is when we have to call get_fields for each object.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why unnecessary variables are bad for your code - TechBeacon
Unnecessary variables are unnecessary liabilities. Variables are one of the most basic elements of programming. They're usually one of the first things you ......
Read more >
Implementing an @export directive · Issue #3283 - GitHub
I want to implement an @export directive. This would export the value of a field into a variable that can be used in...
Read more >
Do "unnecessary" variables matter that much? : r/PHP - Reddit
As I repeat, I'd like to know from everyone: how much do unnecessary variables influence my performance and does a single one of...
Read more >
conditional field count - Qlik Community - 576785
Hi everyone! What I am trying to achieve is to wildcard match from all loaded fields and select those which have particular value....
Read more >
Getting fields from layer calculated during process (output ...
Anyway, I have created the necessary variables as parameters. In the layer that I need to manipulate, and which is obtained from an ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found