Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Single character literals do not work #24

Closed
ErisDS opened this issue Jul 31, 2017 · 4 comments
Closed

Single character literals do not work #24

ErisDS opened this issue Jul 31, 2017 · 4 comments
Labels

Comments

@ErisDS
Copy link
Member

ErisDS commented Jul 31, 2017

Originally reported in TryGhost/Ghost#8433

To reproduce:

  • On a local blog...
  • Create a post with the title A, the slug will be a. Publish the post.
  • Create a post with the title AB, the slug will be ab. Publish the post.
  • Visit the frontend of the blog to grab the client secret.
  • Open postman
  • Try doing a get request for http://localhost:2368/ghost/api/v0.1/posts?client_id=ghost-frontend&client_secret=[client-secret]&filter=slug:ab - see that it works
  • Try doing a get request for http://localhost:2368/ghost/api/v0.1/posts?client_id=ghost-frontend&client_secret=[client-secret]&filter=slug:a - see that it doesn't work

I believe this is due to the plus sign here: https://github.com/TryGhost/GQL/blob/master/src/gql.l#L22

The badcharsincnot regex matches a single character, and then the second group matches a second character. Therefore there must be at least 2 chars for a match.

Fixing this may have other implications, if so, we should close this issue and instead, add a rule that literals must be at least 2 characters to the documentation, provide tests to demo this limitation + if possible, improve the error message.

@kirrg001
Copy link
Contributor

kirrg001 commented Oct 3, 2017

I am also unable to request an empty string e.g. featured_image:"".

Error: Query Error: unrecognized text "'" in filter at char 24
at Object.lexer.parseError (ghost/node_modules/ghost-gql/dist/parser.js:707:11)

Maybe this has the same underlying problem, if not, let me know. Then i can raise a different issue.

@ErisDS
Copy link
Member Author

ErisDS commented Oct 3, 2017

GQL uses single quotes for strings and doesn't recognise your double quotes, hence the error.

@kirrg001
Copy link
Contributor

kirrg001 commented Oct 3, 2017

Single quotes didn't work either, tested both.

aileen added a commit to aileen/Ghost that referenced this issue Feb 27, 2018
closes TryGhost#9085

Fixes an issue, where the client sets image properties to `""` after deleting the image. This causes problems with the query filter (see TryGhost/GQL#24), as they have to be `null`.

Added a check in the model layer saving method to set value  to `null`, when the property is empty.

Affected models and properties:
- `posts`:
	- `feature_image`
	- `og_image`
	- `twitter_image`
- `users`:
	- `profile_image`
	- `cover_image`
- `tags`:
	- `feature_image`
kirrg001 pushed a commit to TryGhost/Ghost that referenced this issue Mar 5, 2018
closes #9085

Fixes an issue, where the client sets image properties to `""` after deleting the image. This causes problems with the query filter (see TryGhost/GQL#24), as they have to be `null`.

Added a check in the model layer saving method to set value  to `null`, when the property is empty.

Affected models and properties:
- `posts`:
	- `feature_image`
	- `og_image`
	- `twitter_image`
- `users`:
	- `profile_image`
	- `cover_image`
- `tags`:
	- `feature_image`
@kirrg001
Copy link
Contributor

GQL was replaced with NQL.

This issue is tracked here now.

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

No branches or pull requests

2 participants