server/mssql: belatedly address code review feedback

GitOrigin-RevId: faf3a646fd1067f2e0ed417b97871cd5173ca02e
This commit is contained in:
Abby Sassel 2021-03-19 16:39:37 +00:00 committed by hasura-bot
parent f1183b8ae3
commit 7a75a08dfa
4 changed files with 104 additions and 86 deletions

View File

@ -77,16 +77,16 @@ parseBoolExpOperations rhsParser _fields columnInfo value =
parseOne = parseWithTy columnType val
parseManyWithType ty = rhsParser (CollectableTypeArray ty) val
parseEq = AEQ False <$> parseOne
parseNeq = ANE False <$> parseOne
parseIn = AIN <$> parseManyWithType colTy
parseNin = ANIN <$> parseManyWithType colTy
parseGt = AGT <$> parseOne
parseLt = ALT <$> parseOne
parseGte = AGTE <$> parseOne
parseLte = ALTE <$> parseOne
parseLike = guardType stringTypes >> ALIKE <$> parseOne
parseNlike = guardType stringTypes >> ANLIKE <$> parseOne
parseEq = AEQ False <$> parseOne
parseNeq = ANE False <$> parseOne
parseIn = AIN <$> parseManyWithType colTy
parseNin = ANIN <$> parseManyWithType colTy
parseGt = AGT <$> parseOne
parseLt = ALT <$> parseOne
parseGte = AGTE <$> parseOne
parseLte = ALTE <$> parseOne
parseLike = guardType stringTypes >> ALIKE <$> parseOne
parseNlike = guardType stringTypes >> ANLIKE <$> parseOne
guardType validTys = unless (isScalarColumnWhere (`elem` validTys) colTy) $
throwError $ buildMsg colTy validTys

View File

@ -849,7 +849,7 @@ fromOpExpG expression op =
IR.AMatchesFulltext _ -> refute (pure (UnsupportedOpExpG op))
-- As of March 2021, only geometry/geography casts are supported
IR.ACast _casts -> refute (pure (UnsupportedOpExpG op)) -- mkCastsExp casts
-- https://docs.microsoft.com/en-us/sql/relational-databases/spatial/spatial-data-sql-server?view=sql-server-ver15
-- https://docs.microsoft.com/en-us/sql/relational-databases/spatial/spatial-data-sql-server
IR.ASTContains _val -> refute (pure (UnsupportedOpExpG op)) -- mkGeomOpBe "ST_Contains" val
IR.ASTCrosses _val -> refute (pure (UnsupportedOpExpG op)) -- mkGeomOpBe "ST_Crosses" val
IR.ASTEquals _val -> refute (pure (UnsupportedOpExpG op)) -- mkGeomOpBe "ST_Equals" val

View File

@ -1,80 +1,73 @@
type: bulk
args:
- type: mssql_run_sql
args:
source: mssql
sql: |
CREATE TABLE author(
id int identity NOT NULL PRIMARY KEY,
name varchar(450) UNIQUE
);
#Author table
- type: mssql_run_sql
args:
source: mssql
sql: |
CREATE TABLE author(
id int identity NOT NULL PRIMARY KEY,
name varchar(450) UNIQUE
);
INSERT INTO
author (name)
VALUES
('Author 1'),
('Author 2'),
('Author 3');
INSERT INTO
author (name)
VALUES
('Author 1'),
('Author 2'),
('Author 3');
CREATE TABLE article (
id int identity NOT NULL PRIMARY KEY,
title TEXT,
content TEXT,
author_id INTEGER REFERENCES author(id),
is_published BIT,
published_on TIMESTAMP
);
#Article table
- type: mssql_run_sql
args:
source: mssql
sql: |
CREATE TABLE article (
id int identity NOT NULL PRIMARY KEY,
title TEXT,
content TEXT,
author_id INTEGER REFERENCES author(id),
is_published BIT,
published_on TIMESTAMP
);
INSERT INTO
article (title, content, author_id, is_published)
VALUES
(
'Article 1',
'Sample article content 1',
1,
0
),
(
'Article 2',
'Sample article content 2',
1,
1
),
(
'Article 3',
'Sample article content 3',
2,
0
),
(
'Article 4',
'Sample article content 4',
3,
1
);
INSERT INTO
article (title, content, author_id, is_published)
VALUES
(
'Article 1',
'Sample article content 1',
1,
0
),
(
'Article 2',
'Sample article content 2',
1,
1
),
(
'Article 3',
'Sample article content 3',
2,
0
),
(
'Article 4',
'Sample article content 4',
3,
1
);
CREATE TABLE city (
id int identity NOT NULL PRIMARY KEY,
name TEXT NOT NULL,
name_varchar varchar(30) NOT NULL,
name_char char(11) NOT NULL,
name_nvarchar nvarchar(30) NOT NULL,
name_nchar nchar(11) NOT NULL,
name_ntext ntext NOT NULL,
country TEXT
);
#City table
- type: mssql_run_sql
args:
source: mssql
sql: |
CREATE TABLE city (
id int identity NOT NULL PRIMARY KEY,
name TEXT NOT NULL,
country TEXT NOT NULL
);
INSERT INTO
city ([name], country)
VALUES
('Durham', 'USA'),
('New York', 'USA'),
('Framlingham', 'UK'),
('New Orleans', 'USA');
INSERT INTO
city ([name], name_varchar, name_char, name_nvarchar, name_nchar, name_ntext, country)
VALUES
('Durham', 'Durham','Durham','Durham','Durham','Durham', 'USA'),
('New York', 'New York','New York','New York','New York','New York', 'USA'),
('Framlingham', 'Framlingham','Framlingham','Framlingham','Framlingham','Framlingham', 'UK'),
('New Orleans', 'New Orleans','New Orleans','New Orleans','New Orleans','New Orleans', 'USA');

View File

@ -1,20 +1,45 @@
description: Select cities starting with any letter A-G
description: Select cities starting with any letter A-G. Query all types listed in `MSSQL.Types.stringTypes` to confirm they work with `like`
url: /v1/graphql
status: 200
response:
data:
city:
- name: Durham
name_varchar: Durham
name_char: "Durham "
name_nvarchar: Durham
name_nchar: "Durham "
name_ntext: Durham
country: USA
- name: Framlingham
name_varchar: Framlingham
name_char: "Framlingham"
name_nvarchar: Framlingham
name_nchar: "Framlingham"
name_ntext: Framlingham
country: UK
query:
query: |
query {
city (
where: {name: {_like: "[A-G]%" }}
where: { _and:
[
{name: {_like: "[A-G]%" }}
{name_varchar: {_like: "[A-G]%"}}
{name_char: {_like: "[A-G]%"}}
{name_nvarchar: {_like: "[A-G]%"}}
{name_nchar: {_like: "[A-G]%"}}
{name_ntext: {_like: "[A-G]%"}}
]
}
) {
name
name_varchar
name_char
name_nvarchar
name_nchar
name_ntext
country
}
}