Search in sources :

Example 11 with StringPath

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));
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 12 with StringPath

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);
}
Also used : BooleanExpression(com.querydsl.core.types.dsl.BooleanExpression) StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 13 with StringPath

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());
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 14 with StringPath

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);
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Test(org.junit.Test)

Example 15 with StringPath

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();
}
Also used : StringPath(com.querydsl.core.types.dsl.StringPath) Tuple(com.querydsl.core.Tuple) Test(org.junit.Test)

Aggregations

StringPath (com.querydsl.core.types.dsl.StringPath)33 Test (org.junit.Test)33 DefaultQueryMetadata (com.querydsl.core.DefaultQueryMetadata)6 QueryMetadata (com.querydsl.core.QueryMetadata)6 Tuple (com.querydsl.core.Tuple)4 QTuple (com.querydsl.core.types.QTuple)2 LuceneSerializer (com.querydsl.lucene5.LuceneSerializer)2 Ignore (org.junit.Ignore)2 ExcludeIn (com.querydsl.core.testutil.ExcludeIn)1 JavaTemplates (com.querydsl.core.types.JavaTemplates)1 Predicate (com.querydsl.core.types.Predicate)1 BooleanExpression (com.querydsl.core.types.dsl.BooleanExpression)1 PhraseElement (com.querydsl.lucene5.PhraseElement)1 TermElement (com.querydsl.lucene5.TermElement)1 BigDecimal (java.math.BigDecimal)1