-
Notifications
You must be signed in to change notification settings - Fork 291
Add MySQL RESTAPI POST/PUT support and Tests #260
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
Conversation
|
|
||
| [TestMethod] | ||
| [Ignore] | ||
| public override Task InsertOneInCompositeKeyTableTest() |
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.
Does this test work even though its composite PK? I thought it doesnt... So, why remove the ignore ?
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.
it works as far as only one autogen column.
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.
I see, so the problem with composite key happens only when both are autogenerated.. I'll note this in the issue #264
| public override Task PutOne_Insert_PKAutoGen_Test() | ||
| { | ||
| throw new NotImplementedException(); | ||
| throw new NotImplementedException("error: Fail, still able to insert"); |
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.
Why are you still able to insert ? Is there an issue in request validation ?
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.
I may need some help to understand the tests here. Why this insert should fail?
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.
This insert should fail because the PK is autogenerated but the request also specifies a PK value in the route. We wouldn't know if the PK specified is present in the DB or not - hence we cannot stop this case in request validation. Instead, we need to send it to the DB and let the DB handle this conflicting situation.
PUT should have upsert semantics is recommended by the API https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#74-supported-methods
Does MySQL still allow inserting even if it were autogenerated?
What ID does it get inserted in that case?
If it still gets inserted, we can allow the insert to happen for MySQL if the ID with which it is inserted is the same as the request ID. Created this issue to tackle this : #274
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.
MySQL allow insert with an id which is auto_inc. it will allow to insert anyway. If the id is larger than the current max id, the max id is updated to avoid duplicate id later.
My suggestion is that we should deal with this in high level instead of adapter.
If a autogen id is in the given column list, upsert should be handled as update as insert will anyway fail. The adapter should get a insert request and upper layer handles the different cases. Thoughts?
| } | ||
| else if (structure.GetColumnDefinition(colName).IsAutoGenerated) | ||
| { | ||
| //TODO: This assumes one column PK |
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.
There is a test for Insert with multi column PKs already :
InsertOneInCompositeKeyTableTest Is that working for you ?
Aniruddh25
left a comment
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.
Thanks for this quick PR. Have some questions and suggestions.
Could you also please update the PR description to say it adds support for MySQL REST POST/PUT
6813442 to
88b24cf
Compare
88b24cf to
2a75ca0
Compare
Aniruddh25
left a comment
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.
LGTM! Thank you again for the quick implementation.
Lets tackle the PutOne_Insert_PKAutoGen failure in a next PR...
Uh oh!
There was an error while loading. Please reload this page.