square / ETL

Extract, Transform, and Load data with Ruby
Other
386 stars 28 forks source link

Use IFNULL over COALESCE as it's more appropriate #3

Closed jeffreyiacono closed 11 years ago

JackDanger commented 11 years ago

Can't help you here. I've no fucking idea how coalesce works.

jeffreyiacono commented 11 years ago

(for mysql)

COALESCE: http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_coalesce

vs

IFNULL: http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#function_ifnull

basically, if you are checking one value for NULL, otherwise using a default, use IFNULL. If you are trying to find the first of multiple entries that are not NULL, use COALESCE.

Here we are just checking if something is NULL, otherwise using a default, so IFNULL is the more appropriate function to use I believe

JackDanger commented 11 years ago

Thanks! In that case, LGTM!