hasura / hasura/graphql-engine

Column Presets fail when setting a bit column in sql-server

Open
#8,135 1 comment 0 reactions 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: 2.2.0
CLI Version (for CLI related issue): 2.2.0

### Environment

Core, running in a docker container.

### What is the expected behaviour?

When setting a column preset for a bit column, I can type in `true` or `false` to indicate a boolean value.

### Keywords

sql server, column presets, boolean

### What is the current behaviour?

An error is produced as indicated in the screen shots

### How to reproduce the issue?

1. Set a column preset for a bit column
2. Set the column preset value to `true` or `false`

I tried using `0` or `1` and this produced the same issue. It seems like perhaps the yaml file wants it to not be in quotes and to be an actual int/number judging by the error message that says "Expected Number".

### Screenshots or Screencast
![Screen Shot 2022-02-03 at 2 31 31 PM](https://user-images.githubusercontent.com/49927862/152426210-c3dfd8d4-49c6-4615-ac2c-892e496a703e.png)
![Screen Shot 2022-02-03 at 2 32 51 PM](https://user-images.githubusercontent.com/49927862/152426212-184b1d08-92c6-4913-8837-21a2c4795e31.png)

### Please provide any traces or logs that could help here.

This is the "Detail" from the error

```
[
{
"definition": {
"role": "user",
"source": "ANSWR_DB",
"comment": null,
"permission": {
"backend_only": false,
"set": {
"Subject": "Message",
"InitiatedBy": "x-hasura-User-Id",
"DisableRecipientReplies": "false"
},
"check": {
"InitiatedBy": {
"_eq": "X-Hasura-User-Id"
}
},
"columns": [
"CategoryId",
"CreatedOn",
"DisableRecipientReplies",
"DisableReplyAlerts",
"LastMessageSentOn",
"PatientId",
"ReplyAlertsInitiatorOnly",
"Subject",
"UpdatedOn"
]
},
"table": {
"schema": "Messaging",
"name": "Conversation"
}
},
"reason": "Inconsistent object: in table \"Messaging.Conversation\": in permission for role \"user\": parsing Word8 failed, expected Number, but encountered String",
"name": "insert_permission user in table Messaging.Conversation in source ANSWR_DB",
"type": "insert_permission"
}
]
```

### Any possible solutions?

None so far, just avoid using column presets for a bit column!

### Can you identify the location in the source code where the problem exists?

Not so far, looked around for the permissions code/components but haven't found it yet.

### If the bug is confirmed, would you be willing to submit a PR?

Perhaps if I have time. I do have background in ts/react. If a team member can point me to the code for permissions/column presets, I assume it should be pretty easy.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with a SQL Server bit column and a column preset set to true, false, 0, or 1. Trace the permissions and column-presets entry points to find where the preset value is parsed as a number. Done means valid boolean or numeric bit values are accepted without the “Expected Number” error, with a regression test if the relevant test location is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql, typescript
Domain
authorization, backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.