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

Make all params named params #162

Conversation

elexisvenator
Copy link
Contributor

@elexisvenator elexisvenator commented Jan 3, 2025

Needed by JasperFx/marten#3604

Update the BatchBuilder to add all positional parameters as named parameters. This is the same behavior as CommandBuilder.

Under the hood what is going on is that if there is a mix of positional and named parameters, then npgsql does not edit the query to normalise all parameters. This results in postgres throwing an error (cant mix positional and named parameters). If there were only positional parameters (old behaviour), the npgsql will rewrite the query to convert all positional params to named params. This is done for maximum compatibility. The easiest way to make things consistently work is to make all positional params as named params from the start, which is what CommandBuilder/CommandBuilderBase does.

This may be a breaking change - but only if people were already using named parameters with the batch builder and only if they were naming their params p0, p1, etc.

Update the `BatchBuilder` to add all positional parameters as named parameters. This is the same behavior as `CommandBuilder`.

Under the hood what is going on is that if there is a mix of positional and named parameters, then npgsql does not edit the query to normalise all parameters. This results in postgres throwing an error (cant mix positional and named parameters).  If there were only positional parameters (old behhaviour), the npgsql will rewrite the query to convert all positional params to named params. This is done for maximum compatibility.  The easiest way to make things consistently work is to make all positional params as named params from the start, which is what `CommandBuilder`/`CommandBuilderBase` does.

This _may_ be a breaking change - but only if people were already using named parameters with the batch builder and only if they were naming their params `p0`, `p1`, etc.
@jeremydmiller
Copy link
Member

@elexisvenator Hey man, sorry, this one is a no go. We very specifically rebuilt BatchBuilder to use positional parameters because that prevents Npgsql from having to do a conversion internally.

@elexisvenator
Copy link
Contributor Author

Backing out of this

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 this pull request may close these issues.

2 participants