Optimize marshalling for jsonb types (#19898)
We check for the presence of binary_parameters in the DSN and add the 0x01 byte accordingly. This helps us avoid casting to string and efficiently use the database. ```release-note NONE ``` Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
ec91ca46ff
Коммит
2e027ae927
@@ -43,10 +43,14 @@ func (me SqlSessionStore) Save(session *model.Session) (*model.Session, error) {
|
||||
return nil, errors.Wrap(err, "failed marshalling session props")
|
||||
}
|
||||
|
||||
if me.IsBinaryParamEnabled() {
|
||||
jsonProps = me.AppendBinaryFlag(jsonProps)
|
||||
}
|
||||
|
||||
query, args, err := me.getQueryBuilder().
|
||||
Insert("Sessions").
|
||||
Columns("Id", "Token", "CreateAt", "ExpiresAt", "LastActivityAt", "UserId", "DeviceId", "Roles", "IsOAuth", "ExpiredNotify", "Props").
|
||||
Values(session.Id, session.Token, session.CreateAt, session.ExpiresAt, session.LastActivityAt, session.UserId, session.DeviceId, session.Roles, session.IsOAuth, session.ExpiredNotify, string(jsonProps)).
|
||||
Values(session.Id, session.Token, session.CreateAt, session.ExpiresAt, session.LastActivityAt, session.UserId, session.DeviceId, session.Roles, session.IsOAuth, session.ExpiredNotify, jsonProps).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "sessions_tosql")
|
||||
@@ -263,9 +267,12 @@ func (me SqlSessionStore) UpdateProps(session *model.Session) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed marshalling session props")
|
||||
}
|
||||
if me.IsBinaryParamEnabled() {
|
||||
jsonProps = me.AppendBinaryFlag(jsonProps)
|
||||
}
|
||||
query, args, err := me.getQueryBuilder().
|
||||
Update("Sessions").
|
||||
Set("Props", string(jsonProps)).
|
||||
Set("Props", jsonProps).
|
||||
Where(sq.Eq{"Id": session.Id}).
|
||||
ToSql()
|
||||
if err != nil {
|
||||
|
||||
Ссылка в новой задаче
Block a user