dotJS 2012 – Brian Leroux – WTFJS

Back in 2012 at dotJS – which I attended – Brian Leroux gave his talk WTFJS. Somehow the video of that talk got recommended on YouTube to me. It was fun watching this again 🙂

Gotta love coercion 😍

Also: Wat?

MySQL behaviour you should be aware of

I suggest changing the syntax for NOT NULL to “NOT” NULL.

If you’re not checking all values in your code logic (viz. PHP code or something like that) before attempting to perform the database manipulation you can fix it by (manually) add triggers to your tables to actually prevent a faulty insert/update:

mysql> CREATE TRIGGER check_constraint BEFORE INSERT ON table_name
    -> BEGIN
    ->   DECLARE error_msg varchar(255);
    ->   IF NEW.column_name = '' THEN
    ->     SET error_msg = 'Constraint my_constraint violated: ...';
    ->     SIGNAL SQLSTATE '45000' SET message_text = error_msg;
    ->   END IF;
    -> END;