This repository was archived by the owner on Jul 21, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,31 @@ func (q *Query) checkBounds(pos int) error {
185185 return nil
186186}
187187
188+ type Serializable interface {
189+ Serialize (* frame.Option ) (n int32 , bytes []byte , err error )
190+ }
191+
192+ // BindAny allows binding any value to the bind marker at given pos in query,
193+ // it shouldn't be used on non-prepared queries, as it will always result in query execution error later.
194+ func (q * Query ) Bind (pos int , v Serializable ) * Query {
195+ if q .stmt .Metadata == nil {
196+ q .err = append (q .err , fmt .Errorf ("binding any to unprepared queries is not supported" ))
197+ return q
198+ }
199+ if err := q .checkBounds (pos ); err != nil {
200+ q .err = append (q .err , err )
201+ return q
202+ }
203+ p := & q .stmt .Values [pos ]
204+
205+ var err error
206+ p .N , p .Bytes , err = v .Serialize (& q .stmt .Metadata .Columns [pos ].Type )
207+ if err != nil {
208+ q .err = append (q .err , err )
209+ }
210+ return q
211+ }
212+
188213func (q * Query ) BindInt64 (pos int , v int64 ) * Query {
189214 if err := q .checkBounds (pos ); err != nil {
190215 q .err = append (q .err , err )
You can’t perform that action at this time.
0 commit comments