@aws-amplify/datastore 3.7.4-custom-pk.90 → 3.7.4-custom-pk.92

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -82863,7 +82863,7 @@ function () {
82863
82863
 
82864
82864
  this.query = function (modelConstructor, identifierOrCriteria, paginationProducer) {
82865
82865
  return __awaiter(_this, void 0, void 0, function () {
82866
- var msg, modelDefinition, keyFields, predicate, pagination, result, returnOne;
82866
+ var msg, modelDefinition, keyFields, predicate, msg, pagination, result, returnOne;
82867
82867
  return __generator(this, function (_a) {
82868
82868
  switch (_a.label) {
82869
82869
  case 0:
@@ -82893,6 +82893,14 @@ function () {
82893
82893
  keyFields = Object(_util__WEBPACK_IMPORTED_MODULE_12__["extractPrimaryKeyFieldNames"])(modelDefinition);
82894
82894
 
82895
82895
  if (isQueryOne(identifierOrCriteria)) {
82896
+ if (keyFields.length > 1) {
82897
+ msg = _util__WEBPACK_IMPORTED_MODULE_12__["errorMessages"].queryByPkWithCompositeKeyPresent;
82898
+ logger.error(msg, {
82899
+ keyFields: keyFields
82900
+ });
82901
+ throw new Error(msg);
82902
+ }
82903
+
82896
82904
  predicate = _predicates__WEBPACK_IMPORTED_MODULE_8__["ModelPredicateCreator"].createForSingleField(modelDefinition, keyFields[0], identifierOrCriteria);
82897
82905
  } else {
82898
82906
  // Object is being queried using object literal syntax
@@ -97494,7 +97502,8 @@ var __values = undefined && undefined.__values || function (o) {
97494
97502
 
97495
97503
  var ID = 'id';
97496
97504
  var errorMessages = {
97497
- idEmptyString: 'An index field cannot contain an empty string value'
97505
+ idEmptyString: 'An index field cannot contain an empty string value',
97506
+ queryByPkWithCompositeKeyPresent: 'Models with composite primary keys cannot by queried by a single key value. Use object literal syntax for composite keys instead: https://docs.amplify.aws/lib/datastore/advanced-workflows/q/platform/js/#querying-records-with-custom-primary-keys'
97498
97507
  };
97499
97508
  function extractKeyIfExists(modelDefinition) {
97500
97509
  var _c;