mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-16 21:01:10 +08:00
51 lines
1.4 KiB
Java
51 lines
1.4 KiB
Java
/*
|
|
* Copyright (c) 2010 Mysema Ltd.
|
|
* All rights reserved.
|
|
*
|
|
*/
|
|
package com.mysema.query.sql;
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
import org.junit.Test;
|
|
|
|
import com.mysema.query.sql.AbstractSQLQuery.UnionBuilder;
|
|
import com.mysema.query.types.path.SimplePath;
|
|
|
|
|
|
public class SQLServerTemplatesTest extends AbstractSQLTemplatesTest{
|
|
|
|
@Override
|
|
@Test
|
|
public void NoFrom(){
|
|
query.getMetadata().addProjection(new SimplePath<Integer>(Integer.class,"1"));
|
|
assertEquals("select 1", query.toString());
|
|
}
|
|
|
|
@Override
|
|
protected SQLTemplates createTemplates() {
|
|
return new SQLServerTemplates();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Test
|
|
@Override
|
|
public void Union(){
|
|
SimplePath<Integer> one = new SimplePath<Integer>(Integer.class,"1");
|
|
SimplePath<Integer> two = new SimplePath<Integer>(Integer.class,"2");
|
|
SimplePath<Integer> three = new SimplePath<Integer>(Integer.class,"3");
|
|
SimplePath<Integer> col1 = new SimplePath<Integer>(Integer.class,"col1");
|
|
UnionBuilder union = query.union(
|
|
sq().unique(one.as(col1)),
|
|
sq().unique(two),
|
|
sq().unique(three));
|
|
assertEquals(
|
|
"(select 1 as col1) " +
|
|
"union " +
|
|
"(select 2) " +
|
|
"union " +
|
|
"(select 3)", union.toString());
|
|
}
|
|
|
|
}
|