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 ":"; }        }
>> >    }

Reply via email to