ufront / ufront-orm

The Object Relational Mapper, allows easy, type-safe access to your database. Builds on Haxe's SPOD but adds macro powered relationships, validation and client side usage
MIT License
13 stars 4 forks source link

ValidationErrors map populated with duplicate values on validation #11

Open milkmangames opened 9 years ago

milkmangames commented 9 years ago

Have a subclass of ufront.db.Object with 4 fields.

Create a new instance and set each field to a value that will not validate (null):

var myObject=new MyObject();
myObject.field1=null;
myObject.field2=null;
myObject.field3=null;
myObject.field4=null;

object.validate();
trace(object.validationErrors);

Result: for each key, the validation error is repeated 4 times, i.e.:

[ field1: [ "field1 is a required field", "field1 is a required field", "field 1 is a required field", "field1 is a required field"] ] 

...and so on.

milkmangames commented 9 years ago

Whoops, this is not a problem with the lib.

Restarting haxe fixed the problem, and the number of repeated values grows with each compilation until its restarted again. So it appears to something with haxe macros and progressive compilation.

jasononeil commented 9 years ago

I think there are several issues with the compilation server at the moment. I'm re-opening this so I can try figure it out.

milkmangames commented 9 years ago

Cool thanks. See likely related posts here https://groups.google.com/forum/m/#!topic/haxelang/fCBCbUwTn5E

jasononeil commented 9 years ago

I've got some unit tests for validation now, I haven't run them with the compilation server, but they're passing when the compilation server is disabled. I'll try that next

jasononeil commented 9 years ago

Unit tests are still failing validation when using the compiler cache, but all other tests are passing. So other than getting multiple validation messages, the key functionality is actually working. I started trying to look into this, didn't make much progress today but will look again soon.

jasononeil commented 9 years ago

There is a workaround by @theRemix:

https://github.com/ufront/ufront-orm/commit/d60de85eb94bb515b53a90c07ce97e7079517cf1

I'm going to leave this issue open until I can fix it in DBMacros though, which would feel more correct.