-
Notifications
You must be signed in to change notification settings - Fork 13.8k
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
[fix] make names non-nullable #8332
[fix] make names non-nullable #8332
Conversation
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.
@serenajiang would you mind adding the Alembic migration to the PR?
Codecov Report
@@ Coverage Diff @@
## master #8332 +/- ##
==========================================
+ Coverage 67.7% 73.22% +5.52%
==========================================
Files 447 115 -332
Lines 22652 12404 -10248
Branches 2363 0 -2363
==========================================
- Hits 15336 9083 -6253
+ Misses 7178 3321 -3857
+ Partials 138 0 -138
Continue to review full report at Codecov.
|
f9d6566
to
6c8b2fa
Compare
e3153a0
to
2989c9e
Compare
bind = op.get_bind() | ||
session = db.Session(bind=bind) | ||
|
||
session.query(DruidCluster).filter_by(cluster_name=None).update({"cluster_name": "NO_NAME"}) |
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 remove this as the migration should fail if there are NULL
values. Instead please add a line item to UPDATING.md
to indicate that this migration may fail (see other examples).
session.commit() | ||
|
||
op.alter_column('clusters', 'cluster_name', | ||
existing_type=mysql.VARCHAR(length=256), |
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 the generic SQLAlchemy types as used in other migrations.
|
||
|
||
def downgrade(): | ||
|
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.
nit: no newline
2989c9e
to
acbbbd4
Compare
One other request, can you add sql snippets to the PR explaining how to find the bad rows if the migration fails? you can follow the format here as an example: #5451 |
This reverts commit 65a05ca.
CATEGORY
Choose one
SUMMARY
If a user somehow creates a table with a null name, 503 errors occur whenever
repr(table)
is called because__repr__
returns a non-string type.Fixed schema to make columns referenced by
__repr__
non-nullable.Before running the migration, you must manually fix any records with null
clusters.cluster_name
,dbs.database_name
, ortables.table_name
. To find problematic records, run a query like:TEST PLAN
Confirmed that after upgrade, I get a warning if I try to insert a row with a null
table_name
.Confirmed that after downgrade, I am able to insert a row with a null
table_name
with no problem.ADDITIONAL INFORMATION
REVIEWERS
@graceguo-supercat @etr2460 @john-bodley