Skip to content
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

Update PostgresAdapter to Generate Id Column with AppendColumnName #1544

Closed
wants to merge 2 commits into from

Conversation

dogac00
Copy link
Contributor

@dogac00 dogac00 commented Sep 22, 2020

Currently, PostgresAdapter generates query for columns with quotes like this: "Column". But it does not add quotes in returning clause when we are returning Id.

I think this PR should fix "Column Id does not exist." error we encounter in PostgreSQL while using InsertAsync.

Related issues:
#481
https://github.com/StackExchange/Dapper/issues/1213
https://github.com/StackExchange/Dapper/issues/1541

@NickCraver
Copy link
Member

Unfortunately, this is a breaking change. While it may help you, it will break others - please see #722 on future plans there. In the mean time, you can quote the column name in your attributes if you want it to be case-sensitive.

@dogac00
Copy link
Contributor Author

dogac00 commented Sep 22, 2020

Which attribute can we use on our property if we want it to be case-sensitive and quoted? As far as I know, Dapper.Contrib currently does not have ColumnAttribute.

Also even if we add ColumnAttribute on our Id it will still generate RETURNING Id from this line sb.Add(property.Name) and give error in PostgreSQL because my column name there is "Id".

I think we have to implement this breaking change if we want to support Column name mapping.

@dogac00
Copy link
Contributor Author

dogac00 commented Sep 23, 2020

In addition, don't you think there is an inconsistency in this generated query:

INSERT INTO Products ("Name", "ItemNumber") VALUES (@Name, @ItemNumber) RETURNING Id

Columns are quoted but Id is not. I think if we quote columns we should quote Id, because it is a column too.

@dogac00 dogac00 changed the title Update PostgresAdapter to Id Column with AppendColumnName Update PostgresAdapter to Generate Id Column with AppendColumnName Oct 12, 2020
@NickCraver
Copy link
Member

I can't speak to Contrib's future plans here and if this is a good fit, but please see #1658 - Dapper.Contrib is not located at https://github.com/DapperLib/Dapper.Contrib (separate from this repository).

Note: I based the Dapper.Contrib fork on the original codebase which hopefully makes porting pull requests against the main branch there much easier - the intent was to split, not throw away work the community wants to go with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:contrib Dapper.Contrib related breaking-change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants