7

While fetching object using query only certain columns are fetched and the rest is nil. I have also tried fetchIfNeededInBackgroundWithBlock but with no luck.

Query:

let query = PFQuery(className:"Order")
query.whereKey("buyerUser", equalTo: PFUser.currentUser()!)
query.findObjectsInBackgroundWithBlock { (orders: [PFObject]?, error: NSError?) -> Void in
    if(error == nil){
        print(orders?.first)
    }
}

Output:

Optional(<Order: 0x7ff778011940, objectId: KytyBZD9zV, localId: (null)> {
buyerUser = "<PFUser: 0x7ff77353e520, objectId: xxxxx, localId: (null)>";
charged = 1;
fulfilled = 0;
item = "<Item: 0x7ff778011dd0, objectId: GN277W4mO0, localId: (null)>";
shippingUser = "<PFUser: 0x7ff778012270, objectId: xxxx, localId: (null)>";
stripePaymentId = "xxxxxx";})

Order class in Parse Data Browser

Order Class

If I try to access the transactionId with following code:

let order = orders?.first
print(order.objectForKey("transactionId"))

The result is always nil.

Please help.

Update

Attached is the Order class data in Parse. As all the rows have data and the object I have used have returned some data in other columns (buyerUser, charged) there is data in transactionId column of the object.

Parse Order Class Data

19
  • @sushithe is there any data in the parse data browser for transactionId? Or is it an empty column at the moment
    – Kelvin Lau
    Commented Nov 27, 2015 at 6:30
  • @Sushilthe, Can you test this print(order["transactionId"])? I believe the problem is that you are dealing with a PFObject class object as a dictionary.
    – NSNoob
    Commented Nov 27, 2015 at 6:30
  • @KelvinLau See his comment on on Girish Kolari's answer.
    – NSNoob
    Commented Nov 27, 2015 at 6:31
  • 1
    Also it would be helpful if you could share structure of your parse class named Orders. Because in the printing of the PFObject I dont see anything for transactionId in your shared log.
    – NSNoob
    Commented Nov 27, 2015 at 6:34
  • 2
    I am not trying to prove anything I am only making my assessment based on the data you provided. You did ask the community members to help right? Unless I am mistaken of course. If you are absolutely sure that for this object there is definitely data in column, then do explain why Parse is not returning it with the object? And I don't know why you are taking that tone when I am rising legit points based on the very limited data that you are providing. Show us this object in the data browser if you are sure transaction is not nil and we will all be satisfied.
    – NSNoob
    Commented Nov 27, 2015 at 7:36

1 Answer 1

4

I can not see "transactionId" in the console message you posted - if key you are looking for is not present it will return nil

charged = 1; fulfilled = 0; item = ""; shippingUser = ""; stripePaymentId = "xxxxxx";})

Update: Server information and message in the console don'e match eq: Order: 0x7fb253fedc80, objectId: WrgiDFxZW6 which can not be located in the server data attached with question.

It can happen if your are referring different table in Parse SDK than the one you used in web(screen shot) - make sure you are refereeing same table in code and web.

2
  • 1
    The problem is, I cannot see the key in the console while the column is present in the Parse Data Browser.
    – Sushil
    Commented Nov 18, 2015 at 6:12
  • 2
    Presence of column does not mean it will necessarily contain data as well unless you have done complete flawless form validation and written some cloud code to reject an entry with a nil transaction id. Grish Kolari is right it is not there in your log.
    – NSNoob
    Commented Nov 27, 2015 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.