Add case sql expression to models