From 8d677f2b92645e7339fca0fdc9929cb06863e820 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 19 Dec 2008 20:56:19 +0000 Subject: [PATCH] HHH-3670 - Invalid test for str() for SQL Server and Sybase git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15713 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../hibernate/test/hql/ASTParserLoadingTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java b/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java index 6f16d9dab3..7c4c33df11 100644 --- a/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java +++ b/testsuite/src/test/java/org/hibernate/test/hql/ASTParserLoadingTest.java @@ -1194,13 +1194,18 @@ public class ASTParserLoadingTest extends FunctionalTestCase { 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") );