Raven 3.0 SQL replication problem

65 views
Skip to first unread message

Yanjie Zhou

unread,
Jun 1, 2015, 5:36:16 PM6/1/15
to rav...@googlegroups.com
Hi,

When I moving sql replication scripts from Raven 2.5 to Raven 3.0, I find some problem:
 I have one collection that some documents' structure are different from others, for example

 Normal document : 
{
Profile:
{
FirstName : "ddd",
MiddleName : "hhh",
LastName : "aaa"
}
Email : "xxxxxx@xxx",
DateOfDirth : "1999/1/1",
Address : 
{
Street : "dddddddddddd",
City : "hhhhhh"
State : "llll"
}
}

But when I have some document like :

{
Profile:
{
FirstName : "ddd",
MiddleName : "hhh",
LastName : "aaa"
}
Email : "xxxxxx@xxx",
        Gender : uuuu,
DateOfDirth : "1999/1/1",
Address : 
{
Street : "dddddddddddd",
City : "hhhhhh"
State : "llll"
}
}

And in the SQL replication script I want to map Gender value into the SQL side. 
Previously in 2.5, Raven mapping will automatically replicate all the documents and just leave the column to null when the document doesn't have the Gender part, but in 3.0 it will throw errors consider the documents without Gender part have some problem and didn't replicate the document at all. So How can I resolve this problem?


Another problem is if some part of the document is null, like:
{
Profile:
{
FirstName : "ddd",
MiddleName : "hhh",
LastName : "aaa"
}
Email : "xxxxxx@xxx",
Gender : uuuu,
DateOfDirth : "1999/1/1",
Address : null
}

If I use the mapping in the SQL replication code like : 

Street : this.Address.Street,

It will throw an error to me said Address is null and didn't replicate the document at all in Raven 3.0. But in 2.5 it will automatically make the Street column on SQL side to null without any error occur. How can I resolve this problem?



Thank you


Yanjie Zhou

Maxim Buryak

unread,
Jun 3, 2015, 7:37:17 AM6/3/15
to rav...@googlegroups.com
Hi,
I've confirmed the difference in behavior between the versions. The reason is different versions of the Jint version: 2.5 uses an earlier version, that did not follow the ECMA standard as closely as the version used in 3.0.
I would recommend to add validation code in javascript, that will prevent such situations, and send null explicitly in those cases



Best Regards,

Hibernating Rhinos Ltd  cid:image001.png@01CF95E2.8ED1B7D0

Maxim Buryak l Core Team Developer Mobile:+972-54-217-7751

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

RavenDB paving the way to "Data Made Simplehttp://ravendb.net/  



--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yanjie Zhou

unread,
Jun 3, 2015, 11:14:25 AM6/3/15
to rav...@googlegroups.com
Hi,

I think I can add those validations to the scripts but I think that will be better if they can be dealt with by the document database itself? As there will be a lot of this kind of situations, like object is null or some documents' structure different, happen all the time in the document database. It will be good if the database itself can deal with those kinds of situations.



Thank you


Yanjie Zhou

Oren Eini (Ayende Rahien)

unread,
Jun 3, 2015, 3:25:39 PM6/3/15
to ravendb
That isn't something that we can handle, we need to match the ECMA compact requirements here.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

James Tan

unread,
Jun 3, 2015, 4:45:57 PM6/3/15
to rav...@googlegroups.com
So this is break changes that 2.5 handle it well but 3.0 cannot handle it due to more compliance? This seems does not make lot sense to me.

Thanks

James

Oren Eini (Ayende Rahien)

unread,
Jun 4, 2015, 4:53:57 AM6/4/15
to ravendb
It shouldn't have worked. Null references in JS are always meant to break.


Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


James Tan

unread,
Jun 4, 2015, 10:51:52 AM6/4/15
to rav...@googlegroups.com
Oren,

My understanding is even it worked in 2.5, it was not by design or it happened work just because of sort of "good bug"?
We will look into it.

Thanks

James
Reply all
Reply to author
Forward
0 new messages