You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bindParam missing from AbstractDataType type definition #11550
status: understoodFor issues. Applied when the issue is understood / reproducible.typescriptFor issues and PRs. Things that involve typescript, such as typings and intellisense.
The bindParam function is missing from the AbstractDataTypes type definition. The result is that a user who implements a custom type must be aware to also implement the bindParam function if they want to do custom escaping or formatting of their type when used with the bind query interface.
Previously it was enough to just support stringify but this is no longer the case with the new bind based query builder.
Absolutely. Tho the issue isn't that the code doesn't compile - its that without the bindParam being a required method to define my custom type did not work properly.
Below is my custom type definition which is meant to be a wrapper around the postgres NUMERIC type using the big.js library to support arbitrary precision and accurate decimal math operations in my application logic.
When I ported from v4 to v5 I noticed that my queries were failing. I traced the problem down to missing the bindParam method from my implementation. Without this method present in the class, the queries were not serializing properly - this was a runtime error rather than compile time error.
After debugging by digging into the query generator code, I realized that I needed to add the bindParam method but this method was not part of AbstractDataType and so was not obvious to me that I needed to include it in my type for it to properly serialize. If the bindParam method was in the interface I would have gotten a build time error (what I wanted to see) and it would be obvious that I am missing an important method for proper functioning of my custom type.
Ah, interesting! Thanks for the explanation and sorry to take so long to reply. It looks like fixing this is quite simple then, just adding one line to the type declarations, am I right? Or did I misunderstand something?
Also, by the way, since I noticed you are implementing a custom data type, is there any chance you could take a look at this issue to see if you have any ideas? #11177 Many people is currently having trouble to make a custom data type work - myself included. The steps provided in our current docs don't work. Thank you!!
just adding one line to the type declarations, am I right
Yep. I believe that would do it.
Also, by the way, since I noticed you are implementing a custom data type, is there any chance you could take a look at this issue to see if you have any ideas? #11177 Many people is currently having trouble to make a custom data type work - myself included.
I took a quick look at the issue and my initial impression is maybe the missing bindParam implementation. The referenced issue starts with someone wanting to implement a custom big number datatype - which is exactly what I needed. The code I pasted above should work for that use case (it does for me) granted I am using postgres rather than mysql as the original issue states.
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂
status: understoodFor issues. Applied when the issue is understood / reproducible.typescriptFor issues and PRs. Things that involve typescript, such as typings and intellisense.
Activity
papb commentedon Oct 30, 2019
Hello, can you please show some code that should compile but doesn't? Thanks
defunctzombie commentedon Nov 6, 2019
Absolutely. Tho the issue isn't that the code doesn't compile - its that without the bindParam being a required method to define my custom type did not work properly.
Below is my custom type definition which is meant to be a wrapper around the postgres NUMERIC type using the
big.jslibrary to support arbitrary precision and accurate decimal math operations in my application logic.When I ported from v4 to v5 I noticed that my queries were failing. I traced the problem down to missing the
bindParammethod from my implementation. Without this method present in the class, the queries were not serializing properly - this was a runtime error rather than compile time error.After debugging by digging into the query generator code, I realized that I needed to add the
bindParammethod but this method was not part ofAbstractDataTypeand so was not obvious to me that I needed to include it in my type for it to properly serialize. If thebindParammethod was in the interface I would have gotten a build time error (what I wanted to see) and it would be obvious that I am missing an important method for proper functioning of my custom type.papb commentedon Jan 15, 2020
Ah, interesting! Thanks for the explanation and sorry to take so long to reply. It looks like fixing this is quite simple then, just adding one line to the type declarations, am I right? Or did I misunderstand something?
Also, by the way, since I noticed you are implementing a custom data type, is there any chance you could take a look at this issue to see if you have any ideas? #11177 Many people is currently having trouble to make a custom data type work - myself included. The steps provided in our current docs don't work. Thank you!!
defunctzombie commentedon Jan 18, 2020
Yep. I believe that would do it.
I took a quick look at the issue and my initial impression is maybe the missing
bindParamimplementation. The referenced issue starts with someone wanting to implement a custom big number datatype - which is exactly what I needed. The code I pasted above should work for that use case (it does for me) granted I am using postgres rather than mysql as the original issue states.papb commentedon Jan 19, 2020
@defunctzombie Thank you!! I will look into it
defunctzombie commentedon Sep 11, 2021
Is this issue still awaiting any other feedback?
github-actions commentedon Nov 6, 2021
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂