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

Use DS exception safe API functions #243

Merged
merged 2 commits into from
Dec 19, 2016
Merged

Conversation

jgoizueta
Copy link
Contributor

See #242
Dataservices functions are replaced by their new, exception-safe counterparts.

The functions have been replaced using this Ruby script:

# Replace dataservices function calls by corresponding exception safe functions

DS_DIR = "~/www/dataservices-api/current"
functions_to_replace = `cat #{DS_DIR}/client/renderer/interface.yaml | grep -- '- name:' | awk '{print $3}'`.split
files_to_be_replaced = Dir['**/*.{js,sql}']

def exception_safe(f)
  "_#{f}_exception_safe"
end

files_to_be_replaced.each do |file|
  puts "Replacing in #{file}"  
  functions_to_replace.each do |fn|
    # It would be nice for this to be case insensitive, preserving case. But it isn't.
    # Note that the \b word boundaries makes this idempotent
    output = `sed -i -e "s/\\b#{fn}\\b/#{exception_safe(fn)}/g" "#{file}"`
    if !output.strip.empty?
      puts "  Replacing #{fn} :"
      puts output
    end
  end
end

# Problems: (must be solved manually)
# filenames replaced in test/setup.js (mock functions are defined in files named after the function)

The test/setup.js have been discarded.

See #242
Dataservices functions are replaced by their new, exception-safe counterparts.
@jgoizueta jgoizueta requested a review from rafatower December 14, 2016 17:56
@jgoizueta jgoizueta self-assigned this Dec 14, 2016
Copy link
Contributor

@rafatower rafatower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me but I don't understand the failures in the tests.

@jgoizueta
Copy link
Contributor Author

@rochoa this is related to CartoDB/dataservices-api#314

We're replacing the dataservices API functions used by new (internal, undocumented) functions that do not cause exceptions on errors and return NULLs/empty sets instead without rolling back transactions.

So this changes the behaviour of the analysis in case of errors, but not the nodes' interfaces and we don't need to update the reference package (right?)

@rafatower
Copy link
Contributor

@rochoa just for you to know, we applied the changes we discussed, and here you have a very small doc describing the exception-safe functions, to be used from now on:

https://github.com/CartoDB/dataservices-api/blob/master/doc/internal/exception_safe.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants