-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
it should be possible to turn off type casting #2596
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
Comments
I turn of typecasting like this. but it should be easier. import pg from 'pg';
var types = pg.types;
function noParse(val) {
return String(val);
}
for (let dataType of Object.keys(types.builtins)) {
types.setTypeParser(types.builtins[dataType], noParse);
} |
Config option: types: {
getTypeParser: () => String,
}, Easy enough for how niche it is, and it’s nice to have defaults that allow switching to binary mode. The issue with dates is being tracked elsewhere.
Not sure what you mean by this. pg tries its best to serialize values symmetrically. |
I need low level postgres driver for node that returns actual values from database as string. Type casting will be handled on higher level. |
it is for a test? it's easy enough to get back at the string from a Date. |
Sorry for very late answer. this is something that annoys me everytime. It is not for testing only. I just want to simply set typeCasting off. Just like MySql driver. I use Knex and on top of that there is a simple ORM module which handles type casting (in two way). So I expect to get actual SQL string data from database tables. |
there are (were) other people that suffers from the same problem. |
+1
|
In my opinion type-casting should not be done in this level. It should be done in higher level ORM like libraries.
Type casting in here is one-way. Only for result of SELECTs. It cannot be done for in INSERTs and UPDATES or WHEREs in queries.
This may make testing tricky. You insert a date value, but it may be different when you read it according to timezone. Floats may be slightly different also, because of rounding etc.
in mysql driver it is possible to turn of type casting by typeCast: false and also dateStrings: true.
The text was updated successfully, but these errors were encountered: