-
Notifications
You must be signed in to change notification settings - Fork 49
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
Save original data on translation error #335
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f9d57e4
port dumbed-down implementation from experiments branch.
c0c0n3 33d5c66
pin timescale/pg docker img version to latest known to be working w/ ql.
c0c0n3 fc0d876
pin timescale/pg docker img version to latest known to be working w/ ql.
c0c0n3 ada1298
upgrade all timescale test images to latest stable version.
c0c0n3 3738702
factor out safe reading of env vars.
c0c0n3 faa71e9
move reading of env vars out of translator.
c0c0n3 be43956
document env vars.
c0c0n3 73d46a7
implement optional saving of original data.
c0c0n3 97ab537
store original entities and associated recovery metadata as json.
c0c0n3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import logging | ||
import os | ||
|
||
from utils.cfgreader import EnvReader, BoolVar, IntVar | ||
|
||
|
||
DEFAULT_LIMIT_VAR = 'DEFAULT_LIMIT' | ||
KEEP_RAW_ENTITY_VAR = 'KEEP_RAW_ENTITY' | ||
|
||
|
||
class SQLTranslatorConfig: | ||
""" | ||
Provide access to SQL Translator config values. | ||
""" | ||
|
||
def __init__(self, env: dict = os.environ): | ||
self.store = EnvReader(var_store=env, | ||
log=logging.getLogger(__name__).info) | ||
|
||
def default_limit(self) -> int: | ||
fallback_limit = 10000 | ||
var = IntVar(DEFAULT_LIMIT_VAR, default_value=fallback_limit) | ||
return self.store.safe_read(var) | ||
|
||
def keep_raw_entity(self) -> bool: | ||
var = BoolVar(KEEP_RAW_ENTITY_VAR, False) | ||
return self.store.safe_read(var) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
so this should be the "safe" way, right?
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.
if sql injection proof is what you mean, yes in principle the question marks should stop a an attack based on dodgy values---well as long as the driver we use and the server do their job right. but i didn't actually change the way it used to work, just factor that bit of code out into a separate method without even thinking about sql injection to be honest. now that i look at it with malicious eyes, this line could still be a problem actually
the "safe" stuff i had in mind for this PR was to stop as much as reasonably possible the second insert from bombing out---i.e. the insert we do to recover from a SQL failure in the existing one. so e.g. we only save the bare min and in the plainest possible way, see code below.