From 1e175bf5ee38164bfa11cb6d3ad92cb44dfd0376 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Fri, 19 Dec 2008 20:55:04 +0000 Subject: [PATCH] HHH-3670 - Invalid test for str() for SQL Server and Sybase git-svn-id: https://svn.jboss.org/repos/hibernate/core/branches/Branch_3_2@15711 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../hibernate/test/hql/ASTParserLoadingTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/org/hibernate/test/hql/ASTParserLoadingTest.java b/test/org/hibernate/test/hql/ASTParserLoadingTest.java index fd05d0dfe8..8727906de1 100644 --- a/test/org/hibernate/test/hql/ASTParserLoadingTest.java +++ b/test/org/hibernate/test/hql/ASTParserLoadingTest.java @@ -1191,13 +1191,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") );