server: fix issue with queries on character column types (close #6217)

GitOrigin-RevId: 81eaa0db63656b1d37b9b71736d4309af902cc47
This commit is contained in:
Abby Sassel 2021-02-22 10:20:27 +00:00 committed by hasura-bot
parent 0dfe83f931
commit b00009f4bb
10 changed files with 99 additions and 13 deletions

View File

@ -14,6 +14,7 @@ keys in the response body.
- server: fix issue of not exposing mutation functions to the admin role when function permissions are inferred (fix #6503)
- server: add "resource_version" field to metadata for concurrency control - disable lookup during migrations
- server: fix issue with queries on character column types (close #6217)
- server: optimize resolving source. Resolving a source would create connection pools every time. Optimize that to re-create connection pools only when necessary. (#609)
## v1.4.0-alpha.1

View File

@ -298,7 +298,7 @@ instance ToSQL PGScalarType where
PGNumeric -> "numeric"
PGMoney -> "money"
PGBoolean -> "boolean"
PGChar -> "character"
PGChar -> "bpchar"
PGVarchar -> "varchar"
PGText -> "text"
PGCitext -> "citext"
@ -357,6 +357,8 @@ pgScalarTranslations =
, ("boolean" , PGBoolean)
, ("bool" , PGBoolean)
, ("bpchar" , PGChar)
, ("char" , PGChar)
, ("character" , PGChar)
, ("varchar" , PGVarchar)
@ -401,7 +403,7 @@ isNumType PGMoney = True
isNumType _ = False
stringTypes :: [PGScalarType]
stringTypes = [PGVarchar, PGText, PGCitext]
stringTypes = [PGVarchar, PGText, PGCitext, PGChar]
isStringType :: PGScalarType -> Bool
isStringType = (`elem` stringTypes)

View File

@ -0,0 +1,18 @@
# Test case for bug reported at https://github.com/hasura/graphql-engine/issues/6217
description: Select projects with a given ID of type `character`
url: /v1/graphql
status: 200
response:
data:
project:
- id: 'bcd'
- id: 'BCD'
query:
query: |
query {
project (
where: {id: { _ilike: "b%"}}
) {
id
}
}

View File

@ -66,7 +66,6 @@ args:
schema: public
name: article
#Article table
- type: track_table
args:
@ -91,8 +90,7 @@ args:
table: article
column: author_id
#Insert values
#Insert values: City table
- type: insert
args:
table: city
@ -106,3 +104,21 @@ args:
- name: New Orleans
country: USA
# Project table
- type: run_sql
args:
sql: |
CREATE TABLE project (
id CHAR(3) PRIMARY KEY
);
INSERT INTO project VALUES
('abc'),
('ABC'),
('bcd'),
('BCD');
- type: track_table
args:
schema: public
name: project

View File

@ -22,3 +22,8 @@ args:
args:
sql: |
drop table city
- type: run_sql
args:
sql: |
drop table project

View File

@ -0,0 +1,16 @@
# Test case for bug reported at https://github.com/hasura/graphql-engine/issues/6217
description: Select projects with a given ID of type `character`
url: /v1/query
status: 200
response:
- id: 'bcd'
- id: 'BCD'
query:
type: select
args:
table: project
where:
id:
$ilike: 'b%'
columns:
- id

View File

@ -91,8 +91,7 @@ args:
table: article
column: author_id
#Insert values
#Insert values: City table
- type: insert
args:
table: city
@ -106,3 +105,21 @@ args:
- name: New Orleans
country: USA
# Project table
- type: run_sql
args:
sql: |
CREATE TABLE project (
id CHAR(3) PRIMARY KEY
);
INSERT INTO project VALUES
('abc'),
('ABC'),
('bcd'),
('BCD');
- type: track_table
args:
schema: public
name: project

View File

@ -22,3 +22,8 @@ args:
args:
sql: |
drop table city
- type: run_sql
args:
sql: |
drop table project

View File

@ -389,6 +389,9 @@ class TestGraphQLQueryBoolExpSearch:
def test_city_where_niregex(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_city_where_niregex.yaml', transport)
def test_project_where_ilike(self, hge_ctx, transport):
check_query_f(hge_ctx, self.dir() + '/select_project_where_ilike.yaml', transport)
@classmethod
def dir(cls):
return 'queries/graphql_query/boolexp/search'

View File

@ -180,6 +180,9 @@ class TestV1SelectBoolExpSearch:
def test_city_where_not_iregex(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/select_city_where_niregex.yaml')
def test_project_where_ilike(self, hge_ctx):
check_query_f(hge_ctx, self.dir() + '/select_project_where_ilike.yaml')
@classmethod
def dir(cls):
return 'queries/v1/select/boolexp/search'