Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync export skips over well defined Transformable Attributes #591

Open
ghost opened this issue Mar 5, 2021 · 6 comments
Open

Sync export skips over well defined Transformable Attributes #591

ghost opened this issue Mar 5, 2021 · 6 comments

Comments

@ghost
Copy link

ghost commented Mar 5, 2021

Trying to define array in core data that will import / export with Sync. Defined attribute arrays as per core data documentation. The transformable attributes work fine in my app. They are just failing to import / export. Does Sync handle Transformable data.

Method #1) Loading data into core data . . .

    let newLocation = IARLocation(context: context)
    newLocation.uniqueID = UUID().uuidString
    newLocation.textDescription = "location 1"
    let gpsLocation: [Double] = [Double(1.0), Double(1.3)]
    newLocation.gps = gpsLocation
    newLocation.gpsLatitude = 1.0
    newLocation.gpsLongitude = 1.3

Method #1) Export output for Location entity . . .

"location": {
"gps_latitude" = 1;
"gps_longitude" = "1.3";
"location_image" = {
"image_filename" = "5BBD3652-0D52-41AD-A744-78CB9CBF9D83";
"image_path" = "";
"image_type" = png;
name = locationImage;
"text_description" = "Location Image";
"unique_id" = "5BBD3652-0D52-41AD-A744-78CB9CBF9D83";
};

Method #1) Core Data def
attached location core data def.png

Method #2) Loading data into core data . . .

    let newAddress = IARAddress(context: context)
    newAddress.uniqueID = UUID().uuidString
    newAddress.textDescription = "address 1"
    let gpsAddress: [NSNumber] = [NSNumber(5.0), NSNumber(5.8)]
    newAddress.gps = gpsAddress
    newAddress.gpsLatitude = 5.0
    newAddress.gpsLongitude = 5.8
    newAddress.city = "Whoville"
    newAddress.zipcode = "00000"
    newAddress.state = "WV"
    newAddress.apartment = "3C"
    newAddress.street = "Main"
    newAddress.number = "140303"
    newDoor.address = newAddress

Method #2) Export output for Location entity . . .

    address =         {
        apartment = 3C;
        city = Whoville;
        "gps_latitude" = 5;
        "gps_longitude" = "5.8";
        name = address;
        number = 140303;
        state = WV;
        street = Main;
        "text_description" = "address 1";
        "unique_id" = "91B70457-33DE-48F8-925A-67C6E0C09B58";
        zipcode = 00000;
    };

Method #2) Core Data def
attached address core data def.png

I currently have gpsLatatude and gpsLongitude defined as Doubles in my code data entity attributes just for verification purposes. I would much prefer to use transformable arrays.

Address core data def
Location core data def

@3lvis
Copy link
Owner

3lvis commented Mar 6, 2021

Oh, sorry about this. I merged a PR recently trying to fix some warnings. I see what the problem was. I’m not at home at the moment but will rollback as soon as I can.

@ghost
Copy link
Author

ghost commented Mar 6, 2021

Thank you

@3lvis
Copy link
Owner

3lvis commented Mar 7, 2021

Reverted!

@3lvis
Copy link
Owner

3lvis commented Mar 7, 2021

@richard-hood-motorola-solutions could you double-check if it works now?

@3lvis
Copy link
Owner

3lvis commented Mar 7, 2021

I think I reacted too quickly and you are actually referring to a different issue.

I currently have gpsLatatude and gpsLongitude defined as Doubles in my code data entity attributes just for verification purposes. I would much prefer to use transformable arrays.

I assume your GPS will be a list of doubles but I don't understand how come Latitude and longitude can be arrays?

If you want to store multiple points into one entity doesn't it make more sense to store an array of dictionaries then you can have a latitude and longitude per entry?

The other option is to make a GPSEntity that stores latitude and longitude then you can have a one-to-many relationship between IARLocation and GPSEntity but I don't recommend this. It's better to keep your structure as flat as possible.

Feel free to write me directly https://twitter.com/3lvis

@ghost
Copy link
Author

ghost commented Mar 8, 2021

Attached is a project that illustrates that Sync is not exporting Transformable attributes.

gpsDict is defined as a Dictionary [String:Double] in the data model custom class field
gpsDouble is defined as an Array of doubles [Double] in the data model custom class field
primes is defined as an Array of ints [Int] in the data model custom class field
textTest is defined as an Array of Strings [String] in the data model custom class field

All of which can be accessed in the app as defined but none of which get exported, as is shown in the debug console when you hit the export button. Sync export just seems to skip over those attributes defined as Transformable.

(You may have to hit the export button twice. There seems to be some delay in the DB being updated.)

All of these Transformable types should be exportable, shouldn't they?

Richard Hood
[email protected]
SyncTest.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant