-
Notifications
You must be signed in to change notification settings - Fork 31
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
Exception on Delete #85
Comments
Thank you @sp00n5 for the report! It looks like a problem with the library incorrectly parsing the DELETE response, not something you are doing wrong. Based on the exception it appears there are two problems: 1) the raw JSON coming back is an array, where the delete operation is expecting an object and 2) the deserialization target object ( If you are able, can you post the raw JSON response that comes back after your delete? If you place a breakpoint on the |
I just realized something... assuming you are using the Nuget package, the If you've downloaded this repo and have a direct project reference in your solution, here's what you can do:
|
Thanks @sp00n5! This confirms that it is a problem with how
Are you comfortable submitting a patch to fix this? |
Sure, I will give it a go...
On Friday, 10 April 2020, 9:57:25 am AEST, Kegan Maher <notifications@github.com> wrote:
Thanks @sp00n5! This confirms that it is a problem with how SodaClient.DeleteRow interprets the response:
- The response is an array of objects, not a single object
- The deserialization target must have properties typ (thought this may have been a typo in the docs, but thanks for verifying!) and id.
Are you comfortable submitting a patch to fix this?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I have modified the SodaClient.DeleteRow to accept an Array (SodaResult[]) and added the required members to the SodaResult Class. Works fine now when the delete is successful, however, when the delete fails it returns an object, not an array eg:
So now we get the same exception as original but now on failure instead of success.. |
Thanks for working on this, all I can say is, wow... how annoying that there are so many different return types depending on the use case/operation. This seems to be a problem with It also seems this error message doesn't conform to the docs which state that the member should be At this point I can think of one ugly workaround, to make |
After reviewing Socrata's own Java-based tool "DataSync" for data publishing, there is another option that we can pursue which may be cleaner, if not a bit more complex. Rather than issuing a {
"<row_id_field>": "<input_id>",
":deleted": true
} The only issue here is the exact field name for Then just pass this JSON string into a call to This seems to be exactly what Socrata's DataSync does. |
I thought about trying the 'dynamic' approach also but it felt a bit like a work around rather than a solution. I'm not sure why the deleterow would need to return an array on success, it can only ever be a single row operation as far as I understand? Maybe they can review that? |
I definitely agree, it seems very strange and inconsistent.
Socrata's Upsert functionality supports create, update, and delete for one or more rows at once (with properly crafted payloads). So this isn't so much a a workaround - we would simply be using Upsert to mark a single row for deletion rather than direct row delete functionality. For a user of this library, it should be entirely transparent. Since their desktop tool makes use of the Upsert functionality vs. direct row delete, it seems to be inline with established practice. They have another Java library (on which this library was based) where the direct row delete method returns void, thus avoiding (ahem) this problem altogether! |
Is the main goal here not to break anyone's existing code? I think your idea will work. I will give it a try. |
Yes, ensuring that existing code works is certainly a goal. I think since we already only accept a string for the In the worst case, we can interrogate the Column metadata to find out the type of the Id column, and cast as needed before sending the request. |
Hi, I'm guessing this is me doing something wrong but I cant see what. I get an InvalidOperationException every time I delete a row, even though it deletes successfully.
Example code:
Exception:
Similar to this?? #5
Any ideas?
Thanks
The text was updated successfully, but these errors were encountered: