Author: gbadner
Date: 2008-12-19 15:54:13 -0500 (Fri, 19 Dec 2008)
New Revision: 15710
Modified:
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java
Log:
JBPAPP-1523 HHH-3670 - Invalid test for str() for SQL Server and Sybase
Modified:
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java
===================================================================
---
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2008-12-19
19:05:29 UTC (rev 15709)
+++
core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/ASTParserLoadingTest.java 2008-12-19
20:54:13 UTC (rev 15710)
@@ -1152,13 +1152,18 @@
Animal an = new Animal();
an.setBodyWeight(123.45f);
session.persist(an);
- String str = (String) session.createQuery("select str(an.bodyWeight) from Animal
an where str(an.bodyWeight) like '123%' or str(an.bodyWeight) like
'1.23%'").uniqueResult();
+ String str = (String) session.createQuery("select str(an.bodyWeight) from Animal
an where str(an.bodyWeight) like '%1%'").uniqueResult();
if ( getDialect() instanceof DB2Dialect ) {
assertTrue( str.startsWith("1.234") );
}
- else if ( getDialect() instanceof SQLServerDialect ) {
- // no assertion as SQLServer always returns nulls here; even trying directly against
the
- // database, it seems to have problems with str() in the where clause...
+ else if ( getDialect() instanceof SybaseDialect ) {
+ // str(val) on sybase assumes a default of 10 characters with no decimal point or
decimal values
+ // str(val) on sybase result is right-justified
+ assertEquals( str.length(), 10 );
+ assertTrue( str.endsWith("123") );
+ str = (String) session.createQuery("select str(an.bodyWeight, 8, 3) from Animal
an where str(an.bodyWeight, 8, 3) like '%1%'").uniqueResult();
+ assertEquals( str.length(), 8 );
+ assertTrue( str.endsWith( "123.450" ) );
}
else {
assertTrue( str.startsWith("123.4") );
Show replies by date