-
Notifications
You must be signed in to change notification settings - Fork 934
NH-3901, NH-3846 - Correct IndexOfGenerator index offsets #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Tests are failing. I think the correct collection assertion is 'Is.EquivalentTo' |
That is odd. All of the tests pass locally. And I don't want
EquivalentTo(), because that doesn't validate order, which should be the
same for both collections.
|
ab469d5
to
2d58e31
Compare
I found (and fixed) a subtler bug with the way that postgres (and SybaseASE15) calculate the position when a starting at an offset. But I still can't get the tests to pass for test methods that take a character. As a note, these tests used to never actually execute anything to the DB or assert anything. So maybe they never were working. |
By default it's Microsoft Sql Server. |
No, check the tests. They are failing because the results of the query are different. |
Yes, sorry. I rechecked the documentation and you are right. Is equivalent |
You can run the tests same way as team city by using ShowBuildMenu.bat |
Yes, and I have now. |
cc7a6a6
to
64bcfad
Compare
Parameter types are inferred for any constants with non-null values. The problem is that (for MSSQL, and maybe others) the inference is a fixed length string. Which is, as far as I can tell, never correct. So I changed the |
I think you need to change HqlGenerator instead of how the function renders. |
I needed to fix both. There are a few different bugs here because the tests never actually checked for expected results. The changes to The changes to Finally, the changes to |
But in HQL you do not need to extract -1, as it shall have the SQL meaning
|
I would argue (and @patearl agrees) that translating in the SQL is better. Here's a trivial example: Now I want to generate a query where the characters and offsets from the first table are used to parse and return values from the second table. Since the offsets are 0-based (as is all my data, coming from C#), I shouldn't need to know that the query is going to be executed in SQL and have to add any adjustment. Therefore the SQL generated should include the -1 offset to correct to C# space. |
Actually... now that I'm using my brain, that was an overly complicated example.
Since the entire expression will be translated to HQL (and then to SQL), the -1 offset needs to be applied in HQL otherwise operation will be incorrect. Or am I misunderstanding something? |
I agree that
Where What I'm trying to say here:
|
Ok, I understood your changes now. Good to go. |
Please rebase on master. Various long-failing tests have been fixed. |
Rebase done |
Will this be included in 4.1.0? |
I wonder if this can be experienced as a breaking change to existing code that have been tested with current behaviour. |
It could be. People would have written expressions like However, if they were doing this, you'd think that this would have been noticed earlier. My issue is that the expressions are now not equivalent, so to do this kind of in-place patch I'd need to swap expressions depending on whether the execution NH or memory. |
Thanks for this fix! |
This translates the IndexOf (locate) result back into 0-based index space (NH-3901) and translates the
startAt
position into 1-based index space (NH-3846).