-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Enum support #36
Comments
I guess I found my answer: https://github.com/khaosdoctor/gotql#enum-args |
Re-opening because this: on_conflict: {
constraint: {value: 'subscriptions_pkey', escape: false},
update_columns: [
{value: 'status', escape: false},
{value: 'price', escape: false},
],
}, results in this query:
|
on_conflict: {
constraint: {value: 'subscriptions_pkey', escape: false},
update_columns: {
value: ['status', 'price'],
escape: false,
},
}, almost works:
|
This is intended. Escaped values will not be processed, for you to obtain the correct representation, you need to transform your query into: on_conflict: {
constraint: {value: 'subscriptions_pkey', escape: false},
update_columns: {
value: '[status,price]',
escape: false,
},
}, |
Thanks. It might be worth to enrich the docs with this example. This edge case makes the concept of this library a bit more verbose than expected. Have you thought of providing a helper function for escaped values? Example: import {literal} from 'gotql'
on_conflict: {
constraint: literal('subscriptions_pkey'),
update_columns: literal(['status','price']),
}, |
or with a tagged template literal import {literal} from 'gotql'
on_conflict: {
constraint: literal`subscriptions_pkey`,
update_columns: [literal`status`, literal`price`],
}, |
Yeah, I'll update the README with some examples like these to make it clearer.
I thought about it recently, when I created it there weren't this many resources on ECMA yet. However, the whole idea of gotql is not to make queries smaller, but clearer to understand and to manipulate. Even with simple queries, the JSON-Like format is more verbose than the common syntax, however, it is way more processable and usable than strings. But that might be a good solution to escaped values, I think I'll add it as a function but keeping the support for
This is cleaner, but unfortunately, it isn't possible. The parser parses the object as a whole, so when you put For now, the best course of action is to work as I said before, but I'll implement a Thanks for the heads up and the solution |
Actually, thanks for using the lib and providing such useful feedback and bug reports in general, you're evolving it so other people can benefit from it as well. Since I'm not actively using gotQL a lot, this is very helpful to those who will use in the future and allow the community to grow and the lib to be even better. Thanks a lot! |
Thank you for creating and maintaining :) |
Yep, just what I was thinking :D |
Closed in #47 |
Describe the bug
Hasura's
on_conflict
argument expect enums to be provided without quotes, however gotql does use quotes for every argument value. This result in an error (see screenshots).To Reproduce
Current behavior
Part of the query:
Expected behavior
Part of the query:
Screenshots
![image](https://user-images.githubusercontent.com/208149/81201520-a81ca400-8fc5-11ea-95f6-907f6f5d2013.png)
![image](https://user-images.githubusercontent.com/208149/81201599-bec2fb00-8fc5-11ea-81e9-381e8de49e3f.png)
![image](https://user-images.githubusercontent.com/208149/81201679-d4382500-8fc5-11ea-8990-01ab6c1b9d15.png)
The text was updated successfully, but these errors were encountered: