Skip to content

Commit

Permalink
[#3816] create mv fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Oct 26, 2017
1 parent 400f538 commit 8f5b2f3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ckan/logic/schema.py
Expand Up @@ -102,7 +102,7 @@ def default_resource_schema():
'cache_last_updated': [ignore_missing, isodate],
'tracking_summary': [ignore_missing],
'datastore_active': [ignore_missing],
'query': [ignore_missing, unicode_only, datastore_resource_query],
'query': [ignore_empty, unicode_only, datastore_resource_query],
'__extras': [ignore_missing, extras_unicode_convert, keep_extras],
}

Expand Down
10 changes: 6 additions & 4 deletions ckanext/datastore/plugin.py
Expand Up @@ -190,12 +190,12 @@ def before_update(self, context, old, new):
# something that has changed (post-validation)
context.setdefault(
'datastore_old_query_values',
{})[old['resource_id']] = old.get('query')
{})[old['id']] = old.get('query')

def after_update(self, context, resource):
if not context.get('for_edit', False):
return
res_id = resource['resource_id']
res_id = resource['id']
query = resource.get('query')
if query != context['datastore_old_query_values'][res_id]:
sync_query_frontend(res_id, query)
Expand Down Expand Up @@ -332,8 +332,10 @@ def sync_query_frontend(resource_id, query):
try:
if query:
p.toolkit.get_action('datastore_create')(
None,
{'resource_id': resource_id, 'materialized_view_sql': query})
None, {
'resource_id': resource_id,
'materialized_view_sql': query,
'force': True})
else:
p.toolkit.get_action('datastore_delete')(
None,
Expand Down

0 comments on commit 8f5b2f3

Please sign in to comment.