github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/table/data_query.go (about) 1 package table 2 3 import ( 4 "github.com/ydb-platform/ydb-go-genproto/protos/Ydb_Table" 5 6 "github.com/ydb-platform/ydb-go-sdk/v3/internal/allocator" 7 ) 8 9 type ( 10 query interface { 11 String() string 12 ID() string 13 YQL() string 14 15 toYDB(a *allocator.Allocator) *Ydb_Table.Query 16 } 17 textDataQuery string 18 preparedDataQuery struct { 19 id string 20 query string 21 } 22 ) 23 24 func (q textDataQuery) String() string { 25 return string(q) 26 } 27 28 func (q textDataQuery) ID() string { 29 return "" 30 } 31 32 func (q textDataQuery) YQL() string { 33 return string(q) 34 } 35 36 func (q textDataQuery) toYDB(a *allocator.Allocator) *Ydb_Table.Query { 37 query := a.TableQuery() 38 query.Query = a.TableQueryYqlText(string(q)) 39 40 return query 41 } 42 43 func (q preparedDataQuery) String() string { 44 return q.query 45 } 46 47 func (q preparedDataQuery) ID() string { 48 return q.id 49 } 50 51 func (q preparedDataQuery) YQL() string { 52 return q.query 53 } 54 55 func (q preparedDataQuery) toYDB(a *allocator.Allocator) *Ydb_Table.Query { 56 query := a.TableQuery() 57 query.Query = a.TableQueryID(q.id) 58 59 return query 60 } 61 62 func queryFromText(s string) query { 63 return textDataQuery(s) 64 } 65 66 func queryPrepared(id, query string) query { 67 return preparedDataQuery{ 68 id: id, 69 query: query, 70 } 71 }