-
Notifications
You must be signed in to change notification settings - Fork 304
Populate DbType for PostgreSql #3101
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
base: main
Are you sure you want to change the base?
Populate DbType for PostgreSql #3101
Conversation
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.
Pull request overview
This pull request attempts to fix issue #3094 where PostgreSQL date filters fail with "operator does not exist: date >= text" errors. The PR tries to pass column names through the filtering pipeline to enable proper type conversion for PostgreSQL parameters, similar to the existing MsSQL implementation.
Changes:
- Modified GraphQL filter parsing to pass column names through to the parameter creation logic
- Added a PopulateDbTypeForParameter method to PostgreSqlExecutor (incomplete implementation)
- Updated documentation comments to reflect PostgreSQL support
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Core/Models/GraphQLFilterParsers.cs | Adds columnName parameter to GenerateRightOperand and passes it through to processLiterals for proper type resolution |
| src/Core/Resolvers/PostgreSqlExecutor.cs | Adds static PopulateDbTypeForParameter method, but implementation is incomplete and non-functional |
| src/Core/Resolvers/IQueryExecutor.cs | Updates documentation to indicate PostgreSQL support |
| src/Core/Resolvers/QueryExecutor.cs | Updates documentation to indicate PostgreSQL support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot, please rereview the PR |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Recommendations
// Change from static to override
public override void PopulateDbTypeForParameter(KeyValuePair<string, DbConnectionParam> parameterEntry, DbParameter parameter)
{
if (parameterEntry.Value is not null && parameterEntry.Value.DbType is not null)
{
parameter.DbType = (DbType)parameterEntry.Value.DbType;
}
}
🔍 What to TestBased on issue #3094, ensure these queries work: query {
todos(filter: { dueDate: { gte: "2024-01-01T00:00:00.000Z" } }) {
items { dueDate }
}
}The generated SQL should not have -- Should generate:
WHERE "Todos"."dueDate" >= $1 -- with DbType.Date
-- NOT:
WHERE "Todos"."dueDate" >= $1::textSummaryThis PR is on the right track but needs the method signature fix before it will work. The Copilot review caught a critical issue that must be addressed. Once fixed and tested, this should resolve the PostgreSQL date filtering problem. |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
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.
What is this change?
PopulateDbTypeForParameterto 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)
Sample Request(s)
With query:
Before:
(Hopefully After):