- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Exclude the anchovy topping from my frist pizza, please.
Admin
Does it use query params? Those look like format params to me...
Admin
Record Count From THIS Clause is what I believe they meant.
Admin
I don't see where query parameters are used -- they're usually called '?'. I do see '%s' which smells (s)printf to me. Which opens all the doors to SQL injection.
Admin
I'll have yours. Anchovy is great, and haters are wrong.
Admin
I'm admittedly giving them the benefit of the doubt, as I have seen query layers which use
%
params instead. I could easily be wrong, though.Admin
Anchovy, pineapple and chocolate, please.
Admin
ASC_SQL_KEYWORD is long but it has a big advantage over using "ASC" everywhere -- if you misspell it as ACS_SQL_KEYWORD you get a compilation error but if you mistype the actual keyword as "ACS" in a hand-typed query you get an error at runtime, which may or may not be well handled by the code.
Admin
That in itself is a metaWTF. What are the odds that a new programmer on the team, faced with something filled with "printf" tokens, is going to think "Oh, goodie, I can build this string using the boffo Magic EIght Ball QueryOMatic, and then use it in a Console.WriteLine? (Or, if Java, System.out.printX.)
Though, given the "intent" (as in, the difference between manslaughter and murder) of this lovely little thing, I seriously doubt it sits on the type of framework you give it credit for.
Admin
Also, if used in combination with the CoPilot splodge from yesterday's WTF, you're giving the AI a much stronger signal.
EXTRA_LONG_TOKENS_FTW!
Oops, I panicked. Win!
Admin
One of the more important implicit guidelines of programming is: add as much human-semantic value per-statement as possible. Code is read more than it is written, so make it easy to for humans to understand. Much of this code does the opposite.
Another important guideline is: use identifiers to identify things that might vary. I'm not privy to the internal workings of our SQL overlords, but I strongly suspect that ASC and DESC are unlikely to change in future SQL standards.
I'm sorry for anyone who has to work with code like this!
Admin
I know how to improve this.
const string A_LETTER = "A";
...
string sql = S_LETTER + E_LETTER .....
Admin
Yes, there are some database APIs that use
%s
as placeholders -- Python mysql connectors, for instance.But one of the
%s
is in quotes, and I can't think of any that replace quoted placeholders. AndIN (%s)
also looks printfy.Admin
Addendum 2021-07-07 09:20: Oops, that Update was supposed to be: Update Crust_Type Set Size_Name = NULL;
Admin
Admin
@Remy - "as I have seen query layers which use % params instead." ... care to enumerate at least two of them?
Admin
Redacted Pizza! Mmmmmmm....
Admin
Someone needs to open a pizza shop named this somewhere in Fort Meade, MD.
Admin
Is this how his wife became a bowling ball?
Admin
I used to work in a pizza joint where I had to clean containers used the previous night, often without emptying the contents first. Meaning, I often had to come in and wash containers full of anchovies, that had been sitting out overnight in a tropical climate (overnight low temperatures 80 - 85 F). Took me nearly 2 decades before I could stomach the smell of anchovies after leaving that job.
Admin
I have spent many arguments with a colleague over the advantages of using enums over strings for this exact reason. Things like country names, where we have to apply different settings if a particular country or region is involved.