-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[db] MySQL: Set --explicit-defaults-for-timestamp=OFF #4226
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -31,6 +31,7 @@ export class DBPrebuiltWorkspace implements PrebuiltWorkspace { | |||||
@Column({ | ||||||
type: 'timestamp', | ||||||
precision: 6, | ||||||
default: () => 'CURRENT_TIMESTAMP(6)', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same question here:
Suggested change
|
||||||
transformer: Transformer.MAP_ISO_STRING_TO_TIMESTAMP_DROP | ||||||
}) | ||||||
creationTime: string; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,6 +20,7 @@ export class DBSnapshot implements Snapshot { | |||||
@Column({ | ||||||
type: 'timestamp', | ||||||
precision: 6, | ||||||
default: () => 'CURRENT_TIMESTAMP(6)', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
TBH I did not - but propably should have - cross-verified this with the actual DB columns but judged from the meaning.... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @geropl I'm happy to align this the other way around then, by removing the Would that make sense? |
||||||
transformer: Transformer.MAP_ISO_STRING_TO_TIMESTAMP_DROP | ||||||
}) | ||||||
creationTime: string; | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,7 +26,11 @@ export namespace Transformer { | |||||
|
||||||
export const MAP_ISO_STRING_TO_TIMESTAMP_DROP: ValueTransformer = { | ||||||
to(value: any): any { | ||||||
// DROP all input values as they are set by the DB 'ON UPDATE'/ as default value | ||||||
// DROP all input values as they are set by the DB 'ON UPDATE'/ as default value. | ||||||
// We're relying on the system variable explicit-defaults-for-timestamp here (link: https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_explicit_defaults_for_timestamp): | ||||||
// `undefined` gets converted to NULL, which on the DB is turned into the configured default value for the column. | ||||||
// In our case, that's 100% CURRENT_TIMESTAMP. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I'd prefer being super-explicit here, in order to not leave any room for confusion
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think precision 6 we only have for part of them, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
// This was done initially so we don't have to make fields like `creationTime` optional, or have to use two types for the same table. | ||||||
return undefined; | ||||||
}, | ||||||
from(value: any): any { | ||||||
|
@@ -72,4 +76,4 @@ export class CompositeValueTransformer implements ValueTransformer { | |||||
from(value: any): any { | ||||||
return this.upper.from(this.lower.from(value)); | ||||||
} | ||||||
} | ||||||
} |
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.
Same question: