sqldb: add SQLStrValid helper
The SQL* helpers are meant to always set the `Valid` field of the sql.Null* type to true. Otherwise they cannot be used to set a valid, empty field. However, we dont want to break the behaviour of the existing SQLStr helper and so this commit adds a new helper with the desired functionality.
This commit is contained in:
3 files changed
+19
-4
No files matched your search
@@ -1380,8 +1380,8 @@ func insertNodeSQLMig(ctx context.Context, db SQLQueries,
|
||||
|
||||
if node.HaveNodeAnnouncement {
|
||||
params.LastUpdate = sqldb.SQLInt64(node.LastUpdate.Unix())
|
||||
params.Color = sqldb.SQLStr(EncodeHexColor(node.Color))
|
||||
params.Alias = sqldb.SQLStr(node.Alias)
|
||||
params.Color = sqldb.SQLStrValid(EncodeHexColor(node.Color))
|
||||
params.Alias = sqldb.SQLStrValid(node.Alias)
|
||||
params.Signature = node.AuthSigBytes
|
||||
}
|
||||
|
||||
|
||||
@@ -3391,8 +3391,8 @@ func upsertNode(ctx context.Context, db SQLQueries,
|
||||
|
||||
if node.HaveNodeAnnouncement {
|
||||
params.LastUpdate = sqldb.SQLInt64(node.LastUpdate.Unix())
|
||||
params.Color = sqldb.SQLStr(EncodeHexColor(node.Color))
|
||||
params.Alias = sqldb.SQLStr(node.Alias)
|
||||
params.Color = sqldb.SQLStrValid(EncodeHexColor(node.Color))
|
||||
params.Alias = sqldb.SQLStrValid(node.Alias)
|
||||
params.Signature = node.AuthSigBytes
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user