Skip to main content
9 events
when toggle format what by license comment
Jan 11 at 1:04 comment added STerliakov Hm, but CodeReview requires that you post a code to be reviewed (it should compile/run without obvious errors and be correct to the best of your knowledge) and be representative: we review the code included in your post. Now it certainly can't be run, and my comment above is part of review of the implementation that you posted and isn't an answer precisely because the snippet does not represent a runnable piece of software. Generic questions "is my approach reasonable", even if accompanied with some pseudocode, are off-topic here.
Jan 11 at 0:00 comment added Braiam @STerliakov the comments are not on the code. They are only in this question trying to explain in a very narrow example, what it is doing and why. I don't blame you that it seems daunting, because inventory management software rarely isn't, specially when you are dealing with serialized items (there's only 1 combination of 3 characteristic described in the model, the located_at is something that should be implied of a inventory system).
Jan 9 at 19:50 comment added STerliakov And please don't ever write comments explaining code above. For if/else branches you may put comments inside them to comment on that branch selection or behaviour, but on top level comments should explain the following piece of code. Now it reads as We return early if the range is equal to the entire record... raise Exception - exception is certainly a kind of an early return, but not the one other people can comprehend this way.
Jan 9 at 18:08 comment added STerliakov As a python&django developer, I must confess that your SQL version is more readable than its python counterpart. I'd write an answer, but unfortunately your snippet is not reviewable. There are multiple undefined variables, some unused variables, import straight in the middle of a function, let alone missing def ... around something containing a return statement. You don't have to verbosely copy model attributes to variables unless you have a very weird custom delete - all instance fields (except for pk? not sure) remain available after calling .delete().
Jan 8 at 2:50 history became hot network question
Jan 7 at 21:35 answer added J_H timeline score: 3
Jan 7 at 18:56 history edited toolic
edited tags
Jan 7 at 18:54 comment added Braiam A concern not detailed here: what if I want to do this with multiple records at the same time? I could see an argument that by that time I should just loop this function and would be satisfied.
Jan 7 at 18:47 history asked Braiam CC BY-SA 4.0