Skip to content
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

MSSQLServer and RQL with Offset/Fetch throws exceptions #565

Closed
Voscha opened this issue Jun 30, 2022 · 3 comments
Closed

MSSQLServer and RQL with Offset/Fetch throws exceptions #565

Voscha opened this issue Jun 30, 2022 · 3 comments
Assignees
Labels
accepted Issue has been accepted and inserted in a future milestone as-designed The behaviour is correct/expected enhancement

Comments

@Voscha
Copy link

Voscha commented Jun 30, 2022

The following RQL from the sample "activerecord_showcases" throws an exception with MS SQLServer:

cRQL2 = 'and(eq(City,"Rome"),or(contains(CompanyName,"GAS"),contains(CompanyName,"Motors")))';
...
lCustList := TMVCActiveRecord.SelectRQL<TCustomer>(cRQL2, 20);

because the resulting SQL has no ORDER BY clause:

'SELECT id, code,description,city,rating,note FROM customers WHERE ((city = ''Rome'') and ((LOWER(description) LIKE ''%gas%'') or (LOWER(description) LIKE ''%motors%''))) /*limit*/ OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY'

Offset/Fetch have to be used with the order by clause, I think this must be done in the SQL generator of MS SQLServer.

@danieleteti danieleteti self-assigned this Jun 30, 2022
@danieleteti danieleteti added the as-designed The behaviour is correct/expected label Jun 30, 2022
@danieleteti
Copy link
Owner

This is the approach with the less level of "surprise". The only thing we could do is to raise a specific exception before returning the (wrong) statement. What's you POV about the "solution" for this issue? In other words, what should happend using an RQL exception like gt("id", 1);limit(10)?

@Voscha
Copy link
Author

Voscha commented Jul 1, 2022

Perhaps add a default sort on the primary key in the sql generator if there is no specific sort in the RQL? so we could avoid to raise an exception.

@danieleteti danieleteti added enhancement accepted Issue has been accepted and inserted in a future milestone labels Jul 31, 2022
@danieleteti danieleteti added this to the 4.0.0-oxygen milestone Jul 31, 2022
@danieleteti
Copy link
Owner

I decided to switch this issue in the 3.2.2-nitrogen. Please, check if it works on your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Issue has been accepted and inserted in a future milestone as-designed The behaviour is correct/expected enhancement
Projects
None yet
Development

No branches or pull requests

2 participants