这是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
4 changes: 2 additions & 2 deletions docs/graphql/manual/api-reference/pgtypes.csv
Original file line number Diff line number Diff line change
@@ -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_
Expand Down
11 changes: 7 additions & 4 deletions server/src-lib/Hasura/RQL/DML/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,20 @@ 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
, S.SEUnsafe "4" -- to print out crs
] 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 ()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
21 changes: 21 additions & 0 deletions server/tests-py/queries/graphql_query/basic/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 4 additions & 0 deletions server/tests-py/queries/graphql_query/basic/teardown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ args:
sql: |
drop table author

- type: run_sql
args:
sql: |
drop table "user"
17 changes: 17 additions & 0 deletions server/tests-py/queries/v1/select/basic/select_user.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions server/tests-py/queries/v1/select/basic/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 4 additions & 0 deletions server/tests-py/queries/v1/select/basic/teardown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ args:
args:
sql: |
drop table author
- type: run_sql
args:
sql: |
drop table "user"
3 changes: 3 additions & 0 deletions server/tests-py/test_graphql_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def test_nested_select_query_article_author(self, hge_ctx):
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'
Expand Down
3 changes: 3 additions & 0 deletions server/tests-py/test_v1_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def test_select_col_not_present(self, hge_ctx):
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"
Expand Down