Ad
  • Custom User Avatar

    Kata has very poor quality. Error messages are also not helpful.

  • Custom User Avatar

    Description: = "=" is missing from orWhere's function arguments.

  • Custom User Avatar

    In this kata you'll build a simplified version of a query builder that can only handle select statements and that will output the resulting MySQL query.

    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.

  • Custom User Avatar

    The description has apparently been updated with this:

    To chain multiple conditions, start your where with a "1 = 1" condition, so that you'll not need to worry about stripping the initial "AND/OR" from the first condition.

    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.

  • Default User Avatar
  • Custom User Avatar

    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.

    1. 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'

    2. 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')

    3. 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')

  • Custom User Avatar

    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

  • Custom User Avatar

    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.

  • Custom User Avatar

    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."