wovalle / fireorm

ORM for firestore 🔥
https://fireorm.js.org
MIT License
560 stars 76 forks source link

Error retrieving document with GeoPoint type field #48

Closed ghost closed 5 years ago

ghost commented 5 years ago

I am having an issue with the latest version since class-transformer was introduced. I have a document that has a GeoPoiont field. Whenever I try to read one of these documents, I get the following error message.

Error: Value for argument "latitude" is not a valid number.

Stack Trace: [1] > at TransformOperationExecutor.transform (C:\MaxxInnova\workspaces\pilotcar\node_modules\fireorm\node_modules\class-transformer\TransformOperationExecutor.js:260:17) [1] > at ClassTransformer.plainToClass (C:\MaxxInnova\workspaces\pilotcar\node_modules\fireorm\node_modules\class-transformer\ClassTransformer.js:17:25) [1] > at Object.plainToClass (C:\MaxxInnova\workspaces\pilotcar\node_modules\fireorm\node_modules\class-transformer\index.js:20:29) [1] > at BaseFirestoreRepository.extractTFromDocSnap (C:\MaxxInnova\workspaces\pilotcar\node_modules\fireorm\lib\src\BaseFirestoreRepository.js:79:46) [1] > at Array.map () [1] > at BaseFirestoreRepository.extractTFromColSnap (C:\MaxxInnova\workspaces\pilotcar\node_modules\fireorm\lib\src\BaseFirestoreRepository.js:96:27)

Example: https://github.com/dietrichwestbrooks/fireorm-geopoint

wovalle commented 5 years ago

Hey, I'm currently on vacations. I'll be able to check this out next week.

wovalle commented 5 years ago

Just got time to replicate this. It is related to class-transformer, how to solve it.

mamodom commented 5 years ago

This issue describes exactly what's happening, class-transformer is newing up a Geopoint with no constructor arguments which are required by its constructor

wovalle commented 5 years ago

Damn @mamodom you're a beast! Checking your pr right now!

whateverbot commented 5 years ago

:tada: This issue has been resolved in version 0.6.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

wovalle commented 5 years ago

Hey @dietrichwestbrooks, I managed to push a temporary fix for this bug. You can read more about this in the README and see an example in the unit tests.

ghost commented 5 years ago

Yes, this is the issue. I used the @Type(() => Object) approach to get around the issue.

On Fri, Jun 21, 2019 at 6:17 PM Maximo Dominguez notifications@github.com wrote:

This issue https://github.com/typestack/class-transformer/issues/174 describes exactly what's happening, class-transformer is newing up a Geopoint with no constructor arguments which are required by its constructor https://github.com/googleapis/nodejs-firestore/blob/master/dev/src/geo-point.ts#L49

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wovalle/fireorm/issues/48?email_source=notifications&email_token=AFPNN74ZJ7BZIQVG27QSAWTP3VOQRA5CNFSM4HYCCBKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYJZWEY#issuecomment-504601363, or mute the thread https://github.com/notifications/unsubscribe-auth/AFPNN746D2HUUSW3KM3LO2DP3VOQRANCNFSM4HYCCBKA .

wovalle commented 5 years ago

Nice! In the future I'll provide a better way to do this, but for now the decorator does the job.