You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Code starts failing with System.ArgumentException: Name is too long and would be truncated to: ... exceptions
The issue
The length calculation in the DataTypeName ctor is incorrect.
System.ArgumentException: Name is too long and would be truncated to: ampc.asset_monitoring_point_trigger_expression_parameter_cache_ite
at Npgsql.Internal.Postgres.DataTypeName..ctor(String fullyQualifiedDataTypeName, Boolean validated)
at Npgsql.Internal.Postgres.DataTypeName..ctor(String fullyQualifiedDataTypeName)
at Npgsql.Internal.Postgres.DataTypeName.FromDisplayName(String displayName, String schema)
at Npgsql.PostgresTypes.PostgresType..ctor(String ns, String name, UInt32 oid)
at Npgsql.PostgresTypes.PostgresCompositeType..ctor(String ns, String name, UInt32 oid)
at Npgsql.PostgresDatabaseInfo.LoadBackendTypes(NpgsqlConnector conn, NpgsqlTimeout timeout, Boolean async)
at Npgsql.PostgresDatabaseInfo.LoadPostgresInfo(NpgsqlConnector conn, NpgsqlTimeout timeout, Boolean async)
at Npgsql.PostgresDatabaseInfoFactory.Load(NpgsqlConnector conn, NpgsqlTimeout timeout, Boolean async)
at Npgsql.Internal.NpgsqlDatabaseInfo.Load(NpgsqlConnector conn, NpgsqlTimeout timeout, Boolean async)
at Npgsql.NpgsqlDataSource.Bootstrap(NpgsqlConnector connector, NpgsqlTimeout timeout, Boolean forceReload, Boolean async, CancellationToken cancellationToken)
at Npgsql.Internal.NpgsqlConnector.Open(NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.UnpooledDataSource.Get(NpgsqlConnection conn, NpgsqlTimeout timeout, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlConnection.<Open>g__OpenAsync|42_0(Boolean async, CancellationToken cancellationToken)
at Pragma.OnKey.Data.SqlConnection.Open() in C:\Dev\git\onkey-plus-server\src\Pragma.OnKey.Infrastructure\Data\SqlConnection.cs:line 205
at Pragma.OnKey.Migrations.MigrationContext.InitialiseMigration(IMigrationDao dao, IMigrationRegistry migrationRegistry) in C:\Dev\git\onkey-plus-server\src\Pragma.OnKey.Infrastructure\Migrations\MigrationContext.cs:line 536
at Pragma.OnKey.Migrations.MigrationContext.InitialiseMigration(IMigrationDao dao, IMigrationRegistry migrationRegistry) in C:\Dev\git\onkey-plus-server\src\Pragma.OnKey.Infrastructure\Migrations\MigrationContext.cs:line 545
at Pragma.OnKey.Migrations.MigrationContext.RunMigration(IMigrationDao dao, IMigrationRegistry migrationRegistry, CancellationToken cancellationToken) in C:\Dev\git\onkey-plus-server\src\Pragma.OnKey.Infrastructure\Migrations\Migrati
From investigation it seems the length is currently calculated incorrectly in the ctor here
Shouldn't it rather be be var typeNameLength = fullyQualifiedDataTypeName.Length - (schemaEndIndex + 1);
Can be verified with the following snippet:
// create 63 characters max PG length typevarname="asset_monitoring_point_trigger_expression_parameter_cache_item";varfullyQualifiedDataTypeName=$"ampc.{name}";varschemaEndIndex= fullyQualifiedDataTypeName.IndexOf('.');varbuggyTypeNameLength= fullyQualifiedDataTypeName.Length -schemaEndIndex+1;varfixedTypeNameLength= fullyQualifiedDataTypeName.Length -(schemaEndIndex+1);varactualLength= name.Length;
Debug.Assert(actualLength==fixedTypeNameLength,"Bug not fixed");
Debug.Assert(actualLength==buggyTypeNameLength,"Bug illustrated");
Further technical details
Npgsql version: 8.0.0
PostgreSQL version:
Operating system: Windows
The text was updated successfully, but these errors were encountered:
cjlotz
changed the title
Npsql 8 regression: System.ArgumentException: Name is too long and would be truncated
npgsql 8 regression: System.ArgumentException: Name is too long and would be truncated
Nov 27, 2023
Steps to reproduce
System.ArgumentException: Name is too long and would be truncated to: ...
exceptionsThe issue
The length calculation in the
DataTypeName
ctor is incorrect.From investigation it seems the length is currently calculated incorrectly in the ctor here
Shouldn't it rather be be
var typeNameLength = fullyQualifiedDataTypeName.Length - (schemaEndIndex + 1);
Can be verified with the following snippet:
Further technical details
Npgsql version: 8.0.0
PostgreSQL version:
Operating system: Windows
The text was updated successfully, but these errors were encountered: