NewPlaceholder allocates a Placeholder.
(name string)
| 781 | |
| 782 | // NewPlaceholder allocates a Placeholder. |
| 783 | func NewPlaceholder(name string) (*Placeholder, error) { |
| 784 | uval, err := strconv.ParseUint(name, 10, 64) |
| 785 | if err != nil { |
| 786 | return nil, err |
| 787 | } |
| 788 | // The string is the number that follows $ which is a 1-based index ($1, $2, |
| 789 | // etc), while PlaceholderIdx is 0-based. |
| 790 | if uval == 0 || uval > MaxPlaceholderIdx+1 { |
| 791 | return nil, pgerror.Newf( |
| 792 | pgcode.NumericValueOutOfRange, |
| 793 | "placeholder index must be between 1 and %d", MaxPlaceholderIdx+1, |
| 794 | ) |
| 795 | } |
| 796 | return &Placeholder{Idx: PlaceholderIdx(uval - 1)}, nil |
| 797 | } |
| 798 | |
| 799 | // Format implements the NodeFormatter interface. |
| 800 | func (node *Placeholder) Format(ctx *FmtCtx) { |
no test coverage detected
searching dependent graphs…