Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Kata has very poor quality. Error messages are also not helpful.
Description:
= "="
is missing fromorWhere
's function arguments.Okay, but what is the MySQL syntax for all the things that are tested in the kata? This is not very difficult to describe in the kata, and saves everyone from having to know how to write MySQL queries.
The description has apparently been updated with this:
So none of the above would be correct.
The bad test feedback is still a thing though. Trying to match the whole thing with a big regex isn't a good idea at all.
Duplicate: https://www.codewars.com/kata/545434090294935e7d0010ab
I agree, it lacks proper feedback when a test fails, I am wasting a lot of time guessing what the format should be.
For example for conditions
where(cash, 1000000, >), where(username, ww), where(password, qwerty), where(first_name, heisenberg), orWhere(first_name, walter)
what is expected? All of the following are rejected, with the vague
Should handle multiple wheres correctly, escaping string values, handling different operators and OR conditions
.SELECT username AS user, password AS pass, first_name FROM users WHERE cash > 1000000 AND username = 'ww' AND password = 'qwerty' AND first_name = 'heisenberg' OR first_name = 'walter'
SELECT username AS user, password AS pass, first_name FROM users WHERE cash > 1000000 AND username = 'ww' AND password = 'qwerty' AND (first_name = 'heisenberg' OR first_name = 'walter')
SELECT username AS user, password AS pass, first_name FROM users WHERE (cash > 1000000) AND (username = 'ww') AND (password = 'qwerty') AND (first_name = 'heisenberg') OR (first_name = 'walter')
The kata description, sample test cases, and test feedback are severely lacking. In its current state, users may end up wasting time on unnecessary trial and error to get the correct format.
For example, for test case #5, what is wrong with the following output and what is the correct output?
SELECT username AS user, password AS pass, first_name FROM posts WHERE cash > 100000 AND username = 'ww' OR first_name = 'walter'
It also rejects:
SELECT username AS user, password AS pass, first_name FROM posts WHERE (cash > 100000) AND (username = 'ww') OR (first_name = 'walter')
The message for this failed test doesn't help:
Should handle multiple wheres correctly, escaping string values, handling different operators and OR conditions
Hey zvytas, I'm glad you enjoyed it.
I see what you mean, but I really ment it to be the last one.
I realized that no test case existed to test this requirement so you could get away with
always using the first definition.
I've added the test case for this too so now you have to strictly follow the specs.
Nice kata, good work! One minor thing - I think the following sentense should be changed.
Currently: "If a column appears in the input more than once, only the last one will be used in the final query."
Updated: "If a column appears in the input more than once, only the first one will be used in the final query."