• mlegrand
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

You have an object with a picklist that contains three values, x, y and z. For testing purposes, you create a record of that object type with a value of "a" in the picklist - Apex allows you to do this. There are already records in the database withvalues of x, y or z in the picklist.

 

You then have a query (after the test has created the record with the "a" value in the picklist) that runs like this:

 

 

Some_Object__c so = [select ID from Some_Object__c order by Your_Picklist_field__c asc nulls last limit 1];

 

 

Which record is returned from the database? The one with "a"? No - for some reason this is the last record returned by the query.

 

Can anyone else confirm this, and if there's anything obvious I'm missing to get what I think should be the expected result - the value inserted by the test is the returned record?

  • October 29, 2010
  • Like
  • 0