djongo icon indicating copy to clipboard operation
djongo copied to clipboard

Fixed a bug related to django4 foreign key lookups

Open HardlyForeal opened this issue 2 years ago • 9 comments

Previous versions of django ran a foreign key lookup with a const (1) parameter in the column list. Django 4 changed that to a parameterized value and pass the parameter value 1. I have created a new token type to hold the aliased paramaterized value. SQLConstParameterizedIdentifier is subclassed from SQLConstIdentifier, and the original functionality is broken out into SQLConstIntIdentifier. This should allow anything that was using isinstanceof for SQLConstIdentifier to still work and allows expansion to other non-int constants. A test case has been added for the django 4 select statement. Closes #630 Closes #634

HardlyForeal avatar Nov 19 '22 04:11 HardlyForeal

Issue #630 was closed by the poster with the comment that they "fixed" it by reverting back to a prior django version. Other postings I've seen indicate that djongo is supposed to support the latest django version, so that issue should really still be open, and would be fixed by this pr. As far as I can tell, this is an issue with every foreign key relationship in the latest django due to changes in the sql it generates.

HardlyForeal avatar Nov 19 '22 08:11 HardlyForeal

@HardlyForeal Thanks! I had faced the same bug and used your commit files to update my local djongo files. Works like a charm now.

ghpkishore avatar Dec 06 '22 07:12 ghpkishore

Im facing exactly the same issue, @ghpkishore would you please share how did you manage to get it working? Did you use a monkey-patching in those methods?

pekosoG avatar Dec 23 '22 06:12 pekosoG

What ever files are present in this commit, I updated the files in my system with those. That worked. You can think of it as monkey-patching, but I changed the source code in the downloaded repo itself.

ghpkishore avatar Dec 23 '22 08:12 ghpkishore

Is this going to be merged soon?

deviantfero avatar Mar 28 '23 00:03 deviantfero

Will it get merge anytime soon?

Pansuria-Shrey avatar May 06 '23 13:05 Pansuria-Shrey

Still working perfectly in Django 4.2.3 and the latest uploaded version of djongo. I had the exists() issue and also the validation of duplicate User usernames in the DB wasn't working. Thank you so much!

phoenixsite avatar Aug 04 '23 22:08 phoenixsite

Thank you very much ! Please merge this fix

ELDiablO59152 avatar Oct 09 '23 14:10 ELDiablO59152

@nesdis please can you take a look on this?

pimuzzo avatar Jun 06 '24 10:06 pimuzzo