HHH-2697 - Can't use := for variable assignment within a SQL-Statement
This commit is contained in:
parent
2e5d707307
commit
9e53118c4e
|
@ -81,6 +81,10 @@ public class ParameterParser {
|
|||
inQuote = true;
|
||||
recognizer.other( c );
|
||||
}
|
||||
else if ( '\\' == c ) {
|
||||
// skip sending the backslash and instead send then next character, treating is as a literal
|
||||
recognizer.other( sqlString.charAt( ++indx ) );
|
||||
}
|
||||
else {
|
||||
if ( c == ':' ) {
|
||||
// named parameter
|
||||
|
|
|
@ -13,12 +13,14 @@ import org.junit.Test;
|
|||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.test.sql.hand.Dimension;
|
||||
import org.hibernate.test.sql.hand.Employment;
|
||||
|
@ -32,6 +34,7 @@ import org.hibernate.test.sql.hand.SpaceShip;
|
|||
import org.hibernate.test.sql.hand.Speech;
|
||||
import org.hibernate.test.sql.hand.TextHolder;
|
||||
import org.hibernate.testing.FailureExpected;
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.SkipForDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.transform.BasicTransformerAdapter;
|
||||
|
@ -833,6 +836,17 @@ public class NativeSQLQueriesTest extends BaseCoreFunctionalTestCase {
|
|||
t.commit();
|
||||
s.close();
|
||||
}
|
||||
@Test
|
||||
@RequiresDialect(MySQL5Dialect.class)
|
||||
public void testEscapeColonInSQL() throws QueryException {
|
||||
Session s = openSession();
|
||||
Transaction t = s.beginTransaction();
|
||||
SQLQuery query = s.createSQLQuery( "SELECT @row \\:= 1" );
|
||||
List list = query.list();
|
||||
assertTrue( list.get( 0 ).toString().equals( "1" ) );
|
||||
t.commit();
|
||||
s.close();
|
||||
}
|
||||
|
||||
private String buildLongString(int size, char baseChar) {
|
||||
StringBuilder buff = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue