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

Fix Event Trigger creation for MSSQL tables with reserved word columns (close #9929) #9926

Conversation

nakanoasaservice
Copy link
Contributor

@nakanoasaservice nakanoasaservice commented Oct 11, 2023

Description

When creating an Event Trigger in Hasura for MSSQL, if the table's column name contains reserved words like group, it results in an error. This PR addresses this issue by wrapping all column names with [] in the Trigger creation SQL issued by Hasura, ensuring proper escaping and preventing such errors.

Changelog

Component : server

Type: bugfix

Product: community-edition

Short Changelog

Fixed an issue where Event Triggers for MSSQL failed for tables with columns named after reserved words.

Long Changelog

  • Column names in the Trigger creation SQL for MSSQL are now wrapped with [], providing proper escaping.
  • This change addresses a limitation where reserved words used as column names caused Event Trigger creation to fail.
  • Users can now safely create Event Triggers for tables, even if they contain reserved words as column names.

Related Issues

#9929

Solution and Design

To address the issue where reserved words as column names caused failures, we've wrapped every column name with square brackets [] in the Trigger creation SQL. This ensures proper escaping and allows the SQL command to be processed without errors.

Steps to test and verify

  1. Set up a MSSQL database with a table containing a column named group or any other reserved word.
  2. Try creating an Event Trigger for this table using Hasura.
  3. The process should complete successfully without any errors.

Limitations, known bugs & workarounds

No known limitations or bugs at this time.

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No
  • Yes
    • Updated docs with SQL for downgrading the catalog

Metadata

Does this PR add a new Metadata feature?

  • No
  • Yes
    • Does run_sql auto manages the new metadata through schema diffing?
      • Yes
      • Not required
    • Does run_sql auto manages the definitions of metadata on renaming?
      • Yes
      • Not required
    • Does export_metadata/replace_metadata supports the new metadata added?
      • Yes
      • Not required

GraphQL

  • No new GraphQL schema is generated
  • New GraphQL schema is being generated:
    • New types and typenames are correlated

Breaking changes

  • No Breaking changes

  • There are breaking changes:

    1. Metadata API

      Existing query types:

      • Modify args payload which is not backward compatible
      • Behavioural change of the API
      • Change in response JSON schema
      • Change in error code
    2. GraphQL API

      Schema Generation:

      • Change in any NamedType
      • Change in table field names

      Schema Resolve:-

      • Change in treatment of null value for any input fields
    3. Logging

      • Log JSON schema has changed
      • Log type names have changed

@hasura-bot
Copy link
Contributor

Beep boop! 🤖

Hey @nakanoasaservice, thanks for your PR!

One of my human friends will review this PR and get back to you as soon as possible.

Stay awesome! 😎

@nakanoasaservice nakanoasaservice force-pushed the feature/mssql-event-trigger-escape branch from e4ed4c7 to 9897ebc Compare October 11, 2023 16:21
@nakanoasaservice nakanoasaservice changed the title fix: escape SQL column names in MSSQL's event trigger Fix Event Trigger creation for MSSQL tables with reserved word columns (close #9229) Oct 12, 2023
@nakanoasaservice nakanoasaservice marked this pull request as ready for review October 12, 2023 09:43
@nakanoasaservice nakanoasaservice requested a review from a team as a code owner October 12, 2023 09:43
@nakanoasaservice nakanoasaservice changed the title Fix Event Trigger creation for MSSQL tables with reserved word columns (close #9229) Fix Event Trigger creation for MSSQL tables with reserved word columns (close #9929) Oct 12, 2023
@hasura-bot hasura-bot closed this Oct 30, 2023
@hasura-bot
Copy link
Contributor

Beep boop! 🤖

GIF

Awesome work @nakanoasaservice!

Your changes were merged successfully. All of us at Hasura ❤️ what you did.

Thanks again 🤗

hasura-bot added a commit that referenced this pull request Oct 30, 2023
GITHUB_PR_NUMBER: 9926
GITHUB_PR_URL: #9926

PR-URL: hasura/graphql-engine-mono#10378
Co-authored-by: Nakano as a Service <20109935+nakanoasaservice@users.noreply.github.com>
GitOrigin-RevId: 644e8fa2cf8c86f85c72c7a075e375a071cb5814
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants