Quinn Angstrom
[workmute] Let's talk about the stupidest bug I've encountered to date at this job
Quinn Angstrom
This is for a piece of functionality related to search and SQL statements
Quinn Angstrom
where part of it is passing in a list of IDs to a SQL statement
Quinn Angstrom
I will try to keep this newbie-parsable if I can
Quinn Angstrom
so basically it's going "find things in this table where the IDs are in this list"
Quinn Angstrom
and when it's correct, that last bit looks something like "WHERE ID IN (5, 7, 100, 150)"
Quinn Angstrom
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
Quinn Angstrom
so on the code side, there's an "idString" that has the string "5,7,100,150"
Quinn Angstrom
but
Quinn Angstrom
and here's where it gets stupid
Quinn Angstrom
some of these IDs are very large
Quinn Angstrom
and being stored as strings, not numbers, because some of our tables use string-based IDs
Quinn Angstrom
and for some fucking reason,
Quinn Angstrom
these large numbers as strings are coming in with commas separating every third digit, like you do when writing numbers traditionally
Quinn Angstrom
like, ID 77500 is stored as "77,500"
Quinn Angstrom
fellow programmers may see where this is going
Quinn Angstrom
if the function tries to get the info on the records with IDs 50, 100, and 77500
Quinn Angstrom
then the SQL ends up being "WHERE ID IN (50,100,77,500)"
Quinn Angstrom
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?
Quinn Angstrom
I honestly don't know how it's happening
Quinn Angstrom
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.
Quinn Angstrom
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
Quinn Angstrom
occasionally stupidities aside I actually reall like C#
Quinn Angstrom
really*
HotXC
ouch
Quinn Angstrom
just because I fucking love Linq
Quinn Angstrom
it's so useful for business programming
Quinn Angstrom
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"
Quinn Angstrom
I can do that in one fucking line of code
Quinn Angstrom
list.Where(x => x.Enabled).Select(y => Regex.Replace(y, ",", string.Empty))
Quinn Angstrom
in other workmute news
Quinn Angstrom
>"Wow, it's already noon and I'm just starting to get hungry! My appetite is in good form today!"
Quinn Angstrom
>I was checking the clock on a host I was remote desktopped into
Quinn Angstrom
>That host is in New York
Quinn Angstrom
>Lunch is in an hour
載入新的回覆