-
Notifications
You must be signed in to change notification settings - Fork 934
Fix schema validator for Npgsql 5 #2992
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
Conversation
Imo this is the least intrusive approach that works for both Npgsql 5 and Npgsql 4. I was considering doing the other way around (normalize to Npgsql 5 type system). But that require more changes and could be a breaking changes due to changes to the dialect for some users (if, eg, they do textual schema compare). |
@bahusoid, @fredericDelaporte are you ok with including this to 5.3.x? |
Yeah. Why not... |
Rebased to 5.3.x |
switch (typeName) | ||
{ | ||
case "double precision": | ||
return "float8"; | ||
case "real": | ||
return "float4"; | ||
case "smallint": | ||
return "int2"; | ||
case "integer": | ||
return "int4"; | ||
case "bigint": | ||
return "int8"; | ||
} |
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.
We can see the naming changes in Npgsql change commit, or infer it from PostgreSQL documentation.
It looks like we were already having an issue with older Npgsql drivers, because we were using the complete name, boolean
, while older drivers were previously supposed to yield the short name, bool
. That trouble would be fixed since we do not translate it to its short name here.
But then we keep an inconsistency: the dialect and now the metadata are using PostgreSQL type short aliases for most types excepted for the boolean type.
For the same reasons than in this comment, normalizing this would be breaking. So, let it stay that way.
|
||
if (typeName.StartsWith("character", StringComparison.Ordinal)) | ||
{ | ||
return typeName.Replace("character varying", "varchar").Replace("character", "char"); |
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.
It is likely we are fixing another old trouble by the way here: for fixed length character types, the older Npgsql drivers could yield bpchar
, while our dialects are using char
.
I am used to the "auto-merge" feature on Azure DevOps, but not here on GitHub. It was quite a surprise for me. It lacks visibility I think. |
Npgsql 5 returns different type names for some of the types. Normalize them back to what dialect expects.
Fixes #2876