 
 		case .unary(let unary, let ex):
 			newSelf = .unary(try unary.visit(visitor), try ex.visit(visitor))
+
+		case .when(let whens, else: let e):
+			newSelf = .when(try whens.map {
+				return SQLWhen(when: try $0.when.visit(visitor), then: try $0.then.visit(visitor))
+			}, else: try e?.visit(visitor))
 		}
 
 		return try visitor.visit(expression: newSelf)

	case allColumns
	case null
	case variable(String)
	indirect case binary(SQLExpression, SQLBinary, SQLExpression)
	indirect case unary(SQLUnary, SQLExpression)


			self.stack.append(.expression(.binary(left, op, right)))
		})/~)

		add_named_rule("ex-case-when", rule:
			Parser.matchLiteralInsensitive("CASE") => {
				self.stack.append(.expression(SQLExpression.when([], else: nil)))
			}
			~~ ((Parser.matchLiteralInsensitive("WHEN") ~~ ^"ex-equality" ~~ Parser.matchLiteralInsensitive("THEN") ~~ ^"ex-equality") => {
				guard case .expression(let then) = self.stack.popLast()! else { fatalError() }
				guard case .expression(let when) = self.stack.popLast()! else { fatalError() }
				guard case .expression(let caseExpression) = self.stack.popLast()! else { fatalError() }
				guard case .when(var whens, else: _) = caseExpression else { fatalError() }
				whens.append(SQLWhen(when: when, then: then))
				self.stack.append(.expression(SQLExpression.when(whens, else: nil)))
			})+
			~~ (((Parser.matchLiteralInsensitive("ELSE") ~~ ^"ex-equality") => {
				guard case .expression(let then) = self.stack.popLast()! else { fatalError() }
				guard case .expression(let caseExpression) = self.stack.popLast()! else { fatalError() }
				guard case .when(let whens, else: _) = caseExpression else { fatalError() }
				self.stack.append(.expression(SQLExpression.when(whens, else: then)))
			})/~)
			~~ Parser.matchLiteralInsensitive("END"))

		add_named_rule("ex", rule: ^"ex-case-when" | ^"ex-equality")

		add_named_rule("order-direction", rule:
			(Parser.matchLiteralInsensitive("ASC") => {
