Open wuzhuobin opened 5 years ago
I think this is because SQLite3.prototype.fromColumnValue
does not do anything beyond a JSON-decode for buffer -- it was never updated for LB4. I believe a change like the following will work:
SQLite3.prototype.fromColumnValue = function(property, value) {
if (value == null || !property) {
return value;
}
switch (property.type.name) {
case 'Number':
return (+value);
case 'Boolean':
return (
value === 'Y' || value === 'y' ||
value === 'T' || value === 't' ||
value === '1' || value === 1
);
case 'String':
return String(value);
case 'Date':
return new Date(value);
case 'Buffer':
return Buffer.from(JSON.parse(value));
case 'GeoPoint':
case 'Point':
case 'List':
case 'Array':
case 'Object':
case 'ModelConstructor':
case 'JSON':
default:
return JSON.parse(value);
}
};
Well, it might work. I have zero idea how all this works given the upper/lowercase difference from what's on https://loopback.io/doc/en/lb4/LoopBack-types.html.
Storing Buffer as a JSON array in text is also one of the worst ways to do it. This stuff really should've been an sqlite BLOB. Maybe use better-sqlite3
which does that and is faster?
Bug or feature request
Description of feature (or steps to reproduce if bug)
Currently, I am using this with loopback4. But the connector does not provide some type support such as, Buffer or Array. They will all turn into TXET in sqlite3. And more importantly, the 'Buffer' seems to work quite well. When i wrote something to a 'Buffer' property, it will ture in to some TEXT like