Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Server Bug v2.6.1.beta and v.2.5.0 - Default values overwritten to NULL #8443

Closed
leoalves opened this issue Apr 26, 2022 · 6 comments
Closed
Labels
a/data/mssql k/bug Something isn't working p/urgent Immediate action required

Comments

@leoalves
Copy link

Version Information

Server Version: v2.5.0 and v.2.6.beta

What is the expected behaviour?

Hasura is generating queries with NULL values, instead of omitting the column. This overwrites default values set into the fields or generates constraint validation errors for non-null fields.

How to reproduce the issue?

  1. connect SQL server database to Hasura
  2. create table with default value
CREATE TABLE defaultValueTest
(
    id         uniqueidentifier PRIMARY KEY DEFAULT NEWID(),
    name       VARCHAR(255) NOT NULL,    
    created_at DATETIME2 NOT NULL DEFAULT SYSDATETIME()
);
  1. Track table
  2. Insert record into the table passing only the name field
mutation {
  insert_defaultValueTest_one(object: {
    name: "a"
  }) {
    id
  }
}
  1. Hasura will return an error saying the id field is mandatory and cannot be NULL

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

I believe this merged pull request is responsible for this issue
92ab937#diff-d79e7a125fc4aff3fef93e498097bd00b33e8eee54a98be0d8bd20c2ddfef52bL28-L29

If you compare the VALUES from the generated query you can see that in the previous version only one value is passed. In the new one all other fields are set to NULL.

@leoalves leoalves added the k/bug Something isn't working label Apr 26, 2022
@sassela
Copy link
Contributor

sassela commented Apr 27, 2022

@leoalves thanks for the bug report! We'll triage this and get back to you with any questions or updates soon.

@sassela sassela added a/data/mssql p/urgent Immediate action required labels Apr 27, 2022
@sassela
Copy link
Contributor

sassela commented Apr 28, 2022

We've flagged this as an urgent bug, but we suspect there's a fix already on the main branch awaiting release. We'll regression test it, release a patch and keep this issue updated once it's available.

Until then, here's the as-yet-unreleased change we think resolves it, which you can access early if needed:
🐳 Docker image: hasurabuild/graphql-engine:mono-branch-main-91f80902a
📦 Heroku app: https://mono-branch-main-91f80902a.herokuapp.com/

@AndrewCraswell
Copy link

I've just hit the same bug using Hasura Cloud. Unfortunately this is a big blocker :/

@sassela
Copy link
Contributor

sassela commented May 3, 2022

This will be fixed in release v2.6.1 going out today. I'll update here once it's available.

@sassela
Copy link
Contributor

sassela commented May 3, 2022

hey folks, thank you again for your patience. Confirming the fix for this bug is now available on v2.6.1. Please comment here or reopen the issue if any problems.

@sassela sassela closed this as completed May 3, 2022
@leoalves
Copy link
Author

leoalves commented May 5, 2022

Just tested. It's working in v2.6.1. And the column_presets that caused this issue is also working.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a/data/mssql k/bug Something isn't working p/urgent Immediate action required
Projects
None yet
Development

No branches or pull requests

3 participants