这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions server/src-lib/Hasura/RQL/DML/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ simplifyError txErr = do
("42704", msg) -> return (ConstraintError, msg)
-- invalid input values
("22007", msg) -> return (DataException, msg)
-- invalid escape sequence
("22025", msg) -> return (BadRequest, msg)
_ -> Nothing

-- validate limit and offset int values
Expand Down
2 changes: 2 additions & 0 deletions server/src-lib/Hasura/RQL/Types/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ data Code
| AlreadyInit
| ConstraintViolation
| DataException
| BadRequest
-- Graphql error
| NoTables
| ValidationFailed
Expand All @@ -92,6 +93,7 @@ instance Show Code where
show = \case
NotNullViolation -> "not-null-violation"
DataException -> "data-exception"
BadRequest -> "bad-request"
ConstraintViolation -> "constraint-violation"
PermissionDenied -> "permission-denied"
NotExists -> "not-exists"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
description: GraphQL query with invalid escape sequence
url: /v1/graphql
status: 200
response:
errors:
- extensions:
code: bad-request
path: $
message: |-
LIKE pattern must not end with escape character
query:
query: |
query {
person(where: {name: {_like: "John\\"}}) {
id
name
}
}
17 changes: 17 additions & 0 deletions server/tests-py/queries/graphql_query/basic/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,23 @@ args:
- name: User 2
number: '123456780'

- type: run_sql
args:
sql: |
create table person (
id serial primary key,
name text
);
- type: track_table
args:
schema: public
name: person
- type: insert
args:
table: person
objects:
- name: "John\\"

#Set timezone
- type: run_sql
args:
Expand Down
5 changes: 5 additions & 0 deletions server/tests-py/queries/graphql_query/basic/teardown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ args:
sql: |
drop table "user"

- type: run_sql
args:
sql: |
drop table person

- type: run_sql
args:
sql: |
Expand Down
4 changes: 4 additions & 0 deletions server/tests-py/test_graphql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def test_nested_select_with_foreign_key_alter(self, hge_ctx, transport):
transport = 'http'
check_query_f(hge_ctx, self.dir() + "/nested_select_with_foreign_key_alter.yaml", transport)

def test_select_query_invalid_escape_sequence(self, hge_ctx, transport):
transport = 'http'
check_query_f(hge_ctx, self.dir() + "/select_query_invalid_escape_sequence.yaml", transport)

@classmethod
def dir(cls):
return 'queries/graphql_query/basic'
Expand Down