mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
added example for SQL injection
This commit is contained in:
parent
332d6206b5
commit
3eb6cd2c7a
@ -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();
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user