commerce icon indicating copy to clipboard operation
commerce copied to clipboard

[4.x]: GQL Query for variant with hasProduct Params return an error

Open aodihis opened this issue 2 years ago • 8 comments

What happened?

Description

In Commerce 4.3.3 when we do query a variant with hasProduct param it will return an error, which on version before this one is fine. Here is our query and the error message.

query:

{
  variant (hasProduct:{slug:"some-slug"}) {
    id
  }
}

error message:

"SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)"

Steps to reproduce

  1. Query a variant with hasProduct param.

Expected behavior

Will return the variant

Actual behavior

giving an error

Craft CMS version

4.5.13

Craft Commerce version

4.3.3

PHP version

No response

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

### Tasks

aodihis avatar Jan 02 '24 02:01 aodihis

Hi @aodihis

Thank you for your feedback.

We have just tried to replicate this issue on the latest version of Commerce 4.x and everything seems to be working as expected.

CleanShot 2024-09-24 at 12 18 27@2x

Is this still an issue for you?

Thanks

nfourtythree avatar Sep 24 '24 11:09 nfourtythree

Closing this as stale, please provide any further feedback here and we can re-open the issue and look into it.

Thanks!

nfourtythree avatar Sep 25 '24 13:09 nfourtythree

Hi @nfourtythree, thank you for your response.

Following up on this issue, our team has continued testing and we've updated Commerce to versions 4.3.3 and higher, including the latest version 4.5.4, but we are still encountering the same error:

Error message:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)

However, when downgrading to Commerce 4.3.2, the query works without any issues.

We’ve attached screenshots showing the error in the newer versions and the successful result in 4.3.2 for comparison. It seems the issue persists in all versions starting from 4.3.3.

Image Image

Additionally, here is the complete error response we received:

{
  "errors": [
    {
      "debugMessage": "SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "trace": [
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Command.php",
          "line": 1320,
          "call": "PDOStatement::execute()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Command.php",
          "line": 1186,
          "call": "yii\\db\\Command::internalExecute()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Command.php",
          "line": 431,
          "call": "yii\\db\\Command::queryInternal()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/db/Query.php",
          "line": 287,
          "call": "yii\\db\\Command::queryOne()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/db/Query.php",
          "line": 280,
          "call": "yii\\db\\Query::one()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/elements/db/ElementQuery.php",
          "line": 1672,
          "call": "craft\\db\\Query::one()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/gql/base/ElementResolver.php",
          "line": 41,
          "call": "craft\\elements\\db\\ElementQuery::one()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 623,
          "call": "craft\\gql\\base\\ElementResolver::resolveOne()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 550,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveFieldValueOrError()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 1195,
          "call": "GraphQL\\Executor\\ReferenceExecutor::resolveField()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 264,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeFields()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/ReferenceExecutor.php",
          "line": 215,
          "call": "GraphQL\\Executor\\ReferenceExecutor::executeOperation()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/Executor/Executor.php",
          "line": 156,
          "call": "GraphQL\\Executor\\ReferenceExecutor::doExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 162,
          "call": "GraphQL\\Executor\\Executor::promiseToExecute()"
        },
        {
          "file": "/var/www/html/vendor/webonyx/graphql-php/src/GraphQL.php",
          "line": 94,
          "call": "GraphQL\\GraphQL::promiseToExecute()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/services/Gql.php",
          "line": 515,
          "call": "GraphQL\\GraphQL::executeQuery()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/controllers/GraphqlController.php",
          "line": 195,
          "call": "craft\\services\\Gql::executeQuery()"
        },
        {
          "call": "craft\\controllers\\GraphqlController::actionApi()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/InlineAction.php",
          "line": 57,
          "function": "call_user_func_array()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Controller.php",
          "line": 178,
          "call": "yii\\base\\InlineAction::runWithParams()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Module.php",
          "line": 552,
          "call": "yii\\base\\Controller::runAction()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 341,
          "call": "yii\\base\\Module::runAction()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 640,
          "call": "craft\\web\\Application::runAction()"
        },
        {
          "file": "/var/www/html/vendor/craftcms/cms/src/web/Application.php",
          "line": 303,
          "call": "craft\\web\\Application::_processActionRequest()"
        },
        {
          "file": "/var/www/html/vendor/yiisoft/yii2/base/Application.php",
          "line": 384,
          "call": "craft\\web\\Application::handleRequest()"
        },
        {
          "file": "/var/www/html/web-cms/index.php",
          "line": 22,
          "call": "yii\\base\\Application::run()"
        }
      ]
    }
  ],
  "data": {
    "variant": null
  }
}

Please let us know if there’s any further information or testing we can assist with to help resolve this.

Thank you.

rezzart-id avatar Oct 11 '24 03:10 rezzart-id

Hi @aodihis

Thank you for your feedback.

Please try updating to the latest Craft (4.12.6.1) and Commerce (4.6.13) and let me know if the issue persists.

If it does can you please send over a database backup and your composer files to [email protected], reference this issue and we can take a further look.

Thanks!

nfourtythree avatar Oct 11 '24 06:10 nfourtythree

@rezzart-id

aodihis avatar Oct 11 '24 12:10 aodihis

Hi @nfourtythree ,

We’ve updated to the latest versions of Craft (4.12.6.1) and Commerce (4.6.13) as suggested, but unfortunately, the issue still persists. The error message remains the same:

SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)

rezzart-id avatar Oct 14 '24 02:10 rezzart-id

Hi @rezzart-id

Thank you for your message.

Could you please send a database backup and your composer files to [email protected] referencing this issue so we can look into it further.

As, unfortunately, at the moment we are unable to replicate what you are seeing.

Thanks!

nfourtythree avatar Oct 15 '24 10:10 nfourtythree

Closing this issue as it has gone stale.

Please let us know if there is any further information to be able to help diagnose the issue.

Thanks!

nfourtythree avatar Jan 20 '25 08:01 nfourtythree