-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix query with lots of nullable columns creating stack overflow #10
Conversation
Split out read
src/DbTests/SQL/ManyColumns.sql
Outdated
@@ -0,0 +1,601 @@ | |||
SELECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you replace this script with the following, which does the same in a lot fewer lines?
DECLARE @numCols INT = 600
DECLARE @sql NVARCHAR(MAX) = 'SELECT '
DECLARE @colNo INT = 1
WHILE (@colNo <= @numCols)
BEGIN
SET @sql += 'Column' + CAST(@colNo AS NVARCHAR) + ' = NULL' + CASE @colNo WHEN @numCols THEN '' ELSE ', ' END
SET @colNo += 1
END
EXEC sp_executesql @sql
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code swapped out
src/DbTests/facil.yaml
Outdated
@@ -192,6 +192,8 @@ rulesets: | |||
tvp: | |||
type: dbo.SingleColNonNull | |||
|
|||
- for: ManyColumns.sql |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty for
has no effect, this can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
src/Facil.Generator/Render.fs
Outdated
yield! indent [ | ||
for c in cols do | ||
if c.IsNullable then | ||
$"let ``value_{c.Name.Value}`` = if reader.IsDBNull ``ordinal_{c.Name.Value}`` then {outOptionNone} else reader.{c.TypeInfo.SqlDataReaderGetMethodName} ``ordinal_{c.Name.Value}`` |> {outOptionSome}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any point to prefixing with value_
? If not, I suggest removing the prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value_
has been removed
I think there could be some other places |
@cmeeren I have run the code gen on my project that was throwing the stack overflow and it now works :) |
Thanks a lot! |
This is a test for #9