added example for SQL injection

This commit is contained in:
Timo Westkämper 2010-09-24 11:59:32 +00:00
parent 332d6206b5
commit 3eb6cd2c7a

View File

@ -0,0 +1,26 @@
package com.mysema.query.scala.sql
import com.mysema.query.sql._
import com.mysema.query.types.Predicate
import com.mysema.query.types.template.BooleanTemplate
import org.junit.Test
import org.junit.Assert._
class InjectionTest {
implicit def asPredicate(str: String): Predicate = BooleanTemplate.create(str);
@Test
def Injection() {
val c = QCategory as "c";
val sq = query from c where "c.name like \"a%\"" list c;
assertEquals("c.name like \"a%\"", sq.getMetadata.getWhere.toString);
}
def query() = new SQLSubQuery();
}