Support for using TEXT as a foreign key target#1260
Conversation
|
|
|
|
||
| // foreignKeyComparableTypes returns whether the two given types are able to be used as parent/child columns in a | ||
| // foreign key. | ||
| func foreignKeyComparableTypes(ctx *sql.Context, type1 sql.Type, type2 sql.Type) bool { |
There was a problem hiding this comment.
These can be DoltgresTypes rather than sql.Type
| // There seems to be a special case where CHAR/VARCHAR/BINARY/VARBINARY can have unequal lengths. | ||
| // Have not tested every type nor combination, but this seems specific to those 4 types. | ||
| if type1.Type() == type2.Type() { | ||
| switch type1.Type() { |
There was a problem hiding this comment.
Adding on to my other comment, we aren't too strict on ensuring that these are returned correctly, considering they don't map to all of our types so it's not really possible to do so. Instead, it's better to check for these specific types. You could even use type1.ID.TypeName() and switch on the string name. But like oid returns sqltypes.VarChar cause there's no oid type in MySQL so we're just returning something.
I think switch type1.ID with case pgtypes.Varchar.ID should work, but if not you can grab the case values using Id.CaseString() and match on the string directly (so you'd just use case "CaseString_Output").
|
Subsumed by #1277 |
This PR relies on dolthub/go-mysql-server#2882