-
Notifications
You must be signed in to change notification settings - Fork 8
DataStore Records Return (Core PR#8684) #200
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: canada-v2.10
Are you sure you want to change the base?
DataStore Records Return (Core PR#8684) #200
Conversation
- Return records capability. - Improved ds upsert sql.
- Added change log file.
| return_columns=return_columns) if data_dict[ | ||
| 'include_records'] else '', | ||
| values=('%s, ' % pk_values_sql if pk_sql == '"_id"' else '') + | ||
| ', '.join([f'cast(:{p} as nested)' if field['type'] == 'nested' |
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 nested type haunts the datastore code base since before postgres had a built-in json type 👻
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.
r we fixing it upstream eventually?
| # (canada fork only): https://github.com/ckan/ckan/pull/8684 | ||
| results =_execute_single_statement(context, sql_string, where_values) | ||
| if data_dict['include_records']: | ||
| data_dict['deleted_records'] = [dict(r) for r in results.mappings().all()] |
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 could see this causing a MemoryError when deleting all the rows in a large table.
For dsaudit we only need the first N rows to populate the activity. Can we apply a LIMIT to a DELETE ... RETURNING?
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.
you have to do something like this I guess: https://stackoverflow.com/a/37043809
which would require some bigger sql statement changes which could be done. This code is for my datastore solr index plugin, so I would need to have all of the deleted records I think?
| result.pop('connection_url', None) | ||
| # (canada fork only): https://github.com/ckan/ckan/pull/8684 | ||
| if not data_dict.pop('include_records', False): | ||
| result.pop('deleted_records', None) |
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.
for all of the other endpoints "include_records" adds a "records" value to the return but datastore_delete is different?
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.
yeah, just semantically for API users to make it clear that the records were deleted
- Upstream PR changes.
feat(dev): ds return backport;
ckan#8684