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

Comment crashes on SQL Server if comment already exists #13525

Open
5 tasks
AndreasSchindler opened this issue Sep 29, 2021 · 3 comments
Open
5 tasks

Comment crashes on SQL Server if comment already exists #13525

AndreasSchindler opened this issue Sep 29, 2021 · 3 comments
Labels
dialect: mssql For issues and PRs. Things that involve MSSQL (and do not involve all dialects). status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action type: bug

Comments

@AndreasSchindler
Copy link

Issue Creation Checklist

[x ] I have read the contribution guidelines

Issue Description

Storing Tables to SQL Server crashes if an extended Property already exists.

we suggest changing the Function CommentTemplate in MS SQL Querygenerator to

commentTemplate(comment, table, column) {
// Check if extended Property exists; insert / update accordingly
return IF NOT EXISTS (SELECT NULL FROM SYS.EXTENDED_PROPERTIES WHERE [major_id] = OBJECT_ID(${this.quoteIdentifier(table)}) AND [name] = N'MS_Description' AND [minor_id] = (SELECT [column_id] FROM SYS.COLUMNS WHERE [name] = ${this.escape(column)} AND [object_id] = OBJECT_ID(${this.escape(table)}))) EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = ${this.escape(comment)}, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = ${this.escape(table)}, @level2type = N'COLUMN', @level2name = ${this.escape(column)}; ELSE EXECUTE sp_updateextendedproperty @name = N'MS_Description', @value = ${this.escape(comment)}, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = ${this.escape(table)}, @level2type = N'COLUMN', @level2name = ${this.escape(column)};;

 }

Additional context

Add any other context or screenshots about the issue here.

Issue Template Checklist

Is this issue dialect-specific?

  • No. This issue is relevant to Sequelize as a whole.
  • [ x] Yes. This issue only applies to the following dialect(s): MSSQL
  • I don't know.

Would you be willing to resolve this issue by submitting a Pull Request?

YES -> See code to fix above

  • [x ] Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

I am a first time contributor and am not 100% sure about the steps expected

@wbourne0
Copy link
Member

wbourne0 commented Oct 2, 2021

Can you add a code example that shows this failing? Is this when using .sync?

@wbourne0 wbourne0 added dialect: mssql For issues and PRs. Things that involve MSSQL (and do not involve all dialects). status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action type: bug labels Oct 2, 2021
@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added stale and removed stale labels Oct 27, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2021

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

@github-actions github-actions bot added the stale label Nov 4, 2021
@WikiRik WikiRik removed the stale label Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dialect: mssql For issues and PRs. Things that involve MSSQL (and do not involve all dialects). status: awaiting response For issues and PRs. OP must respond (or change something, if it is a PR). Maintainers have no action type: bug
Projects
None yet
Development

No branches or pull requests

3 participants