Debian Codegraph @

src/main/org/h2/expression/condition/ExistsPredicate.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: H2 Group
5 */
6 package org.h2.expression.condition;
7
8 import org.h2.command.query.Query;
9 import org.h2.engine.SessionLocal;
10 import org.h2.value.Value;
11 import org.h2.value.ValueBoolean;
12
13 /**
14 * Exists predicate as in EXISTS(SELECT ...)
15 */
16 public class ExistsPredicate extends PredicateWithSubquery {
17
18 public ExistsPredicate(Query query) {
19 super(query);
20 }
21
22 @Override
23 public Value getValue(SessionLocal session) {
24 query.setSession(session);
25 return ValueBoolean.get(query.exists());
26 }
27
28 @Override
29 public StringBuilder getUnenclosedSQL(StringBuilder builder, int sqlFlags) {
30 return super.getUnenclosedSQL(builder.append("EXISTS"), sqlFlags);
31 }
32
33 }