MCPcopy
hub / github.com/github/gh-ost / TestBuildUniqueKeyMinValuesPreparedQuery

Function TestBuildUniqueKeyMinValuesPreparedQuery

go/sql/builder_test.go:705–738  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

703}
704
705func TestBuildUniqueKeyMinValuesPreparedQuery(t *testing.T) {
706 databaseName := "mydb"
707 originalTableName := "tbl"
708 uniqueKeyColumns := NewColumnList([]string{"name", "position"})
709 uniqueKey := &UniqueKey{Name: "PRIMARY", Columns: *uniqueKeyColumns}
710 {
711 query, err := BuildUniqueKeyMinValuesPreparedQuery(databaseName, originalTableName, uniqueKey)
712 require.NoError(t, err)
713 expected := `
714 select /* gh-ost mydb.tbl */ name, position
715 from
716 mydb.tbl
717 force index (PRIMARY)
718 order by
719 name asc, position asc
720 limit 1
721 `
722 require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
723 }
724 {
725 query, err := BuildUniqueKeyMaxValuesPreparedQuery(databaseName, originalTableName, uniqueKey)
726 require.NoError(t, err)
727 expected := `
728 select /* gh-ost mydb.tbl */ name, position
729 from
730 mydb.tbl
731 force index (PRIMARY)
732 order by
733 name desc, position desc
734 limit 1
735 `
736 require.Equal(t, normalizeQuery(expected), normalizeQuery(query))
737 }
738}
739
740func TestBuildDMLDeleteQuery(t *testing.T) {
741 databaseName := "mydb"

Callers

nothing calls this directly

Calls 4

NewColumnListFunction · 0.85
normalizeQueryFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…