DeriveParameters issue.

Offen
#6,382 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 6 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
csharp, postgresql
Bereich
database

Rechercherichtung

Start with the DeriveParameters call and the SELECT {function}($1) reproduction in the issue; compare how positional parameters are handled by the Npgsql SQL parser and PostgreSQL. No source file or test path is identified in the report, so locate the parameter-derivation code and its tests first. Done means the reproduction no longer throws the parser-mismatch error and the derived parameter count is one.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Is it wrong to derive command params with positional-like syntax?

    [Test, Description("Tests")]
    public async Task DeriveParameters_test()
    {
        await using var adminConnection = await OpenConnectionAsync();
        var type = await GetTempTypeName(adminConnection);
        await adminConnection.ExecuteNonQueryAsync($@"CREATE TYPE {type} AS (sval character varying, nval numeric)");

        var function = "test_func"; //await GetTempFunctionName(adminConnection);
        await adminConnection.ExecuteNonQueryAsync(
$@"CREATE OR REPLACE FUNCTION {function}(INOUT params ""{type}"")
returns ""{type}""
as
$BODY$
begin
  params.sval := params.sval || ' result';
  params.nval := params.nval * 10;
end;
$BODY$
  LANGUAGE plpgsql");

        var dataSourceBuilder = CreateDataSourceBuilder();
        //dataSourceBuilder.MapEnum<Fruit>(type);
        await using var dataSource = dataSourceBuilder.Build();
        await using var connection = await dataSource.OpenConnectionAsync();

        var cmd = new NpgsqlCommand($"SELECT {function}($1)", connection);    // here!!!! using '@param_name' will work
        NpgsqlCommandBuilder.DeriveParameters(cmd);
        Assert.That(cmd.Parameters, Has.Count.EqualTo(1));
    }

drops with

There was a mismatch in the number of derived parameters between the Npgsql SQL parser and the PostgreSQL parser. Please report this as bug to the Npgsql developers (https://github.com/npgsql/npgsql/issues)

npgsql 8.0.8

Vorherrschende Sprache
C#
Sterne
3.7k
Forks
890
Ø Merge
4 T. 11 Std.
Gemergte PRs (30 T.)
19

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

  • Kein Dockerfile und keine Docker-Compose-Datei
  • Keine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus npgsql/npgsql

Alle Issues in npgsql/npgsql

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.