-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
✨ add --ignore-errors flag #87
Conversation
return date.fromisoformat(value.decode()) | ||
decoded_value: str = value.decode() | ||
if " " in decoded_value: | ||
decoded_value = decoded_value.split(" ")[0] |
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 smells to me like you're trying to mangle a datetime into a date.
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.
Indeed. I'm sorry that I forgot to remove this piece and reverted that code. It was a bad and legacy database I tried to convert.
@@ -251,7 +252,7 @@ def _translate_type_from_sqlite_to_mysql(self, column_type: str) -> str: | |||
full_column_type: str = column_type.upper() | |||
match: t.Optional[t.Match[str]] = self._valid_column_type(column_type) | |||
if not match: | |||
raise ValueError("Invalid column_type!") | |||
raise ValueError("Invalid column_type: " + column_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.
Please use an f-string here, i.e.
raise ValueError(f"Invalid column_type: {column_type}")
auto_increment="AUTO_INCREMENT" if auto_increment else "", | ||
default="DEFAULT " + column["dflt_value"] | ||
if column["dflt_value"] and column_type not in MYSQL_COLUMN_TYPES_WITHOUT_DEFAULT and not auto_increment |
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 here you want to completely ignore the fact that a field can not have a default type? Why?
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.
Good find. That code should not have been deleted. I was mangling around with the code and I guess after a few iterations this piece got lost.
sql += " `{name}` {type} {notnull} {default} {auto_increment}, ".format( | ||
name=mysql_safe_name, | ||
type=column_type, | ||
notnull="NOT NULL" if column["notnull"] or column["pk"] else "NULL", | ||
notnull="NOT NULL" if not_null else "NULL", |
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 prefer the explicit condition for readability.
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.
OK
That's why I made the PR into a draft for now. 🤞Take your time with this. If this repo has taught me anything it's that one ounce of prevention is worth a pound of cure. 😊 I've left a few comments. Can you please take a look at them. Also, please add unit tests. 🙏 |
@CWBudde I closed this PR because it hasn't seen any activity in over 6 months. Please feel free to reopen if needed. |
Along with the --ignore-errors flag I also implemented a couple of other minor fixes. In the end it led to the fact that only 4 errors (due to bad design in the original sqlite3 database) needed to get fixed manually.
In the end I'm not 100% sure that the current code (after several revisions) is the best it could be. So I'd be happy about a critical review. In case the changes are too much, I could split this PR.