Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
aodihis opened this issue Jan 2, 2024 · 8 comments
Open

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

aodihis opened this issue Jan 2, 2024 · 8 comments
Assignees
Labels
commerce4 Issues related to Commerce v4 ℹ️ status: need more info When waiting for user to supply database or more information.

Comments

@aodihis
Copy link

aodihis commented Jan 2, 2024

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

No tasks being tracked yet.
@aodihis aodihis added commerce4 Issues related to Commerce v4 bug labels Jan 2, 2024
@nfourtythree
Copy link
Contributor

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 nfourtythree added ℹ️ status: need more info When waiting for user to supply database or more information. and removed bug labels Sep 24, 2024
@nfourtythree
Copy link
Contributor

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

Thanks!

@rezzart-id
Copy link

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.

@nfourtythree
Copy link
Contributor

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 nfourtythree reopened this Oct 11, 2024
@aodihis
Copy link
Author

aodihis commented Oct 11, 2024

@rezzart-id

@rezzart-id
Copy link

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)

Copy link

linear bot commented Oct 15, 2024

@nfourtythree
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commerce4 Issues related to Commerce v4 ℹ️ status: need more info When waiting for user to supply database or more information.
Projects
None yet
Development

No branches or pull requests

3 participants