MCPcopy Index your code
hub / github.com/upper/db / prepareQueryForDisplay

Function prepareQueryForDisplay

internal/sqlbuilder/builder.go:405–443  ·  view source on GitHub ↗
(in string)

Source from the content-addressed store, hash-verified

403}
404
405func prepareQueryForDisplay(in string) string {
406 out := make([]byte, 0, len(in))
407
408 offset := 0
409 whitespace := true
410 placeholders := 1
411
412 for i := 0; i < len(in); i++ {
413 if in[i] == ' ' || in[i] == '\r' || in[i] == '\n' || in[i] == '\t' {
414 if whitespace {
415 offset = i
416 } else {
417 whitespace = true
418 out = append(out, in[offset:i]...)
419 offset = i
420 }
421 continue
422 }
423 if whitespace {
424 whitespace = false
425 if len(out) > 0 {
426 out = append(out, ' ')
427 }
428 offset = i
429 }
430 if in[i] == '?' {
431 out = append(out, in[offset:i]...)
432 offset = i + 1
433
434 out = append(out, '$')
435 out = append(out, strconv.Itoa(placeholders)...)
436 placeholders++
437 }
438 }
439 if !whitespace {
440 out = append(out, in[offset:]...)
441 }
442 return string(out)
443}
444
445func (iter *iterator) NextScan(dst ...interface{}) error {
446 if ok := iter.Next(); ok {

Callers 5

StringMethod · 0.85
StringMethod · 0.85
TestPrepareForDisplayFunction · 0.85
StringMethod · 0.85
StringMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestPrepareForDisplayFunction · 0.68