diff --git a/docs/graphql/manual/api-reference/pgtypes.csv b/docs/graphql/manual/api-reference/pgtypes.csv index 79e65ea2e2a..96d65086203 100644 --- a/docs/graphql/manual/api-reference/pgtypes.csv +++ b/docs/graphql/manual/api-reference/pgtypes.csv @@ -1,6 +1,6 @@ Name,Aliases,Description,GraphQL Engine Type -bigint,int8,signed eight-byte integer,Int_ -bigserial,serial8,autoincrementing eight-byte integer,Int_ +bigint,int8,signed eight-byte integer,String_ +bigserial,serial8,autoincrementing eight-byte integer,String_ bit [ (n) ],,fixed-length bit string,Implicit_ bit varying [ (n) ],varbit [ (n) ],variable-length bit string,Implicit_ boolean,bool,logical Boolean (true/false),Bool_ diff --git a/server/src-lib/Hasura/RQL/DML/Internal.hs b/server/src-lib/Hasura/RQL/DML/Internal.hs index 136786dedaa..fd97d321563 100644 --- a/server/src-lib/Hasura/RQL/DML/Internal.hs +++ b/server/src-lib/Hasura/RQL/DML/Internal.hs @@ -233,9 +233,9 @@ mkColExtr (c, pct) = mkColExtrAl (Just c) (c, pct) mkColExtrAl :: (IsIden a) => Maybe a -> (PGCol, PGColType) -> S.Extractor -mkColExtrAl alM (c, pct) = - if pct == PGGeometry || pct == PGGeography - then S.mkAliasedExtrFromExp +mkColExtrAl alM (c, pct) + | pct == PGGeometry || pct == PGGeography = + S.mkAliasedExtrFromExp ( S.SEFnApp "ST_AsGeoJSON" [ S.mkSIdenExp c , S.SEUnsafe "15" -- max decimal digits @@ -243,7 +243,10 @@ mkColExtrAl alM (c, pct) = ] Nothing `S.SETyAnn` S.jsonType ) alM - else S.mkAliasedExtr c alM + | pct == PGBigInt || pct == PGBigSerial = + S.mkAliasedExtrFromExp + (S.mkSIdenExp c `S.SETyAnn` S.textType) alM + | otherwise = S.mkAliasedExtr c alM -- validate headers validateHeaders :: (P1C m) => [T.Text] -> m () diff --git a/server/tests-py/queries/graphql_query/basic/select_query_user.yaml b/server/tests-py/queries/graphql_query/basic/select_query_user.yaml new file mode 100644 index 00000000000..c048ef7c013 --- /dev/null +++ b/server/tests-py/queries/graphql_query/basic/select_query_user.yaml @@ -0,0 +1,21 @@ +description: Simple GraphQL query to fetch items from user table +url: /v1alpha1/graphql +status: 200 +response: + data: + user: + - id: '1' + name: User 1 + number: '123456789' + - id: '2' + name: User 2 + number: '123456780' +query: + query: | + query { + user { + id + name + number + } + } diff --git a/server/tests-py/queries/graphql_query/basic/setup.yaml b/server/tests-py/queries/graphql_query/basic/setup.yaml index dccc278da6c..9e75f34dc61 100644 --- a/server/tests-py/queries/graphql_query/basic/setup.yaml +++ b/server/tests-py/queries/graphql_query/basic/setup.yaml @@ -85,3 +85,24 @@ args: true ) +#User table with bigserial and bigint columns +- type: run_sql + args: + sql: | + CREATE TABLE "user" ( + id BIGSERIAL PRIMARY KEY, + name TEXT NOT NULL, + number BIGINT + ); +- type: track_table + args: + schema: public + name: user +- type: insert + args: + table: user + objects: + - name: User 1 + number: '123456789' + - name: User 2 + number: '123456780' diff --git a/server/tests-py/queries/graphql_query/basic/teardown.yaml b/server/tests-py/queries/graphql_query/basic/teardown.yaml index 51a498ddb32..640ce6f4eb2 100644 --- a/server/tests-py/queries/graphql_query/basic/teardown.yaml +++ b/server/tests-py/queries/graphql_query/basic/teardown.yaml @@ -18,3 +18,7 @@ args: sql: | drop table author +- type: run_sql + args: + sql: | + drop table "user" diff --git a/server/tests-py/queries/v1/select/basic/select_user.yaml b/server/tests-py/queries/v1/select/basic/select_user.yaml new file mode 100644 index 00000000000..0aca10e26c1 --- /dev/null +++ b/server/tests-py/queries/v1/select/basic/select_user.yaml @@ -0,0 +1,17 @@ +url: /v1/query +status: 200 +response: +- id: '1' + name: User 1 + number: '123456789' +- id: '2' + name: User 2 + number: '123456780' +query: + type: select + args: + table: user + columns: + - id + - name + - number diff --git a/server/tests-py/queries/v1/select/basic/setup.yaml b/server/tests-py/queries/v1/select/basic/setup.yaml index 8d2446e30fe..9212fc00098 100644 --- a/server/tests-py/queries/v1/select/basic/setup.yaml +++ b/server/tests-py/queries/v1/select/basic/setup.yaml @@ -83,3 +83,24 @@ args: true ) +#User table with bigserial and bigint columns +- type: run_sql + args: + sql: | + CREATE TABLE "user" ( + id BIGSERIAL PRIMARY KEY, + name TEXT NOT NULL, + number BIGINT + ); +- type: track_table + args: + schema: public + name: user +- type: insert + args: + table: user + objects: + - name: User 1 + number: '123456789' + - name: User 2 + number: '123456780' diff --git a/server/tests-py/queries/v1/select/basic/teardown.yaml b/server/tests-py/queries/v1/select/basic/teardown.yaml index c4e61d8e138..984ac4eaec1 100644 --- a/server/tests-py/queries/v1/select/basic/teardown.yaml +++ b/server/tests-py/queries/v1/select/basic/teardown.yaml @@ -16,3 +16,7 @@ args: args: sql: | drop table author +- type: run_sql + args: + sql: | + drop table "user" diff --git a/server/tests-py/test_graphql_queries.py b/server/tests-py/test_graphql_queries.py index 070558063a6..30e1454663d 100644 --- a/server/tests-py/test_graphql_queries.py +++ b/server/tests-py/test_graphql_queries.py @@ -19,6 +19,9 @@ class TestGraphQLQueryBasic: def test_nested_select_query_where(self, hge_ctx): check_query_f(hge_ctx, self.dir + '/nested_select_where_query_author_article.yaml') + def test_select_query_user(self, hge_ctx): + check_query_f(hge_ctx, "queries/graphql_query/basic/select_query_user.yaml") + @pytest.fixture(autouse=True) def transact(self, request, hge_ctx): self.dir = 'queries/graphql_query/basic' diff --git a/server/tests-py/test_v1_queries.py b/server/tests-py/test_v1_queries.py index 1997aea82ca..31f9e8a5199 100644 --- a/server/tests-py/test_v1_queries.py +++ b/server/tests-py/test_v1_queries.py @@ -19,6 +19,9 @@ class TestV1SelectBasic: def test_nested_select_query_where(self, hge_ctx): check_query_f(hge_ctx, self.dir + '/nested_select_where_query_author_article.yaml') + def test_select_query_user(self, hge_ctx): + check_query_f(hge_ctx, self.dir + '/select_user.yaml') + @pytest.fixture(autouse=True) def transact(self, request, hge_ctx): self.dir = "queries/v1/select/basic"