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

Refactor comment support #16828

Merged
merged 1 commit into from
Jul 29, 2019
Merged

Refactor comment support #16828

merged 1 commit into from
Jul 29, 2019

Conversation

roji
Copy link
Member

@roji roji commented Jul 29, 2019

  • Removed comment-related migration generation APIs from relational, implementation is now only in SqlServerMigrationsSqlGenerator.
  • Made extended property support more general so we can use them for other purposes if needed.

Fixes #16799
Fixes #16800

Note that I've included the comment statements (EXEC sp_addextendedproperty) in the same command as the DDL itself. Am not familiar enough with SqlServer to know if that's meaningful.

* Removed comment-related migration generation APIs from relational,
  implementation is now only in SqlServerMigrationsSqlGenerator.
* Made extended property support more general so we can use them
  for other purposes if needed.

Fixes #16799
Fixes #16800
@roji roji requested a review from bricelam July 29, 2019 20:18
Copy link
Contributor

@bricelam bricelam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 In the same batch is preferable.

What does a column comment during CREATE TABLE look like?

@roji
Copy link
Member Author

roji commented Jul 29, 2019

@@ -117,6 +117,10 @@ protected override void Generate(MigrationOperation operation, IModel model, Mig
MigrationCommandListBuilder builder,
bool terminate)
{
if (!terminate && operation.Comment != null)
{
throw new ArgumentException($"When generating migrations SQL for {nameof(AddColumnOperation)}, can't produce unterminated SQL with comments");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In SQLite, we Debug.Fail() but let it slide in Release.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But at least here we now for sure that the SQL will come out totally mangled, no? So better to throw an informative exception?

Copy link
Contributor

@bricelam bricelam Jul 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean... they could compose WITH RECOMPILE onto the last EXEC call 😜

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, OK :) Not sure what it would mean to do that to sp_addextendedproperty... In any case it would only work on the last statement, and only if comments were provided...

Basically I can't see the non-terminating scenario being much use when multiple statements are being generated - especially when the really significant one is the first...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm totally fine throwing 😄 (just pointing out an existing pattern used elsewhere)

@roji roji merged commit daea522 into release/3.0 Jul 29, 2019
@ghost ghost deleted the CommentFixes branch July 29, 2019 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't do memory-optimized tables with comments Comment removal in migrations
2 participants