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

Method TestFunction

internal/testsuite/sql_suite.go:830–885  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

828}
829
830func (s *SQLTestSuite) TestFunction() {
831 sess := s.Session()
832
833 rowStruct := struct {
834 ID int64
835 Name string
836 }{}
837
838 artist := sess.Collection("artist")
839
840 cond := db.Cond{"id NOT IN": []int{0, -1}}
841 if s.Adapter() == "ql" {
842 cond = db.Cond{"id() NOT IN": []int{0, -1}}
843 }
844 res := artist.Find(cond)
845
846 err := res.One(&rowStruct)
847 s.NoError(err)
848
849 total, err := res.Count()
850 s.NoError(err)
851 s.Equal(uint64(4), total)
852
853 // Testing conditions
854 cond = db.Cond{"id NOT IN": []interface{}{0, -1}}
855 if s.Adapter() == "ql" {
856 cond = db.Cond{"id() NOT IN": []interface{}{0, -1}}
857 }
858 res = artist.Find(cond)
859
860 err = res.One(&rowStruct)
861 s.NoError(err)
862
863 total, err = res.Count()
864 s.NoError(err)
865 s.Equal(uint64(4), total)
866
867 res = artist.Find().Select("name")
868
869 var rowMap map[string]interface{}
870 err = res.One(&rowMap)
871 s.NoError(err)
872
873 total, err = res.Count()
874 s.NoError(err)
875 s.Equal(uint64(4), total)
876
877 res = artist.Find().Select("name")
878
879 err = res.One(&rowMap)
880 s.NoError(err)
881
882 total, err = res.Count()
883 s.NoError(err)
884 s.Equal(uint64(4), total)
885}
886
887func (s *SQLTestSuite) TestNullableFields() {

Callers

nothing calls this directly

Calls 7

SessionMethod · 0.65
CollectionMethod · 0.65
AdapterMethod · 0.65
FindMethod · 0.65
OneMethod · 0.65
CountMethod · 0.65
SelectMethod · 0.65

Tested by

no test coverage detected