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

QueryTimeout is always overwritten in the QueryHelper.CreateQueryFactory #345

Closed
Mostafa-Elmoghazi opened this issue Feb 6, 2020 · 5 comments · Fixed by #552
Closed

Comments

@Mostafa-Elmoghazi
Copy link

Mostafa-Elmoghazi commented Feb 6, 2020

Hello,

I've started using the SqlKata library recently in a data analytical project that depends heavily on dynamic queries. I'me working on very complicated queries that sometimes take a bit long time to execute. I'm facing an issue while setting the timeout of the query on SqlKata. I've set the timeout on the QueryFactory instance I've created to 5000000 but the query still times out. When I looked at the source code of execution library, I found this:

Given the following code:
var db = new QueryFactory(connection, compiler);
db.QueryTimeout = 5000000;
var result = db.Query("ApplicationUsers").Get<dynamic>();

Here Get function calls QueryHelper.CreateQueryFactory which recreate a new QueryFactory instance with QueryTimeout property set to its default 30.

How can I get my own QueryFactory instance execute the query with my set QueryTimeout value and without getting new instance of QueryFactory created?

Note: I'm using the latest stable version v1.1.7

@ahmad-moussawi

@ahmad-moussawi
Copy link
Contributor

Hi @Mostafa-Elmoghazi could you please try the latest version, available as pre-release https://www.nuget.org/packages/SqlKata/2.0.2-ci-771 and confirm if this issue persist or not?

@ahmad-moussawi
Copy link
Contributor

Closing due to no response, feel free to reopen for any further feedback.

@nicolasfatoux
Copy link

This issue is still present in version 2.3.2

In Query.Extensions.cs the CreateQueryFactory method creates a new QueryFactory from the xQuery, but it doesn't set the timeout on that QueryFactory.

@Thowk
Copy link

Thowk commented Feb 2, 2022

@ahmad-moussawi Issue still exists in current v2.3.7. In Query.Extensions (line 369)
var factory = new QueryFactory(xQuery.Connection, xQuery.Compiler);
I believe it should be fixed to:
var factory = new QueryFactory(xQuery.Connection, xQuery.Compiler, xQuery.QueryFactory.QueryTimeout);

@ahmad-moussawi
Copy link
Contributor

Thanks @nicolasfatoux, @Thowk.
I've pushed a PR now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants