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
bindParam missing from AbstractDataType type definition #11550
Comments
Hello, can you please show some code that should compile but doesn't? Thanks |
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 import { AbstractDataType } from 'sequelize';
import Big from 'big.js';
export default class BigType implements AbstractDataType {
public dialectTypes: string = '';
public key: string = 'NUMERIC';
toSql(): string {
return 'NUMERIC';
}
toString(): string {
return 'NUMERIC';
}
stringify(value: Big): string {
return value.toString();
}
bindParam(value: Big): string {
return value.toString();
}
_sanitize(value: string): Big {
return Big(value);
}
parse(value: string): Big {
return Big(value);
}
} When I ported from v4 to v5 I noticed that my queries were failing. I traced the problem down to missing the After debugging by digging into the query generator code, I realized that I needed to add the |
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!! |
Yep. I believe that would do it.
I took a quick look at the issue and my initial impression is maybe the missing |
@defunctzombie Thank you!! I will look into it |
Is this issue still awaiting any other feedback? |
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. 🙂 |
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.The text was updated successfully, but these errors were encountered: