Skip to content

Conversation

@ajcvickers
Copy link
Contributor

Fixes #33269

@ajcvickers ajcvickers requested a review from a team March 26, 2024 12:21
.Append(ColumnList(operation.Columns))
.Append(")");

KeyTraits(operation, model, builder);
Copy link
Member

Choose a reason for hiding this comment

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

Am not sure at all, but do we think unique constraints have common options/traits with primary keys? I thought e.g. fill factor is defined at the index level, rather than on the unique constraint (not sure).

Maybe it's better to be safe and make this a SQL Server-only thing rather than a relational thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know. @AndriySvyryd approved the original PR.

Copy link
Member

Choose a reason for hiding this comment

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

SQL Server supports most of the index options at the primary key level, don't know about other databases

Copy link
Member

Choose a reason for hiding this comment

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

Basically, we don't need KeyTraits, just call IndexOptions here. Only the relevant facets will be present on the operation.

/// <param name="model">The target model which may be <see langword="null" /> if the operations exist without a model.</param>
/// <param name="builder">The command builder to use to add the SQL fragment.</param>
protected virtual void KeyWithOptions(MigrationOperation operation, MigrationCommandListBuilder builder)
protected virtual void KeyTraits(MigrationOperation operation, IModel? model, MigrationCommandListBuilder builder)
Copy link
Member

Choose a reason for hiding this comment

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

For sequence/index I thing we use the word "Options" rather than "Traits"

Copy link
Contributor Author

@ajcvickers ajcvickers Mar 26, 2024

Choose a reason for hiding this comment

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

This copies the pattern used for IndexTraits which is the already existing method right above this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note however, we call IndexTraits at different places. I know know if it needs to called at different places--again @AndriySvyryd approved the original PR.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, missed that we had IndexTraits, makes sense I guess (though not sure why we have options in some places and traits in others...)

@ajcvickers
Copy link
Contributor Author

@dotnet/efteam If there is concern that this is implemented incorrectly, then I don't think we should spend a lot of time on it, but rather just revert the community PR that was approved and then revisit it at a later date when we have time to review by more people than just @AndriySvyryd.

/// <summary>
/// Generates a SQL fragment for extra with options of a key from a
/// <see cref="AddPrimaryKeyOperation" /> or <see cref="AddUniqueConstraintOperation" />.
/// Generates a SQL fragment for traits of an primary key or alternate key from a <see cref="CreateTableOperation" />,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/// Generates a SQL fragment for traits of an primary key or alternate key from a <see cref="CreateTableOperation" />,
/// Generates a SQL fragment for traits of a primary key or alternate key from a <see cref="CreateTableOperation" />,

@ajcvickers
Copy link
Contributor Author

@AndriySvyryd @roji Updated.

@ajcvickers ajcvickers merged commit ce152e3 into main Mar 27, 2024
@ajcvickers ajcvickers deleted the 240326_FillByFactors branch March 27, 2024 16:56
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.

HasFillFactor only gets applied when database is altered, not when created

4 participants