Convert NSString to NSNumber when importing #334

Merged
merged 4 commits into from Jan 25, 2013

Projects

None yet

6 participants

@angelolloqui
Contributor

Problem:

I am working with an app that needs to import data from a Rest API. Everything looks OK, however when importing the data I see some fields in the database that are declared as numbers but the server side gives them inside "", which will consider them a string.

Current result:

The importation fails, and none of the data is imported

Solution:

I implemented a new check in the NSAttributeDescription+MagicalDataImport that, in case of expecting any type of integer, checks if the data is a NSNumber, and if not it tries to convert it.
I also included the unit tests related to it.

Result with the fix:

Strings are converted to numbers when needed, and therefore the data importation works as expected.

I hope you find everything OK and can me merged quickly.
Thanks!

@berikv
berikv commented Dec 7, 2012

Seems sensible to me.

@xslim
xslim commented Dec 7, 2012

I vote for adding this.

@olutsenko

Please add it!

@jstart
jstart commented Jan 21, 2013

+1

@casademora
Member

Apologies for being behind on this one. I'll talk this over with the team, but first impressions for me are pretty good. Thanks for sending this in!

@casademora casademora merged commit 435da59 into magicalpanda:develop Jan 25, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment