Start a new topic

Relational Data equals nil in new version 1.41.0

Hi

I updated kinvey version from 1.40.9 to 1.41.0 and get issue. I have relation one-to-many (Labrary - Books). When I try to retrieve data I receive array of books but all attributes of books is nil.

Could you fix it, its critical issue for me?

Best Regards

Wood


any news?

Wood,

Was this code working with the earlier version of the Kinvey SDK? Which was that version?


Can you please send the necessary code that will help reproduce the issue?

Thanks,
Pranav
Kinvey Support

 

Hi


Yes my code was  working with earlier version of the Knives SDK (1.40.9)


   

-(void) retrieveUserBooksFromKinvey{
        KCSLinkedAppdataStore* store= [KCSLinkedAppdataStore storeWithOptions:@{ KCSStoreKeyCollectionName : @"Libraries",
                                                                                 KCSStoreKeyCollectionTemplateClass : [Libraries class]}];
        
        KCSQuery *q2 =[KCSQuery queryOnField:@"libraryOwner._id" withExactMatchForValue:[KCSUser activeUser].userId];         
        [store queryWithQuery:q2 withCompletionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil) {
            if (errorOrNil != nil) {
            } else
            {
                Libraries* library = objectsOrNil[0];
                self.navigationItem.title=library.title;
                [_userBookArray addObjectsFromArray:[library.books allObjects]];
                numberOfBooks =[NSString stringWithFormat:@"%ld", (long) (int) _userBookArray.count];
                
            }
            
            [_userTableView reloadData];
        }withProgressBlock:nil];

    
    
}
 

   

Hello Wood Wayfarer,


I have some additional questions and a request.


There is a later version of the iOS SDK v1.41.1 that may have fixed this problem. Please upgrade to this latest version of the SDK and let us know if this is still a problem or not.


If you are still seeing this issue, please send us the application source code related to this functionality so that we can review it? 


When sending the source code, please provide the specific steps that you are using to reproduce the problem.


Regards,


Billy



Hi


 v1.41.1 doesn't fix it.


I have two tables  Libraries and Books and they have relation one-to-Many. So Libraries table has parameter books which include information about books in this library. For example:



[

  {

    "_collection": "Books",

    "_id": "0435ADFA-A502-41A4-8F01-F92E9FAC61EC",

    "_type": "KinveyRef"

  },

  {

    "_collection": "Books",

    "_id": "7AB8D211-1AA1-4EA1-9F29-1ED85F76A561",

    "_type": "KinveyRef"

  },

  {

    "_collection": "Books",

    "_id": "9FC4D5FE-33EC-4D40-820F-C03FFA086EE1",

    "_type": "KinveyRef"

  }

]


 I tried to get all books from library  ( value books includes array of Books objects.) However all parameters of book object is equal nil except bookId.


This is my method to get books from library


  

-(void) retrieveUserBooksFromKinvey{
        KCSLinkedAppdataStore* store= [KCSLinkedAppdataStore storeWithOptions:@{ KCSStoreKeyCollectionName : @"Libraries",
                                                                                 KCSStoreKeyCollectionTemplateClass : [Libraries class]}];
        
        KCSQuery *q2 =[KCSQuery queryOnField:@"libraryOwner._id" withExactMatchForValue:[KCSUser activeUser].userId];         
        [store queryWithQuery:q2 withCompletionBlock:^(NSArray *objectsOrNil, NSError *errorOrNil) {
            if (errorOrNil != nil) {
            } else
            {
                Libraries* library = objectsOrNil[0];
  for(Books * book in  library.books){
                NSLog(@"%@", book.bookTitle);
// title equal nil and other params too
            }
                self.navigationItem.title=library.title;
                [_userBookArray addObjectsFromArray:[library.books allObjects]];
                numberOfBooks =[NSString stringWithFormat:@"%ld", (long) (int) _userBookArray.count];
                
            }
            
            [_userTableView reloadData];
        }withProgressBlock:nil];

    
    
}
 

  



Wood,

Can you please send the Libraries and Books class that implements the KCSPersistable protocol?

Thanks,
Pranav
Kinvey Support

 

Libraries.h

 

@interface Libraries  : NSObject <KCSPersistable>

@property (nonatomic, copy, readonly) NSString *libraryObjectId;
@property (nonatomic, copy) CLLocation* libraryCoordinate;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, retain)  KCSUser *libraryOwner;
@property (nonatomic, retain) NSMutableSet *books;


@property (nonatomic, readonly) CLLocationCoordinate2D* coordinate;
@property (nonatomic, readonly) CLLocation* coordinateForSearch;
@property (nonatomic, copy, readonly) NSString *libraryOwnerName;
@property (nonatomic, assign, readonly) double distanceToLibrary;

 Libraries.m

 

@implementation Libraries
- (NSDictionary *)hostToKinveyPropertyMapping
{
    return @{
             @"libraryObjectId" : KCSEntityKeyId, //the required _id field
             @"title" : @"name",
             @"libraryCoordinate" : KCSEntityKeyGeolocation,
             @"libraryOwner" : @"libraryOwner",
             @"books":@"books"
             };
}

+ (NSDictionary *)kinveyPropertyToCollectionMapping
{
    return @{ @"libraryOwner" : KCSUserCollectionName ,@"books" : @"Books"};
}


+(NSDictionary *)kinveyObjectBuilderOptions
{
    // reference class map - maps properties to objects
    return @{ KCS_REFERENCE_MAP_KEY : @{ @"books" : [Books class]}};
}

 


Books.h

 

@interface Books : NSObject <KCSPersistable>

//@protocol MKAnnotation <NSObject>


// @optional
// Title and subtitle for use by selection UI.
@property (nonatomic, copy, readonly) NSString *bookObjectId;
@property (nonatomic, copy) NSString *bookTitle;
@property (nonatomic, copy) NSString *author;
@property (nonatomic, copy) UIImage *bookCoverage;
@property (nonatomic, copy) NSURL *bookCoverageURL;

@property (nonatomic, copy) NSString *bookStatus;
@property (nonatomic, copy)  NSString *userIdSendRequestForBook;

 Books.m

 

@implementation Books

- (NSDictionary *)hostToKinveyPropertyMapping
{
    return @{
             @"bookObjectId" : KCSEntityKeyId, //the required _id field
             @"bookTitle" : @"title",
             @"author" : @"author",
             @"bookCoverage" : @"coverage"
             
             };
}

 

Wood,

Can you please check this : If you do not have the “libraryOwner” field in the Libraries class, does it make any difference? Let me know.

Thanks,
Pranav
Kinvey Support

 

Hi Pranav .I cannot exclude field “libraryOwner” from the Libraries class. How its possible that it worked in previous version ? Looks like you didn't test this functionality. Did you try to reproduce it ?

Best Regards

Alex

Wood,

Can you make support@kinvey.com a collaborator on your app, that will help me reproduce this issue quickly on my end and then get engineering inputs on it?

 

Thanks,

Pranav

Kinvey Support

Pranav,


I cannot do this at the moment beacuse I have Development plan (


Thanks


Login or Signup to post a comment