mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Change apiJsonObjectToQRecord's includePrimaryKey param to be includeNonEditableFields instead
This commit is contained in:
@ -124,7 +124,7 @@ public class QRecordApiAdapter
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static QRecord apiJsonObjectToQRecord(JSONObject jsonObject, String tableName, String apiName, String apiVersion, boolean includePrimaryKey) throws QException
|
||||
public static QRecord apiJsonObjectToQRecord(JSONObject jsonObject, String tableName, String apiName, String apiVersion, boolean includeNonEditableFields) throws QException
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// make map of apiFieldNames (e.g., names as api uses them) to QFieldMetaData //
|
||||
@ -164,9 +164,9 @@ public class QRecordApiAdapter
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
if(!field.getIsEditable())
|
||||
{
|
||||
if(includePrimaryKey && field.getName().equals(table.getPrimaryKeyField()))
|
||||
if(includeNonEditableFields)
|
||||
{
|
||||
LOG.trace("Even though field [" + field.getName() + "] is not editable, we'll use it, because it's the primary key, and we've been asked to include primary keys");
|
||||
LOG.trace("Even though field [" + field.getName() + "] is not editable, we'll use it, because we've been asked to include non-editable fields");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -40,6 +40,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -189,13 +190,13 @@ class QRecordApiAdapterTest extends BaseTest
|
||||
assertFalse(recordWithoutNonEditableFields.getValues().containsKey("createDate"));
|
||||
assertFalse(recordWithoutNonEditableFields.getValues().containsKey("id"));
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// assert non-editable primary key fields IS included, if so requested //
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////
|
||||
// assert non-editable fields ARE included, if so requested //
|
||||
//////////////////////////////////////////////////////////////
|
||||
QRecord recordWithoutNonEditablePrimaryKeyFields = QRecordApiAdapter.apiJsonObjectToQRecord(new JSONObject("""
|
||||
{"firstName": "Tim", "birthDay": "1976-05-28", "createDate": "2023-03-31T11:44:28Z", "id": 256}
|
||||
"""), TestUtils.TABLE_NAME_PERSON, TestUtils.API_NAME, TestUtils.V2023_Q1, true);
|
||||
assertFalse(recordWithoutNonEditablePrimaryKeyFields.getValues().containsKey("createDate"));
|
||||
assertTrue(recordWithoutNonEditablePrimaryKeyFields.getValues().containsKey("createDate"));
|
||||
assertEquals(256, recordWithoutNonEditablePrimaryKeyFields.getValues().get("id"));
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user