vadimtsushko / objectory

Unsupported: Objectory - object document mapper for server-side and client side Dart applications
MIT License
55 stars 12 forks source link

Issue with runtimeType.toString() #30

Open kaisellgren opened 11 years ago

kaisellgren commented 11 years ago

So, as per this issue: https://code.google.com/p/dart/issues/detail?id=10334

It seems we have to change how Objectory works.

In case you haven't got to the bottom of this, the issue seems to be with using runtimeType.toString() to identify objects in mongo database.

This dbType is either 'Tag' when running in VM(Dartium) or 'Tag0' when running dart2js generated javascript. It can be just 'Tag' in dart2js js if there no other uses of Tag. That's why I believe changing edit_group.dart/html fixes the issue.

kaisellgren commented 11 years ago

There's an attached sample project that fails, I'll also add the link here for easier access: https://docs.google.com/file/d/0B8bfJ10MXQKZSGlYeHN3UWhmQ2c/edit?usp=sharing

Repro:

1) Pub install 2) Install Mongodb, have it running at default ports 3) dart run.dart 4) dart build.dart 5) dart2js web/out/index.html_bootstrap.dart -o'web/out/index.html_bootstrap.dart.js' 6) Open the web/out/index.html in Dartium and Chrome.

In Dartium you see the "test" printed on the console, but not in Chrome/Fx.

vadimtsushko commented 11 years ago

So string representation of runtimeType of class is undefined at dart2js. It mean it is not suitable as a dbType (actially Collection name in MongoDB)

Save path is to override dbType method in each PersistentObject class in your domain model, for example

String dbType => 'Tag'
kaisellgren commented 11 years ago

This fixed all our issues with these nulls. :)

However, everyone else will face the same problem since all you need is to use persistent list and dart2js...

We need to place that in the docs so people specify the collection name or we find a real solution that is independent from the user of this library (the optimal choice).

I'll leave this task open, you can decide if this is solved or not.

vadimtsushko commented 11 years ago

One solution is to remove default implementation in base class (change to Error 'Must be implemented') Then all clients unifirmely would have to implement dbType. It somewhat unnececcary on server side objectory though - so such clients would be unduly affected

I'll think about it