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

Column Suffixes #93

Open
andrewfairlie opened this issue Jul 7, 2023 · 2 comments
Open

Column Suffixes #93

andrewfairlie opened this issue Jul 7, 2023 · 2 comments

Comments

@andrewfairlie
Copy link

andrewfairlie commented Jul 7, 2023

Craft introduced column suffixes for new fields, but it seems like the GraphQL queries on Preparse fields aren't querying against the field column. Unsure if this is a Craft bug or Preparse Field bug.

EG: Our test query

{
  events:entries(section:"events", calendarDatesEnd: "now", limit: 1){
    title
    ... on events_default_Entry {
      calendarDatesEnd
    }
  }
}

Returns the following SQL error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'content.field_calendarDatesEnd' in 'where clause'

The column is actually content.field_calendarDatesEnd_urqjyipm because of the suffix Craft adds.

@andrewfairlie
Copy link
Author

andrewfairlie commented Jul 7, 2023

Updating https://github.com/besteadfast/craft-preparse-field/blob/develop/src/fields/PreparseFieldType.php#L231C1-L231C1

to the following solves the suffix bug.

use craft\helpers\ElementHelper;
                $column = ElementHelper::fieldColumnFromField($this);
                $query->subQuery->andWhere(Db::parseDateParam("content.$column", $value));

However this then reveals a second bug on this part where you can't actually query based on time

Query

{
  events:entries(section:"events", calendarDatesStart: ">now"){
    title
    ... on events_default_Entry {
      calendarDatesEnd
    }
  }
}

Response

  "errors": [
    {
      "debugMessage": "SQLSTATE[HY000]: General error: 1525 Incorrect DATETIME value: 'now'",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },

@andrewfairlie
Copy link
Author

@jalendport is this one you would be able to look into please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant