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.

Querying in a sub query seems not exclude deleted items

See original GitHub issue

As you see below, items are not excluded…

358278 is soft deleted and not appear in a normal query

In [11]: WidgetItem.objects.values_list('widget').filter(id=358278)
Out[11]: <SafeDeleteQueryset []>

But not in a more complex query like this:

In [8]: widget_items = WidgetItem.objects.values_list('widget').filter(id=358278)

In [9]: Widget.objects.filter(id__in=widget_items).distinct()
Out[9]: <SafeDeleteQueryset [<Widget: 358278>]>

Any recommandations ?

And when printing query, deleted field are not excluded too:

In [8]: print(WidgetItem.objects.filter(id=358278).values_list('widget').query)
SELECT `nfb_widgets_widgetitem`.`widget_id` FROM `nfb_widgets_widgetitem` WHERE `nfb_widgets_widgetitem`.`id` = 358278 ORDER BY `nfb_widgets_widgetitem`.`order` ASC

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:12
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
Gagarocommented, Jan 27, 2021

This is fixed in master, I’ll have to migrate the test runners to github actions before releasing it.

0reactions
Gagarocommented, Jan 28, 2021

released in 0.5.7

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consider using [NOT] EXISTS instead of [NOT] IN with a ...
Phil Factor explains why you should prefer use of [NOT] EXISTS over [NOT] IN, when comparing data sets using a subquery.
Read more >
SQL Exclude results from join or subquery where column ...
Ok, I'm working with an existing database (cannot edit the tables, columns, etc.) I am asked to create a report with the data...
Read more >
13.2.15.6 Subqueries with EXISTS or NOT EXISTS
If a subquery returns any rows at all, EXISTS subquery is TRUE , and NOT EXISTS subquery is FALSE . For example: SELECT...
Read more >
[Solved] Exclude records using a subquery in SQL SERVER
I have to exclude some records( i can't delete) i am trying to create a view. Tried with sub queries but not worked...
Read more >
Syntax and Examples of SQL EXCLUDE - eduCBA
The basic syntax for writing exclude queries in SQL are as follows: ... Exclude rows using NOT IN operator with subqueries on the...
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