Fixing the usage of ternary operator in model which caused Empty Query error

Fixed the Empty Query error caused by incorrect usage of the ternary operator.