Skip to content

Populate DbType for PostgreSql#3645

Draft
unattendedfaxmachine wants to merge 12 commits into
Azure:mainfrom
unattendedfaxmachine:user/mm/pg_datetime_support
Draft

Populate DbType for PostgreSql#3645
unattendedfaxmachine wants to merge 12 commits into
Azure:mainfrom
unattendedfaxmachine:user/mm/pg_datetime_support

Conversation

@unattendedfaxmachine
Copy link
Copy Markdown

Why make this change?

This PR is to address #3094, which is a bug that happens because the default type conversion for C# to Npgsql is to convert a string to a TEXT field, but this doesn't work when trying to compare a DATE type for PostgreSql databases.

This PR is a consolidation/continuation/experimentation of prior work here:

What is this change?

My change passes the column name of the Postgres column attempting to be filtered through to the filtering context, and then we override PopulateDbTypeForParameter to pass the DBType value through to Npgsql, much like how this is done for MsSql. This hopefully means that Npgsql knows to convert the C# string into something that works with the DATE (and every other) column type.

How was this tested?

(Currently untested)

  • Integration Tests
  • Unit Tests

Sample Request(s)

With query:

query {
  todos(filter: { dueDate: { gte: "2024-01-01T00:00:00.000Z" } }) {
    items {
      dueDate
    }
  }
}

Before:

SELECT * FROM public."Todos"
WHERE "Todos"."dueDate" >= '2025-01-01T00:00:00Z'::text;

(Hopefully After):

SELECT * FROM public."Todos"
WHERE "Todos"."dueDate" >= '2025-01-01T00:00:00Z';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants