Quinneapolis
[workmute] Let's talk about the stupidest bug I've encountered to date at this job
Quinneapolis
This is for a piece of functionality related to search and SQL statements
Quinneapolis
where part of it is passing in a list of IDs to a SQL statement
Quinneapolis
I will try to keep this newbie-parsable if I can
Quinneapolis
so basically it's going "find things in this table where the IDs are in this list"
Quinneapolis
and when it's correct, that last bit looks something like "WHERE ID IN (5, 7, 100, 150)"
Quinneapolis
And how it gets that list is that it takes the IDs, kludges them together into a comma-delimited string, and throws it into the SQL statement
Quinneapolis
so on the code side, there's an "idString" that has the string "5,7,100,150"
Quinneapolis
but
Quinneapolis
and here's where it gets stupid
Quinneapolis
some of these IDs are very large
Quinneapolis
and being stored as strings, not numbers, because some of our tables use string-based IDs
Quinneapolis
and for some fucking reason,
Quinneapolis
these large numbers as strings are coming in with commas separating every third digit, like you do when writing numbers traditionally
Quinneapolis
like, ID 77500 is stored as "77,500"
Quinneapolis
fellow programmers may see where this is going
Quinneapolis
if the function tries to get the info on the records with IDs 50, 100, and 77500
Quinneapolis
then the SQL ends up being "WHERE ID IN (50,100,77,500)"
Quinneapolis
and instead of looking for ID 77500, it looks for ID 77 and ID 500
kamikasei
Who the fuck thought the toString() function for internal use should pretty-print?
Quinneapolis
I honestly don't know how it's happening
Quinneapolis
but this is so dumb
kamikasei
What's the language? Maybe there's some global setting somewhere telling it how to format string representations?
kamikasei
But yes that is super dumb.
Quinneapolis
C#
izzy.vrm
w ow that's super dumb
Rama
Well, C# is a Microsoft language, so there you go
Rama
Of course it breaks every piece of Microsoft software it has to interact with
Quinneapolis
occasionally stupidities aside I actually reall like C#
Quinneapolis
really*
Cold XC
ouch
Quinneapolis
just because I fucking love Linq
Quinneapolis
it's so useful for business programming
Quinneapolis
like, if I have a requirement of "get the list of IDs from this list, but only from the list items that are Enabled, and strip the commas out of the IDs, then return the list"
Quinneapolis
I can do that in one fucking line of code
Quinneapolis
list.Where(x => x.Enabled).Select(y => Regex.Replace(y, ",", string.Empty))
Quinneapolis
in other workmute news
Quinneapolis
>"Wow, it's already noon and I'm just starting to get hungry! My appetite is in good form today!"
Quinneapolis
>I was checking the clock on a host I was remote desktopped into
Quinneapolis
>That host is in New York
Quinneapolis
>Lunch is in an hour
載入新的回覆