use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class RelationalFunctionCallTest method twoArgs.
@Test
public void twoArgs() {
StringPath str = Expressions.stringPath("str");
RelationalFunctionCall<String> functionCall = SQLExpressions.relationalFunctionCall(String.class, "getElements", "a", str);
assertEquals("getElements({0}, {1})", functionCall.getTemplate().toString());
assertEquals("a", functionCall.getArg(0));
assertEquals(str, functionCall.getArg(1));
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class PrecedenceTest method test.
@Test
public void test() {
StringPath str1 = Expressions.stringPath("str1");
StringPath str2 = Expressions.stringPath("str2");
BooleanExpression pending = str1.eq("3").and(str2.eq("1"));
BooleanExpression notNew = str1.ne("1").and(str2.in("2", "3"));
BooleanExpression whereClause = str1.eq("a").and(pending.or(notNew));
String str = new SQLSerializer(Configuration.DEFAULT).handle(whereClause).toString();
assertEquals("str1 = ? and (str1 = ? and str2 = ? or str1 != ? and str2 in (?, ?))", str);
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class AliasTest method various1.
@Test
public void various1() {
StringPath str = Expressions.stringPath("str");
assertEquals(Arrays.asList("a", "ab"), from(str, "a", "ab", "cd", "de").where(str.startsWith("a")).select(str).fetch());
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class CollQueryTemplatesTest method concat.
@Test
public void concat() {
StringPath a = Expressions.stringPath("a");
StringPath b = Expressions.stringPath("b");
Expression<?> expr = a.append(b).toLowerCase();
String str = new CollQuerySerializer(CollQueryTemplates.DEFAULT).handle(expr).toString();
assertEquals("(a + b).toLowerCase()", str);
}
use of com.querydsl.core.types.dsl.StringPath in project querydsl by querydsl.
the class CollQueryTest method various.
@Test
public void various() {
StringPath a = Expressions.stringPath("a");
StringPath b = Expressions.stringPath("b");
for (Tuple strs : from(a, "aa", "bb", "cc").from(b, Arrays.asList("a", "b")).where(a.startsWith(b)).select(a, b).fetch()) {
assertEquals(strs.get(a), strs.get(b) + strs.get(b));
}
query().from(cat, cats).select(cat.mate).fetch();
query().from(cat, cats).select(cat.kittens).fetch();
query().from(cat, cats).where(cat.kittens.isEmpty()).select(cat).fetch();
query().from(cat, cats).where(cat.kittens.isNotEmpty()).select(cat).fetch();
query().from(cat, cats).where(cat.name.matches("fri.*")).select(cat.name).fetch();
}
Aggregations