I have created a bug report for this issue, ticket NH-3004, and a unit test which does not require ADS to run. The unit test is in the same form as those found in the NHSpecificTest folder in the NHibernate.Test project.
Please can you let me know how I should submit this test? I have also created a fix for the bug, please can you let me know the best way to submit this fix? Thanks Michael On Jan 5, 11:32 am, "Richard Brown \(gmail\)" <[email protected]> wrote: > A failing test might be tricky without writing it specifically for ADS - and > since we don't have ADS on our TeamCity server, it might never get run > anyway. > > Another option would be to override that method in the ADS driver: > > public MyAdsDriver : IDriver > { > ... > void IDriver.RemoveUnusedCommandParameters(IDbCommand cmd, SqlString > sqlString) > { > // do nothing > } > ... > > > > > > > > } > -----Original Message----- > From: Oskar Berggren > Sent: Tuesday, January 03, 2012 4:52 PM > To: [email protected] > Subject: Re: [nhibernate-development] Re: Bug found in > > DriverBase.RemoveUnusedCommandParameters > > Yes, please create a bug report and a simple test case that can > inserted in NHibernate's tests. > > /Oskar > > 2011/12/28 Mike Charalambous <[email protected]>: > > Hi Julian > > > I have downloaded and built the latest trunk and have found the issue > > is still there. > > > The issue is slightly different than bug 2893, which is talking about > > when the assigned parameter names are ?. In this case the Advantage > > DBMS the parameter name is :p0 in SQL and p0 in the parameter > > collection. RemoveUnusedCommandParameters does not take into account > > that the SQL and parameter collection names can differ. So any query > > with a parameter, such as > > > Session.CreateQuery("from WebUser u where u.Inactive > > = :inactive").SetParameter("inactive", false).List<WebUser>(); > > > fails with the exception > > > Advantage.Data.Provider.AdsException : Error 7200: AQE Error: State > > = 07002; NativeError = 2141; [iAnywhere Solutions][Advantage SQL > > Engine]Parameter missing AdsCommand query execution failed. > > > Would it be best if I created a bug report for this issue? > > > Regards > > Michael > > > On Dec 28, 2:15 am, Julian Maughan <[email protected]> wrote: > >> Thanks for raising this. I believe it is fixed in the upcoming NHibernate > >> release. Have a look at this bug report: > > >>https://nhibernate.jira.com/browse/NH-2893 > > >> If you can't wait for an official release, you can download > >> (https://github.com/nhibernate/nhibernate-core) and compile the source > >> code. > > >> Regards > >> Julian > > >> On 27 December 2011 03:34, Mike Charalambous > >> <[email protected] > > >> > wrote: > >> > Hi > > >> > I have recently written a NHibernate driver for the Sybase Advantage > >> > Database Server (ADS), and have across a bug in the function > >> > RemoveUnusedCommandParameters when running queries with parameters in > >> > them. This bug means that all parameters are removed by > >> > RemoveUnusedCommandParameters instead of just the ones which are > >> > unused. Please see the bottom of my post for the driver code. > > >> > The heart of the issue is that ADS requires a prefix to be used when > >> > referring to parameters in SQL, but not when the parameter is in the > >> > parameter collection. The RemoveUnusedCommandParameters function does > >> > not take into account that the parameter name can have a prefix in the > >> > SQL and not in the parameter collection and so removes all parameters > >> > from the command object. > > >> > I think the fix for this issue is straightforward and as far as I can > >> > tell will not cause any issues with existing drivers. The code: > > >> > .Select(p => p.ParameterName) > > >> > should be changed to: > > >> > .Select(p => FormatNameForSql(p.ParameterName)) > > >> > I have created a unit test for this issue but it requires binaries for > >> > the Advantage Database Server. Is this okay? > > >> > Thanks > > >> > Mike Charalambous > > >> > public class SybaseAdsClientDriver : > >> > NHibernate.Driver.ReflectionBasedDriver > >> > { > >> > public SybaseAdsClientDriver() > >> > : base("Advantage.Data.Provider", > >> > "Advantage.Data.Provider.AdsConnection", > >> > "Advantage.Data.Provider.AdsCommand") > >> > { > >> > } > > >> > public override bool UseNamedPrefixInSql > >> > { get { return true; } } > > >> > public override bool UseNamedPrefixInParameter > >> > { get { return false; } } > > >> > public override string NamedPrefix > >> > { get { return ":"; } } > >> > }
