(c context.Context, conn *sql.Conn)
| 952 | } |
| 953 | |
| 954 | func (s *gstate) setLocalUserID(c context.Context, conn *sql.Conn) (err error) { |
| 955 | if v := c.Value(UserIDKey); v == nil { |
| 956 | return nil |
| 957 | } else { |
| 958 | var val string |
| 959 | switch v1 := v.(type) { |
| 960 | case string: |
| 961 | val = v1 |
| 962 | case int: |
| 963 | val = strconv.Itoa(v1) |
| 964 | } |
| 965 | |
| 966 | q := s.getTargetPsqlCompiler().RenderSetSessionVar("user.id", val) |
| 967 | if q == "" { |
| 968 | return nil |
| 969 | } |
| 970 | |
| 971 | if tx := s.tx(); tx != nil { |
| 972 | _, err = tx.ExecContext(c, q) |
| 973 | } else { |
| 974 | _, err = conn.ExecContext(c, q) |
| 975 | } |
| 976 | } |
| 977 | return |
| 978 | } |
| 979 | |
| 980 | var errValidationFailed = errors.New("validation failed") |
| 981 |
no test coverage detected