You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This may be helpful as a temporary workaround. Note this is using a timestamp data type / MySQL.
/**
When creating a Column, a default value can be specified. If a string
is provided, the MySQLConnection.packType() method wraps the value
with "\'". This makes sense if you are specifying a default value
that is constant, but means the generated query for a current_timestamp
default value doesn't work (MySQL wants current_timestamp, not \"current_timestamp\")
The workaround is to provide a String(describing: _) value, which is done here.
*/
public enum DefaultValues {
public static let currentTimestamp = CurrentTimestamp()
public static let updatingTimestamp = UpdatingCurrentTimestamp()
}
public class CurrentTimestamp: CustomStringConvertible {
public var description = "CURRENT_TIMESTAMP"
}
public class UpdatingCurrentTimestamp: CustomStringConvertible {
public var description = "CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
}
Having the ability to use NOW() as a default value would allow users to implement an automatic created at column in their table definitions.
This work could be scoped with issue #117,
The text was updated successfully, but these errors were encountered: