-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Create explicit index object for Keys & ForeignKeys #3714
Conversation
5cd1f5a
to
8116f62
Compare
/// </summary> | ||
IIndex Index { get; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether the values assigned to the foreign key properties are unique. | ||
/// </summary> | ||
bool IsUnique { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsUnique should be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember it being the intention that foreign keys, which define relationships in our metadata, would no longer control whether the relationship is 1:1 or 1:*. Does this mean that you can no longer have a 1:1 relationship in the model without also having an index?
I think we should discuss in the design meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foreign key does control the relationship is 1:1 or 1:* but it won't store the information with in itself. It will modify the associated index uniqueness appropriately. So you cannot have unique & non-unique FKs using same set of properties ( #3551 enables that scenario). It also mean that you can no longer have 1:1 relationship in the model without having unique index on same properties which is present situation in migration and database. All our relationships in database are non-unique regardless of FK's uniqueness. Correcting it exposed #3648 because we were inserting duplicate values in unique FK temporarily.
I will bring this to design meeting for further discussion.
a6f44b0
to
cb53a5f
Compare
Migrations changes look good. |
@@ -251,7 +251,8 @@ FOREIGN KEY (BuddyId) REFERENCES Friends(Id) | |||
Assert.Equal(table.FindPrimaryKey(), fk.PrincipalKey); | |||
} | |||
|
|||
[Fact] | |||
// TODO: See issue #3710 | |||
//[Fact] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😢 Can you add this to #3710 to ensure it is re-enabled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Please note the following issues: |
@MarcoLoetscher - regarding issues you mentioned,
|
039b158
to
0b89341
Compare
@@ -75,7 +75,8 @@ public static void ParseColumnDefinition(TableModel table, string statement) | |||
return; | |||
} | |||
|
|||
if (statement.IndexOf(" UNIQUE", StringComparison.OrdinalIgnoreCase) > 0) | |||
if (statement.IndexOf(" UNIQUE", StringComparison.OrdinalIgnoreCase) > 0 | |||
|| statement.IndexOf(" PRIMARY KEY", StringComparison.OrdinalIgnoreCase) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these changes fix #3642. Could you update that issue as well? The Design changes look good to me but I would get others to check the other changes.
0b89341
to
f5df44f
Compare
f5df44f
to
5651d3e
Compare
pending design discussion |
@@ -90,7 +91,8 @@ public static void ParseColumnDefinition(TableModel table, string statement) | |||
public static void ParseConstraints(TableModel table, string statement) | |||
{ | |||
var constraint = statement.Split(' ', '(')[0]; | |||
if (constraint.Equals("UNIQUE", StringComparison.OrdinalIgnoreCase)) | |||
if (constraint.Equals("UNIQUE", StringComparison.OrdinalIgnoreCase) | |||
|| statement.Equals(" PRIMARY KEY", StringComparison.OrdinalIgnoreCase)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests? I don't think this will work because of the space at the beginning of the string literal.
closing this in favour of #3764 |
Resolves #700
Key
&ForeignKey
has Index object associated.IsUnique
andIsClustered
from key/foreignkey moved to index object.Need review from @bricelam for Migrations & @AndriySvyryd for metadata.