|
From: Patrick E. (JIRA) <nh...@gm...> - 2010-09-26 16:27:37
|
[ http://216.121.112.228/browse/NH-2318?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19930#action_19930 ]
Patrick Earl commented on NH-2318:
----------------------------------
I did more playing around with the ordinal parameters. It seemed like there was a lot of essentially duplicate code to deal with the two code paths of ordinal and named parameters. I had some thoughts around the parameter support:
1. There should be a pre-processing step that converts ordinal parameters into named parameters. Since we will potentially want to add / remove parameters later in the processing chain, this should also be the point at which the hql parameter lists are verified against the query contents.
2. All internal processing should be performed against these special named parameters.
3. For the purposes of internal processing, it should be possible to manipulate the parameter list (even adding new parameters) when doing things like ISQLFunction or Linq mapping. It shouldn't be a fixed list that's passed in from the top level that happens to get mapped to various positions in the query. Rather, it should start as a fixed list from the query and be modified by the processing chains.
4. If the database supports named parameters, just execute the query. If not, translate and duplicate the named parameters back into ordinal parameters before executing the query.
5. For things like ISQLFunction, it may be useful to add a "volatile" marker that indicates that the query cache should be bypassed. That way, if the function needs to do processing based on parameter values, it won't break because it was cached and run against different parameters. As an example, to implement NullSafeEquals(x, y), on MSSQL one needs to do something like "(x IS NULL OR y IS NULL) or (x IS NOT NULL AND y IS NOT NULL AND x = y)", but if y is null, you could simply convert it to x IS NULL, making the database query far more efficient, especially if x is a complicated expression.
I'd be happy to chat sometime if you're looking for a sounding board or some brainstorming. Let me know if you'd like help with anything.
> Template functions fail with certain combinations of arguments.
> ---------------------------------------------------------------
>
> Key: NH-2318
> URL: http://216.121.112.228/browse/NH-2318
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.0.0.Alpha2
> Reporter: Patrick Earl
> Assignee: Richard Brown
> Attachments: HqlParameterReordering.patch, SqlFunctionProjectionFix.patch, TrimFunctionsTest.patch
>
>
> Some template functions such as TRIM() fail since they use repeated arguments in the template. Additionally, the LEADING and TRAILING trim emulation functions have their ltrim and rtrim reversed. Included is a unit test that demonstrates that failure.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|