-
Notifications
You must be signed in to change notification settings - Fork 58
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(backfill): update a_urn column during entity table backfill #491
Conversation
private static final String SQL_UPSERT_ASPECT_WITH_URN_TEMPLATE = | ||
"INSERT INTO %s (urn, a_urn, %s, lastmodifiedon, lastmodifiedby) VALUE (:urn, :a_urn, :metadata, :lastmodifiedon, :lastmodifiedby) " | ||
+ "ON DUPLICATE KEY UPDATE %s = :metadata, lastmodifiedon = :lastmodifiedon;"; | ||
+ "ON DUPLICATE KEY UPDATE %s = :metadata, lastmodifiedon = :lastmodifiedon, a_urn = :a_urn;"; |
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.
would this logic only be called when a_urn column presents? how to ensure this or can you clarify in the comment a_urn always exists when this is called and 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.
I added a comment
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.
Basically yes, there is a flag that is passed into all of the SQL statement methods that indicates whether the a_urn column exists. If it does, then use template 1, if not, use template 2
@@ -43,7 +43,7 @@ public void testCreateUpsertAspectSql() { | |||
String expectedSql = | |||
"INSERT INTO metadata_entity_foo (urn, a_urn, a_aspectfoo, lastmodifiedon, lastmodifiedby) VALUE (:urn, " | |||
+ ":a_urn, :metadata, :lastmodifiedon, :lastmodifiedby) ON DUPLICATE KEY UPDATE a_aspectfoo = :metadata," | |||
+ " lastmodifiedon = :lastmodifiedon;"; | |||
+ " lastmodifiedon = :lastmodifiedon, a_urn = :a_urn;"; |
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.
do we have similar unit test that covers entity without a_urn
?
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.
It is right underneath. There is a flag passed into createUpsertAspectSql()
which indicates if a_urn column exists or not. It is only controlled by the DAO code, not the user.
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.
sounds good, thanks for clarification.
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.
LGTM
Summary
Currently, backfillEntityTables API does not backfill the a_urn column. This is an oversight since we never expected to need to backfill this column and it cannot be backfilled like other aspect columns. Thus, the solution is to add it to the upsert SQL which is called in EbeanLocalAccess::add.
Testing Done
./gradlew build
Checklist