mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
added more tests
This commit is contained in:
parent
d0da315d09
commit
f1194c3af5
@ -1,11 +1,12 @@
|
||||
Naming options :
|
||||
|
||||
Caps start : (domainType.firstName Like "An%") And (domainType.firstName Like "Be%")
|
||||
|
||||
Full caps : (domainType.firstName LIKE "An%") AND (domainType.firstName LIKE "Be%")
|
||||
|
||||
_ : (domainType.firstName _like "An%") _and (domainType.firstName _like "Be%")
|
||||
|
||||
_ : (domainType.firstName like_ "An%") and_ (domainType.firstName like_ "Be%")
|
||||
|
||||
$ : (domainType.firstName $like "An%") $and (domainType.firstName $like "Be%")
|
||||
|
||||
Caps start : (domainType.firstName Like "An%") And (domainType.firstName Like "Be%")
|
||||
|
||||
Full caps : (domainType.firstName LIKE "An%") AND (domainType.firstName LIKE "Be%")
|
||||
|
||||
@ -40,24 +40,21 @@ object Conversions {
|
||||
implicit def timePath(t: java.sql.Time): TimePath[java.sql.Time] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def comparablePath(c: Comparable[_]): ComparablePath[_] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
//implicit def simplePath(s: Object): SimplePath[_] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def entityPath(arg: Object): EntityPathImpl[_] = {
|
||||
var rv : EntityPathImpl[_] = aliasFactory.getCurrentAndReset();
|
||||
if (rv != null) {
|
||||
rv;
|
||||
}else {
|
||||
arg match {
|
||||
case x:EntityPathImpl[_] => x;
|
||||
case x:ManagedObject => x.__mappedPath.asInstanceOf[EntityPathImpl[_]];
|
||||
case _ => null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
implicit def numberPath[N <: Number with Comparable[N]](n: N): NumberPath[N] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def bytePath(n: Byte): NumberPath[java.lang.Byte] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def intPath(n: Int): NumberPath[Integer] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def longPath(n: Long): NumberPath[java.lang.Long] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def shortPath(n: Short): NumberPath[java.lang.Short] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def doublePath(n: Double): NumberPath[java.lang.Double] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def floatPath(n: Float): NumberPath[java.lang.Float] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def scalaCollectionPath[T](c: scala.Collection[T]): CollectionPath[T] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def scalaListPath[T](l: scala.List[T]): ListPath[T] = aliasFactory.getCurrentAndReset();
|
||||
@ -74,6 +71,21 @@ object Conversions {
|
||||
|
||||
implicit def javaMapPath[K,V](l: java.util.Map[K,V]): MapPath[K,V] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
//implicit def simplePath(s: Object): SimplePath[_] = aliasFactory.getCurrentAndReset();
|
||||
|
||||
implicit def entityPath(arg: Object): EntityPathImpl[_] = {
|
||||
var rv : EntityPathImpl[_] = aliasFactory.getCurrentAndReset();
|
||||
if (rv != null) {
|
||||
rv;
|
||||
}else {
|
||||
arg match {
|
||||
case x:EntityPathImpl[_] => x;
|
||||
case x:ManagedObject => x.__mappedPath.asInstanceOf[EntityPathImpl[_]];
|
||||
case _ => null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PathFactoryImpl extends PathFactory {
|
||||
|
||||
@ -89,8 +89,6 @@ trait SetExpression[T] extends CollectionExpressionBase[java.util.Set[T]] { }
|
||||
|
||||
trait ListExpression[T] extends CollectionExpressionBase[java.util.List[T]] {
|
||||
|
||||
// TODO : get(Expression[Integer]) / get(Integer)
|
||||
|
||||
}
|
||||
|
||||
trait MapExpression[K,V] extends SimpleExpression[java.util.Map[K,V]] with ParametrizedExpression[java.util.Map[K,V]]{
|
||||
@ -109,8 +107,6 @@ trait MapExpression[K,V] extends SimpleExpression[java.util.Map[K,V]] with Param
|
||||
|
||||
def _containsValue(v: Expression[V]) = boolean(CONTAINS_KEY, this, v);
|
||||
|
||||
// TODO : get
|
||||
|
||||
}
|
||||
|
||||
trait ComparableExpressionBase[T <: Comparable[_]] extends SimpleExpression[T] {
|
||||
|
||||
@ -37,6 +37,14 @@ class AliasTest {
|
||||
assertEquals("!domainType.firstName like An%", notClause.toString);
|
||||
}
|
||||
|
||||
@Test
|
||||
def Number_Usage(){
|
||||
assertEquals("domainType.scalaInt < 5", (domainType.scalaInt _lt 5).toString);
|
||||
assertEquals("domainType.javaInt < 5", (domainType.javaInt _lt 5).toString);
|
||||
assertEquals("domainType.scalaInt between 2 and 3", (domainType.scalaInt _between (2,3)).toString);
|
||||
assertEquals("domainType.javaInt between 2 and 3", (domainType.javaInt _between (2,3)).toString);
|
||||
}
|
||||
|
||||
@Test
|
||||
def Java_Collection_Usage(){
|
||||
// size
|
||||
|
||||
@ -2,6 +2,10 @@ package com.mysema.query.scala;
|
||||
|
||||
class DomainType {
|
||||
|
||||
var scalaInt: Int = _;
|
||||
|
||||
var javaInt: Integer = null;
|
||||
|
||||
var firstName: String = null;
|
||||
|
||||
var lastName: String = null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user