mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: expose config on generated filters (#2473)
This commit is contained in:
@@ -82,7 +82,7 @@ type predicateAdder interface {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the {{ $builder }} builder.
|
||||
func ({{ $receiver }} *{{ $builder }}) Filter() *{{ $filter }} {
|
||||
return &{{ $filter }}{ {{ $receiver }} }
|
||||
return &{{ $filter }}{ {{ $receiver }}.config, {{ $receiver}} }
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -92,11 +92,12 @@ type predicateAdder interface {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the {{ $mutation }} builder.
|
||||
func (m *{{ $mutation }}) Filter() *{{ $filter }} {
|
||||
return &{{ $filter }}{m}
|
||||
return &{{ $filter }}{m.config, m}
|
||||
}
|
||||
|
||||
// {{ $filter }} provides a generic filtering capability at runtime for {{ $builder }}.
|
||||
type {{ $filter }} struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
|
||||
@@ -473,7 +473,7 @@ func (aq *AccountQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the AccountQuery builder.
|
||||
func (aq *AccountQuery) Filter() *AccountFilter {
|
||||
return &AccountFilter{aq}
|
||||
return &AccountFilter{aq.config, aq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -483,11 +483,12 @@ func (m *AccountMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the AccountMutation builder.
|
||||
func (m *AccountMutation) Filter() *AccountFilter {
|
||||
return &AccountFilter{m}
|
||||
return &AccountFilter{m.config, m}
|
||||
}
|
||||
|
||||
// AccountFilter provides a generic filtering capability at runtime for AccountQuery.
|
||||
type AccountFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -531,7 +532,7 @@ func (bq *BlobQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the BlobQuery builder.
|
||||
func (bq *BlobQuery) Filter() *BlobFilter {
|
||||
return &BlobFilter{bq}
|
||||
return &BlobFilter{bq.config, bq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -541,11 +542,12 @@ func (m *BlobMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the BlobMutation builder.
|
||||
func (m *BlobMutation) Filter() *BlobFilter {
|
||||
return &BlobFilter{m}
|
||||
return &BlobFilter{m.config, m}
|
||||
}
|
||||
|
||||
// BlobFilter provides a generic filtering capability at runtime for BlobQuery.
|
||||
type BlobFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -608,7 +610,7 @@ func (cq *CarQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the CarQuery builder.
|
||||
func (cq *CarQuery) Filter() *CarFilter {
|
||||
return &CarFilter{cq}
|
||||
return &CarFilter{cq.config, cq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -618,11 +620,12 @@ func (m *CarMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the CarMutation builder.
|
||||
func (m *CarMutation) Filter() *CarFilter {
|
||||
return &CarFilter{m}
|
||||
return &CarFilter{m.config, m}
|
||||
}
|
||||
|
||||
// CarFilter provides a generic filtering capability at runtime for CarQuery.
|
||||
type CarFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -676,7 +679,7 @@ func (dq *DeviceQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the DeviceQuery builder.
|
||||
func (dq *DeviceQuery) Filter() *DeviceFilter {
|
||||
return &DeviceFilter{dq}
|
||||
return &DeviceFilter{dq.config, dq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -686,11 +689,12 @@ func (m *DeviceMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the DeviceMutation builder.
|
||||
func (m *DeviceMutation) Filter() *DeviceFilter {
|
||||
return &DeviceFilter{m}
|
||||
return &DeviceFilter{m.config, m}
|
||||
}
|
||||
|
||||
// DeviceFilter provides a generic filtering capability at runtime for DeviceQuery.
|
||||
type DeviceFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -743,7 +747,7 @@ func (dq *DocQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the DocQuery builder.
|
||||
func (dq *DocQuery) Filter() *DocFilter {
|
||||
return &DocFilter{dq}
|
||||
return &DocFilter{dq.config, dq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -753,11 +757,12 @@ func (m *DocMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the DocMutation builder.
|
||||
func (m *DocMutation) Filter() *DocFilter {
|
||||
return &DocFilter{m}
|
||||
return &DocFilter{m.config, m}
|
||||
}
|
||||
|
||||
// DocFilter provides a generic filtering capability at runtime for DocQuery.
|
||||
type DocFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -815,7 +820,7 @@ func (gq *GroupQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the GroupQuery builder.
|
||||
func (gq *GroupQuery) Filter() *GroupFilter {
|
||||
return &GroupFilter{gq}
|
||||
return &GroupFilter{gq.config, gq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -825,11 +830,12 @@ func (m *GroupMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the GroupMutation builder.
|
||||
func (m *GroupMutation) Filter() *GroupFilter {
|
||||
return &GroupFilter{m}
|
||||
return &GroupFilter{m.config, m}
|
||||
}
|
||||
|
||||
// GroupFilter provides a generic filtering capability at runtime for GroupQuery.
|
||||
type GroupFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -868,7 +874,7 @@ func (miq *MixinIDQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the MixinIDQuery builder.
|
||||
func (miq *MixinIDQuery) Filter() *MixinIDFilter {
|
||||
return &MixinIDFilter{miq}
|
||||
return &MixinIDFilter{miq.config, miq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -878,11 +884,12 @@ func (m *MixinIDMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the MixinIDMutation builder.
|
||||
func (m *MixinIDMutation) Filter() *MixinIDFilter {
|
||||
return &MixinIDFilter{m}
|
||||
return &MixinIDFilter{m.config, m}
|
||||
}
|
||||
|
||||
// MixinIDFilter provides a generic filtering capability at runtime for MixinIDQuery.
|
||||
type MixinIDFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -917,7 +924,7 @@ func (nq *NoteQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the NoteQuery builder.
|
||||
func (nq *NoteQuery) Filter() *NoteFilter {
|
||||
return &NoteFilter{nq}
|
||||
return &NoteFilter{nq.config, nq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -927,11 +934,12 @@ func (m *NoteMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the NoteMutation builder.
|
||||
func (m *NoteMutation) Filter() *NoteFilter {
|
||||
return &NoteFilter{m}
|
||||
return &NoteFilter{m.config, m}
|
||||
}
|
||||
|
||||
// NoteFilter provides a generic filtering capability at runtime for NoteQuery.
|
||||
type NoteFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -989,7 +997,7 @@ func (oq *OtherQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the OtherQuery builder.
|
||||
func (oq *OtherQuery) Filter() *OtherFilter {
|
||||
return &OtherFilter{oq}
|
||||
return &OtherFilter{oq.config, oq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -999,11 +1007,12 @@ func (m *OtherMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the OtherMutation builder.
|
||||
func (m *OtherMutation) Filter() *OtherFilter {
|
||||
return &OtherFilter{m}
|
||||
return &OtherFilter{m.config, m}
|
||||
}
|
||||
|
||||
// OtherFilter provides a generic filtering capability at runtime for OtherQuery.
|
||||
type OtherFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1028,7 +1037,7 @@ func (pq *PetQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the PetQuery builder.
|
||||
func (pq *PetQuery) Filter() *PetFilter {
|
||||
return &PetFilter{pq}
|
||||
return &PetFilter{pq.config, pq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1038,11 +1047,12 @@ func (m *PetMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the PetMutation builder.
|
||||
func (m *PetMutation) Filter() *PetFilter {
|
||||
return &PetFilter{m}
|
||||
return &PetFilter{m.config, m}
|
||||
}
|
||||
|
||||
// PetFilter provides a generic filtering capability at runtime for PetQuery.
|
||||
type PetFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1123,7 +1133,7 @@ func (sq *SessionQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the SessionQuery builder.
|
||||
func (sq *SessionQuery) Filter() *SessionFilter {
|
||||
return &SessionFilter{sq}
|
||||
return &SessionFilter{sq.config, sq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1133,11 +1143,12 @@ func (m *SessionMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the SessionMutation builder.
|
||||
func (m *SessionMutation) Filter() *SessionFilter {
|
||||
return &SessionFilter{m}
|
||||
return &SessionFilter{m.config, m}
|
||||
}
|
||||
|
||||
// SessionFilter provides a generic filtering capability at runtime for SessionQuery.
|
||||
type SessionFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1176,7 +1187,7 @@ func (tq *TokenQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the TokenQuery builder.
|
||||
func (tq *TokenQuery) Filter() *TokenFilter {
|
||||
return &TokenFilter{tq}
|
||||
return &TokenFilter{tq.config, tq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1186,11 +1197,12 @@ func (m *TokenMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the TokenMutation builder.
|
||||
func (m *TokenMutation) Filter() *TokenFilter {
|
||||
return &TokenFilter{m}
|
||||
return &TokenFilter{m.config, m}
|
||||
}
|
||||
|
||||
// TokenFilter provides a generic filtering capability at runtime for TokenQuery.
|
||||
type TokenFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1234,7 +1246,7 @@ func (uq *UserQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the UserQuery builder.
|
||||
func (uq *UserQuery) Filter() *UserFilter {
|
||||
return &UserFilter{uq}
|
||||
return &UserFilter{uq.config, uq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1244,11 +1256,12 @@ func (m *UserMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the UserMutation builder.
|
||||
func (m *UserMutation) Filter() *UserFilter {
|
||||
return &UserFilter{m}
|
||||
return &UserFilter{m.config, m}
|
||||
}
|
||||
|
||||
// UserFilter provides a generic filtering capability at runtime for UserQuery.
|
||||
type UserFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
|
||||
@@ -658,7 +658,7 @@ func (cq *CardQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the CardQuery builder.
|
||||
func (cq *CardQuery) Filter() *CardFilter {
|
||||
return &CardFilter{cq}
|
||||
return &CardFilter{cq.config, cq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -668,11 +668,12 @@ func (m *CardMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the CardMutation builder.
|
||||
func (m *CardMutation) Filter() *CardFilter {
|
||||
return &CardFilter{m}
|
||||
return &CardFilter{m.config, m}
|
||||
}
|
||||
|
||||
// CardFilter provides a generic filtering capability at runtime for CardQuery.
|
||||
type CardFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -750,7 +751,7 @@ func (cq *CommentQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the CommentQuery builder.
|
||||
func (cq *CommentQuery) Filter() *CommentFilter {
|
||||
return &CommentFilter{cq}
|
||||
return &CommentFilter{cq.config, cq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -760,11 +761,12 @@ func (m *CommentMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the CommentMutation builder.
|
||||
func (m *CommentMutation) Filter() *CommentFilter {
|
||||
return &CommentFilter{m}
|
||||
return &CommentFilter{m.config, m}
|
||||
}
|
||||
|
||||
// CommentFilter provides a generic filtering capability at runtime for CommentQuery.
|
||||
type CommentFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -804,7 +806,7 @@ func (ftq *FieldTypeQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the FieldTypeQuery builder.
|
||||
func (ftq *FieldTypeQuery) Filter() *FieldTypeFilter {
|
||||
return &FieldTypeFilter{ftq}
|
||||
return &FieldTypeFilter{ftq.config, ftq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -814,11 +816,12 @@ func (m *FieldTypeMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the FieldTypeMutation builder.
|
||||
func (m *FieldTypeMutation) Filter() *FieldTypeFilter {
|
||||
return &FieldTypeFilter{m}
|
||||
return &FieldTypeFilter{m.config, m}
|
||||
}
|
||||
|
||||
// FieldTypeFilter provides a generic filtering capability at runtime for FieldTypeQuery.
|
||||
type FieldTypeFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1168,7 +1171,7 @@ func (fq *FileQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the FileQuery builder.
|
||||
func (fq *FileQuery) Filter() *FileFilter {
|
||||
return &FileFilter{fq}
|
||||
return &FileFilter{fq.config, fq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1178,11 +1181,12 @@ func (m *FileMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the FileMutation builder.
|
||||
func (m *FileMutation) Filter() *FileFilter {
|
||||
return &FileFilter{m}
|
||||
return &FileFilter{m.config, m}
|
||||
}
|
||||
|
||||
// FileFilter provides a generic filtering capability at runtime for FileQuery.
|
||||
type FileFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1274,7 +1278,7 @@ func (ftq *FileTypeQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the FileTypeQuery builder.
|
||||
func (ftq *FileTypeQuery) Filter() *FileTypeFilter {
|
||||
return &FileTypeFilter{ftq}
|
||||
return &FileTypeFilter{ftq.config, ftq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1284,11 +1288,12 @@ func (m *FileTypeMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the FileTypeMutation builder.
|
||||
func (m *FileTypeMutation) Filter() *FileTypeFilter {
|
||||
return &FileTypeFilter{m}
|
||||
return &FileTypeFilter{m.config, m}
|
||||
}
|
||||
|
||||
// FileTypeFilter provides a generic filtering capability at runtime for FileTypeQuery.
|
||||
type FileTypeFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1342,7 +1347,7 @@ func (gq *GoodsQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the GoodsQuery builder.
|
||||
func (gq *GoodsQuery) Filter() *GoodsFilter {
|
||||
return &GoodsFilter{gq}
|
||||
return &GoodsFilter{gq.config, gq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1352,11 +1357,12 @@ func (m *GoodsMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the GoodsMutation builder.
|
||||
func (m *GoodsMutation) Filter() *GoodsFilter {
|
||||
return &GoodsFilter{m}
|
||||
return &GoodsFilter{m.config, m}
|
||||
}
|
||||
|
||||
// GoodsFilter provides a generic filtering capability at runtime for GoodsQuery.
|
||||
type GoodsFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1381,7 +1387,7 @@ func (gq *GroupQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the GroupQuery builder.
|
||||
func (gq *GroupQuery) Filter() *GroupFilter {
|
||||
return &GroupFilter{gq}
|
||||
return &GroupFilter{gq.config, gq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1391,11 +1397,12 @@ func (m *GroupMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the GroupMutation builder.
|
||||
func (m *GroupMutation) Filter() *GroupFilter {
|
||||
return &GroupFilter{m}
|
||||
return &GroupFilter{m.config, m}
|
||||
}
|
||||
|
||||
// GroupFilter provides a generic filtering capability at runtime for GroupQuery.
|
||||
type GroupFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1501,7 +1508,7 @@ func (giq *GroupInfoQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the GroupInfoQuery builder.
|
||||
func (giq *GroupInfoQuery) Filter() *GroupInfoFilter {
|
||||
return &GroupInfoFilter{giq}
|
||||
return &GroupInfoFilter{giq.config, giq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1511,11 +1518,12 @@ func (m *GroupInfoMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the GroupInfoMutation builder.
|
||||
func (m *GroupInfoMutation) Filter() *GroupInfoFilter {
|
||||
return &GroupInfoFilter{m}
|
||||
return &GroupInfoFilter{m.config, m}
|
||||
}
|
||||
|
||||
// GroupInfoFilter provides a generic filtering capability at runtime for GroupInfoQuery.
|
||||
type GroupInfoFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1564,7 +1572,7 @@ func (iq *ItemQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the ItemQuery builder.
|
||||
func (iq *ItemQuery) Filter() *ItemFilter {
|
||||
return &ItemFilter{iq}
|
||||
return &ItemFilter{iq.config, iq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1574,11 +1582,12 @@ func (m *ItemMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the ItemMutation builder.
|
||||
func (m *ItemMutation) Filter() *ItemFilter {
|
||||
return &ItemFilter{m}
|
||||
return &ItemFilter{m.config, m}
|
||||
}
|
||||
|
||||
// ItemFilter provides a generic filtering capability at runtime for ItemQuery.
|
||||
type ItemFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1608,7 +1617,7 @@ func (nq *NodeQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the NodeQuery builder.
|
||||
func (nq *NodeQuery) Filter() *NodeFilter {
|
||||
return &NodeFilter{nq}
|
||||
return &NodeFilter{nq.config, nq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1618,11 +1627,12 @@ func (m *NodeMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the NodeMutation builder.
|
||||
func (m *NodeMutation) Filter() *NodeFilter {
|
||||
return &NodeFilter{m}
|
||||
return &NodeFilter{m.config, m}
|
||||
}
|
||||
|
||||
// NodeFilter provides a generic filtering capability at runtime for NodeQuery.
|
||||
type NodeFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1680,7 +1690,7 @@ func (pq *PetQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the PetQuery builder.
|
||||
func (pq *PetQuery) Filter() *PetFilter {
|
||||
return &PetFilter{pq}
|
||||
return &PetFilter{pq.config, pq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1690,11 +1700,12 @@ func (m *PetMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the PetMutation builder.
|
||||
func (m *PetMutation) Filter() *PetFilter {
|
||||
return &PetFilter{m}
|
||||
return &PetFilter{m.config, m}
|
||||
}
|
||||
|
||||
// PetFilter provides a generic filtering capability at runtime for PetQuery.
|
||||
type PetFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1767,7 +1778,7 @@ func (sq *SpecQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the SpecQuery builder.
|
||||
func (sq *SpecQuery) Filter() *SpecFilter {
|
||||
return &SpecFilter{sq}
|
||||
return &SpecFilter{sq.config, sq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1777,11 +1788,12 @@ func (m *SpecMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the SpecMutation builder.
|
||||
func (m *SpecMutation) Filter() *SpecFilter {
|
||||
return &SpecFilter{m}
|
||||
return &SpecFilter{m.config, m}
|
||||
}
|
||||
|
||||
// SpecFilter provides a generic filtering capability at runtime for SpecQuery.
|
||||
type SpecFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1820,7 +1832,7 @@ func (tq *TaskQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the TaskQuery builder.
|
||||
func (tq *TaskQuery) Filter() *TaskFilter {
|
||||
return &TaskFilter{tq}
|
||||
return &TaskFilter{tq.config, tq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1830,11 +1842,12 @@ func (m *TaskMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the TaskMutation builder.
|
||||
func (m *TaskMutation) Filter() *TaskFilter {
|
||||
return &TaskFilter{m}
|
||||
return &TaskFilter{m.config, m}
|
||||
}
|
||||
|
||||
// TaskFilter provides a generic filtering capability at runtime for TaskQuery.
|
||||
type TaskFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -1864,7 +1877,7 @@ func (uq *UserQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the UserQuery builder.
|
||||
func (uq *UserQuery) Filter() *UserFilter {
|
||||
return &UserFilter{uq}
|
||||
return &UserFilter{uq.config, uq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -1874,11 +1887,12 @@ func (m *UserMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the UserMutation builder.
|
||||
func (m *UserMutation) Filter() *UserFilter {
|
||||
return &UserFilter{m}
|
||||
return &UserFilter{m.config, m}
|
||||
}
|
||||
|
||||
// UserFilter provides a generic filtering capability at runtime for UserQuery.
|
||||
type UserFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
package ent
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect"
|
||||
)
|
||||
@@ -23,7 +25,8 @@ type config struct {
|
||||
// log used for logging on debug mode.
|
||||
log func(...interface{})
|
||||
// hooks to execute on mutations.
|
||||
hooks *hooks
|
||||
hooks *hooks
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// hooks per client, for fast access.
|
||||
@@ -63,3 +66,10 @@ func Driver(driver dialect.Driver) Option {
|
||||
c.driver = driver
|
||||
}
|
||||
}
|
||||
|
||||
// HTTPClient configures the HTTPClient.
|
||||
func HTTPClient(v *http.Client) Option {
|
||||
return func(c *config) {
|
||||
c.HTTPClient = v
|
||||
}
|
||||
}
|
||||
|
||||
43
entc/integration/privacy/ent/entc.go
Normal file
43
entc/integration/privacy/ent/entc.go
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2019-present Facebook Inc. All rights reserved.
|
||||
// This source code is licensed under the Apache 2.0 license found
|
||||
// in the LICENSE file in the root directory of this source tree.
|
||||
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"entgo.io/ent/entc"
|
||||
"entgo.io/ent/entc/gen"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// A usage for custom options to configure the code generator to use
|
||||
// an extension and inject external dependencies in the generated API.
|
||||
opts := []entc.Option{
|
||||
entc.Dependency(
|
||||
entc.DependencyType(&http.Client{}),
|
||||
),
|
||||
entc.FeatureNames(
|
||||
"privacy",
|
||||
"entql",
|
||||
"schema/snapshot",
|
||||
),
|
||||
}
|
||||
err := entc.Generate("./schema", &gen.Config{
|
||||
Header: `
|
||||
// Copyright 2019-present Facebook Inc. All rights reserved.
|
||||
// This source code is licensed under the Apache 2.0 license found
|
||||
// in the LICENSE file in the root directory of this source tree.
|
||||
|
||||
// Code generated by entc, DO NOT EDIT.
|
||||
`,
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
log.Fatalf("running ent codegen: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (tq *TaskQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the TaskQuery builder.
|
||||
func (tq *TaskQuery) Filter() *TaskFilter {
|
||||
return &TaskFilter{tq}
|
||||
return &TaskFilter{tq.config, tq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -165,11 +165,12 @@ func (m *TaskMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the TaskMutation builder.
|
||||
func (m *TaskMutation) Filter() *TaskFilter {
|
||||
return &TaskFilter{m}
|
||||
return &TaskFilter{m.config, m}
|
||||
}
|
||||
|
||||
// TaskFilter provides a generic filtering capability at runtime for TaskQuery.
|
||||
type TaskFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -242,7 +243,7 @@ func (tq *TeamQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the TeamQuery builder.
|
||||
func (tq *TeamQuery) Filter() *TeamFilter {
|
||||
return &TeamFilter{tq}
|
||||
return &TeamFilter{tq.config, tq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -252,11 +253,12 @@ func (m *TeamMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the TeamMutation builder.
|
||||
func (m *TeamMutation) Filter() *TeamFilter {
|
||||
return &TeamFilter{m}
|
||||
return &TeamFilter{m.config, m}
|
||||
}
|
||||
|
||||
// TeamFilter provides a generic filtering capability at runtime for TeamQuery.
|
||||
type TeamFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
@@ -314,7 +316,7 @@ func (uq *UserQuery) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns a Filter implementation to apply filters on the UserQuery builder.
|
||||
func (uq *UserQuery) Filter() *UserFilter {
|
||||
return &UserFilter{uq}
|
||||
return &UserFilter{uq.config, uq}
|
||||
}
|
||||
|
||||
// addPredicate implements the predicateAdder interface.
|
||||
@@ -324,11 +326,12 @@ func (m *UserMutation) addPredicate(pred func(s *sql.Selector)) {
|
||||
|
||||
// Filter returns an entql.Where implementation to apply filters on the UserMutation builder.
|
||||
func (m *UserMutation) Filter() *UserFilter {
|
||||
return &UserFilter{m}
|
||||
return &UserFilter{m.config, m}
|
||||
}
|
||||
|
||||
// UserFilter provides a generic filtering capability at runtime for UserQuery.
|
||||
type UserFilter struct {
|
||||
config
|
||||
predicateAdder
|
||||
}
|
||||
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
|
||||
package ent
|
||||
|
||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature privacy,entql,schema/snapshot --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema
|
||||
//go:generate go run -mod=mod entc.go
|
||||
|
||||
@@ -107,6 +107,19 @@ func FilterTeamRule() privacy.QueryRule {
|
||||
})
|
||||
}
|
||||
|
||||
// FilterUsesDep is a filter query rule that uses its injected dependency using type-assertion.
|
||||
func FilterUsesDep() privacy.QueryRule {
|
||||
return privacy.FilterFunc(func(ctx context.Context, f privacy.Filter) error {
|
||||
u, ok := f.(*ent.UserFilter)
|
||||
if !ok {
|
||||
return privacy.Denyf("unexpected filter type %T", f)
|
||||
}
|
||||
// Access the dependency after the type is resolved.
|
||||
_ = u.HTTPClient
|
||||
return privacy.Skip
|
||||
})
|
||||
}
|
||||
|
||||
// DenyIfStatusChangedByOther is a mutation rule that returns a deny decision if the
|
||||
// task status was changed by someone that is not the owner of the task, or an admin.
|
||||
func DenyIfStatusChangedByOther() privacy.MutationRule {
|
||||
@@ -184,7 +197,7 @@ func SetMutationLogFunc(f func(string, ...interface{})) func(string, ...interfac
|
||||
return logf
|
||||
}
|
||||
|
||||
// LogPlanetMutationHook returns a hook logging planet mutations.
|
||||
// LogTaskMutationHook returns a hook logging planet mutations.
|
||||
func LogTaskMutationHook() ent.Hook {
|
||||
return func(next ent.Mutator) ent.Mutator {
|
||||
return hook.TaskFunc(func(ctx context.Context, m *ent.TaskMutation) (ent.Value, error) {
|
||||
|
||||
Reference in New Issue
Block a user