this post was submitted on 30 Jun 2024
23 points (100.0% liked)

SQL

474 readers
1 users here now

Related Fediverse communities:

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

founded 1 year ago
MODERATORS
23
Guess the intent (aussie.zone)
submitted 4 months ago* (last edited 4 months ago) by [email protected] to c/sql
 

I am one of the developers on a very small team and have just found the following query

I would love to hear your ideas for what you think was being attempted here!

SELECT ... FROM client WHERE CAST(ABS(SIN(clientId)) AS BIT) = 0

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 4 months ago

Well then, to answer OP’s question about intent, I don’t have much of a clue, but here’s some Idea Ore that maybe someone can refine into a plausible explanation:

  • clientId basically has to be sequential or none of this makes sense
  • conceptually, I believe this statement is equivalent to clientId%180 == 0
  • i can’t fathom CAST(ABS(SIN())) being more efficient than modular division, so maybe the dev was trying to be clever, hated the hardcoded 180, or some other unknown going on
  • a sine wave goes -∿- so this is where it hits the x-axis
  • given that, there has to be some periodic or cyclical purpose, relating to the why/how of the clientId creation. For example, when the results of this are graphed with a created_at timestamp, it might give useful insights to growth (or something)