diff --git a/go.mod b/go.mod index 9b2fffa9..6357ebd8 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module go.dtapp.net/library go 1.18 require ( - entgo.io/ent v0.11.1 gitee.com/chunanyong/dm v1.8.5 gitee.com/chunanyong/zorm v1.5.6 github.com/aliyun/aliyun-oss-go-sdk v2.2.4+incompatible diff --git a/go.sum b/go.sum index c3230939..a366469b 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -entgo.io/ent v0.11.1 h1:im67R+2W3Nee2bNS2YnoYz8oAF0Qz4AOlIvKRIAEISY= -entgo.io/ent v0.11.1/go.mod h1:X5b1YfMayrRTgKGO//8IqpL7XJx0uqdeReEkxNpXROA= gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s= gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU= gitee.com/chunanyong/dm v1.8.5 h1:7RbtxRqZSzMxMT/6vhjdV/Gym2lV2S0PLUUW0ht4ZC4= diff --git a/utils/dorm/ent.go b/utils/dorm/ent.go deleted file mode 100644 index eb3abd24..00000000 --- a/utils/dorm/ent.go +++ /dev/null @@ -1,16 +0,0 @@ -package dorm - -import ( - "entgo.io/ent" -) - -type ConfigEntClient struct { - Dns string // 地址 -} - -// EntClient -// https://entgo.io/ -type EntClient struct { - Db *ent.Edge // 驱动 - config *ConfigEntClient // 配置 -} diff --git a/utils/dorm/ent_mysql.go b/utils/dorm/ent_mysql.go deleted file mode 100644 index 530ca9d3..00000000 --- a/utils/dorm/ent_mysql.go +++ /dev/null @@ -1,19 +0,0 @@ -package dorm - -import ( - _ "github.com/go-sql-driver/mysql" -) - -func NewEntMysqlClient(config *ConfigEntClient) (*EntClient, error) { - - //var err error - //c := &EntClient{config: config} - - //client, err := ent.Open("mysql", c.config.Dns) - //if err != nil { - // return nil, errors.New(fmt.Sprintf("连接失败:%v", err)) - //} - //defer client.Close() - - return nil, nil -} diff --git a/vendor/entgo.io/ent/.all-contributorsrc b/vendor/entgo.io/ent/.all-contributorsrc deleted file mode 100644 index 434b1eba..00000000 --- a/vendor/entgo.io/ent/.all-contributorsrc +++ /dev/null @@ -1,828 +0,0 @@ -{ - "files": [ - "doc/md/contributors.md" - ], - "imageSize": 100, - "commit": false, - "contributors": [ - { - "login": "a8m", - "name": "Ariel Mashraki", - "avatar_url": "https://avatars.githubusercontent.com/u/7413593?v=4", - "profile": "https://github.com/a8m", - "contributions": [ - "maintenance", - "doc", - "code" - ] - }, - { - "login": "alexsn", - "name": "Alex Snast", - "avatar_url": "https://avatars.githubusercontent.com/u/987019?v=4", - "profile": "https://github.com/alexsn", - "contributions": [ - "code" - ] - }, - { - "login": "rotemtam", - "name": "Rotem Tamir", - "avatar_url": "https://avatars.githubusercontent.com/u/1522681?v=4", - "profile": "https://rotemtam.com/", - "contributions": [ - "maintenance", - "doc", - "code" - ] - }, - { - "login": "cliedeman", - "name": "Ciaran Liedeman", - "avatar_url": "https://avatars.githubusercontent.com/u/3578740?v=4", - "profile": "https://github.com/cliedeman", - "contributions": [ - "code" - ] - }, - { - "login": "marwan-at-work", - "name": "Marwan Sulaiman", - "avatar_url": "https://avatars.githubusercontent.com/u/16294261?v=4", - "profile": "https://www.marwan.io/", - "contributions": [ - "code" - ] - }, - { - "login": "napei", - "name": "Nathaniel Peiffer", - "avatar_url": "https://avatars.githubusercontent.com/u/8946502?v=4", - "profile": "https://nathaniel.peiffer.com.au/", - "contributions": [ - "code" - ] - }, - { - "login": "tmc", - "name": "Travis Cline", - "avatar_url": "https://avatars.githubusercontent.com/u/3977?v=4", - "profile": "https://github.com/tmc", - "contributions": [ - "code" - ] - }, - { - "login": "hantmac", - "name": "Jeremy", - "avatar_url": "https://avatars.githubusercontent.com/u/7600925?v=4", - "profile": "https://cloudsjhan.github.io/", - "contributions": [ - "code" - ] - }, - { - "login": "aca", - "name": "aca", - "avatar_url": "https://avatars.githubusercontent.com/u/50316549?v=4", - "profile": "https://github.com/aca", - "contributions": [ - "code" - ] - }, - { - "login": "BrentChesny", - "name": "BrentChesny", - "avatar_url": "https://avatars.githubusercontent.com/u/1449435?v=4", - "profile": "https://github.com/BrentChesny", - "contributions": [ - "code", - "doc" - ] - }, - { - "login": "giautm", - "name": "Giau. Tran Minh", - "avatar_url": "https://avatars.githubusercontent.com/u/12751435?v=4", - "profile": "https://github.com/giautm", - "contributions": [ - "code", - "review" - ] - }, - { - "login": "htdvisser", - "name": "Hylke Visser", - "avatar_url": "https://avatars.githubusercontent.com/u/181308?v=4", - "profile": "https://htdvisser.dev/", - "contributions": [ - "code" - ] - }, - { - "login": "kerbelp", - "name": "Pavel Kerbel", - "avatar_url": "https://avatars.githubusercontent.com/u/3934990?v=4", - "profile": "https://github.com/kerbelp", - "contributions": [ - "code" - ] - }, - { - "login": "day-dreams", - "name": "zhangnan", - "avatar_url": "https://avatars.githubusercontent.com/u/24593904?v=4", - "profile": "https://github.com/day-dreams", - "contributions": [ - "code" - ] - }, - { - "login": "uta-mori", - "name": "mori yuta", - "avatar_url": "https://avatars.githubusercontent.com/u/59682979?v=4", - "profile": "https://github.com/uta-mori", - "contributions": [ - "code", - "translation", - "review" - ] - }, - { - "login": "chris-rock", - "name": "Christoph Hartmann", - "avatar_url": "https://avatars.githubusercontent.com/u/1178413?v=4", - "profile": "http://lollyrock.com/", - "contributions": [ - "code" - ] - }, - { - "login": "rubensayshi", - "name": "Ruben de Vries", - "avatar_url": "https://avatars.githubusercontent.com/u/649160?v=4", - "profile": "https://github.com/rubensayshi", - "contributions": [ - "code" - ] - }, - { - "login": "ernado", - "name": "Aleksandr Razumov", - "avatar_url": "https://avatars.githubusercontent.com/u/866677?v=4", - "profile": "https://keybase.io/ernado", - "contributions": [ - "code" - ] - }, - { - "login": "apbuteau", - "name": "apbuteau", - "avatar_url": "https://avatars.githubusercontent.com/u/6796073?v=4", - "profile": "https://github.com/apbuteau", - "contributions": [ - "code" - ] - }, - { - "login": "ichord", - "name": "Harold.Luo", - "avatar_url": "https://avatars.githubusercontent.com/u/1324791?v=4", - "profile": "https://github.com/ichord", - "contributions": [ - "code" - ] - }, - { - "login": "idoshveki", - "name": "ido shveki", - "avatar_url": "https://avatars.githubusercontent.com/u/11615669?v=4", - "profile": "https://github.com/idoshveki", - "contributions": [ - "code" - ] - }, - { - "login": "masseelch", - "name": "MasseElch", - "avatar_url": "https://avatars.githubusercontent.com/u/12862103?v=4", - "profile": "https://github.com/masseelch", - "contributions": [ - "code" - ] - }, - { - "login": "kidlj", - "name": "Jian Li", - "avatar_url": "https://avatars.githubusercontent.com/u/300616?v=4", - "profile": "https://github.com/kidlj", - "contributions": [ - "code" - ] - }, - { - "login": "nolotz", - "name": "Noah-Jerome Lotzer", - "avatar_url": "https://avatars.githubusercontent.com/u/5778728?v=4", - "profile": "https://noah.je/", - "contributions": [ - "code" - ] - }, - { - "login": "danf0rth", - "name": "danforth", - "avatar_url": "https://avatars.githubusercontent.com/u/14220891?v=4", - "profile": "https://github.com/danf0rth", - "contributions": [ - "code" - ] - }, - { - "login": "maxiloEmmmm", - "name": "maxilozoz", - "avatar_url": "https://avatars.githubusercontent.com/u/16779121?v=4", - "profile": "https://github.com/maxiloEmmmm", - "contributions": [ - "code" - ] - }, - { - "login": "zzwx", - "name": "zzwx", - "avatar_url": "https://avatars.githubusercontent.com/u/8169082?v=4", - "profile": "https://gist.github.com/zzwx", - "contributions": [ - "code" - ] - }, - { - "login": "ix64", - "name": "MengYX", - "avatar_url": "https://avatars.githubusercontent.com/u/13902388?v=4", - "profile": "https://github.com/ix64", - "contributions": [ - "translation" - ] - }, - { - "login": "mattn", - "name": "mattn", - "avatar_url": "https://avatars.githubusercontent.com/u/10111?v=4", - "profile": "https://mattn.kaoriya.net/", - "contributions": [ - "translation" - ] - }, - { - "login": "Bladrak", - "name": "Hugo Briand", - "avatar_url": "https://avatars.githubusercontent.com/u/1321977?v=4", - "profile": "https://github.com/Bladrak", - "contributions": [ - "code" - ] - }, - { - "login": "enmand", - "name": "Dan Enman", - "avatar_url": "https://avatars.githubusercontent.com/u/432487?v=4", - "profile": "https://danielenman.com/", - "contributions": [ - "code" - ] - }, - { - "login": "UnAfraid", - "name": "Rumen Nikiforov", - "avatar_url": "https://avatars.githubusercontent.com/u/2185291?v=4", - "profile": "http://www.l2junity.org/", - "contributions": [ - "code" - ] - }, - { - "login": "wenerme", - "name": "陈杨文", - "avatar_url": "https://avatars.githubusercontent.com/u/1777211?v=4", - "profile": "https://wener.me", - "contributions": [ - "code" - ] - }, - { - "login": "joesonw", - "name": "Qiaosen (Joeson) Huang", - "avatar_url": "https://avatars.githubusercontent.com/u/1635441?v=4", - "profile": "https://djwong.net", - "contributions": [ - "bug" - ] - }, - { - "login": "davebehr1", - "name": "AlonDavidBehr", - "avatar_url": "https://avatars.githubusercontent.com/u/16716239?v=4", - "profile": "https://github.com/davebehr1", - "contributions": [ - "code", - "review" - ] - }, - { - "login": "DuGlaser", - "name": "DuGlaser", - "avatar_url": "https://avatars.githubusercontent.com/u/50506482?v=4", - "profile": "http://duglaser.dev", - "contributions": [ - "doc" - ] - }, - { - "login": "shanna", - "name": "Shane Hanna", - "avatar_url": "https://avatars.githubusercontent.com/u/28489?v=4", - "profile": "https://github.com/shanna", - "contributions": [ - "doc" - ] - }, - { - "login": "mahmud2011", - "name": "Mahmudul Haque", - "avatar_url": "https://avatars.githubusercontent.com/u/5278142?v=4", - "profile": "https://www.linkedin.com/in/mahmud2011", - "contributions": [ - "code" - ] - }, - { - "login": "sywesk", - "name": "Benjamin Bourgeais", - "avatar_url": "https://avatars.githubusercontent.com/u/862607?v=4", - "profile": "http://blog.scaleprocess.net", - "contributions": [ - "code" - ] - }, - { - "login": "8ayac", - "name": "8ayac(Yoshinori Hayashi)", - "avatar_url": "https://avatars.githubusercontent.com/u/29266382?v=4", - "profile": "https://about.8ay.ac/", - "contributions": [ - "doc" - ] - }, - { - "login": "y-yagi", - "name": "y-yagi", - "avatar_url": "https://avatars.githubusercontent.com/u/987638?v=4", - "profile": "https://github.com/y-yagi", - "contributions": [ - "doc" - ] - }, - { - "login": "Sacro", - "name": "Ben Woodward", - "avatar_url": "https://avatars.githubusercontent.com/u/2659869?v=4", - "profile": "https://github.com/Sacro", - "contributions": [ - "code" - ] - }, - { - "login": "wzyjerry", - "name": "WzyJerry", - "avatar_url": "https://avatars.githubusercontent.com/u/11435169?v=4", - "profile": "https://github.com/wzyjerry", - "contributions": [ - "code" - ] - }, - { - "login": "tarrencev", - "name": "Tarrence van As", - "avatar_url": "https://avatars.githubusercontent.com/u/4740651?v=4", - "profile": "https://github.com/tarrencev", - "contributions": [ - "doc", - "code" - ] - }, - { - "login": "MONAKA0721", - "name": "Yuya Sumie", - "avatar_url": "https://avatars.githubusercontent.com/u/32859963?v=4", - "profile": "https://mo7ka.com", - "contributions": [ - "doc" - ] - }, - { - "login": "akfaew", - "name": "Michal Mazurek", - "avatar_url": "https://avatars.githubusercontent.com/u/7853732?v=4", - "profile": "http://jasminek.net", - "contributions": [ - "code" - ] - }, - { - "login": "nmemoto", - "name": "Takafumi Umemoto", - "avatar_url": "https://avatars.githubusercontent.com/u/1522332?v=4", - "profile": "https://github.com/nmemoto", - "contributions": [ - "doc" - ] - }, - { - "login": "squarebat", - "name": "Khadija Sidhpuri", - "avatar_url": "https://avatars.githubusercontent.com/u/59063821?v=4", - "profile": "http://www.linkedin.com/in/khadija-sidhpuri-87709316a", - "contributions": [ - "code" - ] - }, - { - "login": "neel229", - "name": "Neel Modi", - "avatar_url": "https://avatars.githubusercontent.com/u/53475167?v=4", - "profile": "https://github.com/neel229", - "contributions": [ - "code" - ] - }, - { - "login": "shomodj", - "name": "Boris Shomodjvarac", - "avatar_url": "https://avatars.githubusercontent.com/u/304768?v=4", - "profile": "https://ie.linkedin.com/in/boris-shomodjvarac-51970879", - "contributions": [ - "doc" - ] - }, - { - "login": "sadmansakib", - "name": "Sadman Sakib", - "avatar_url": "https://avatars.githubusercontent.com/u/17023844?v=4", - "profile": "https://github.com/sadmansakib", - "contributions": [ - "doc" - ] - }, - { - "login": "dakimura", - "name": "dakimura", - "avatar_url": "https://avatars.githubusercontent.com/u/34202807?v=4", - "profile": "https://github.com/dakimura", - "contributions": [ - "code" - ] - }, - { - "login": "RiskyFeryansyahP", - "name": "Risky Feryansyah", - "avatar_url": "https://avatars.githubusercontent.com/u/36788585?v=4", - "profile": "https://github.com/RiskyFeryansyahP", - "contributions": [ - "code" - ] - }, - { - "login": "seiichi1101", - "name": "seiichi ", - "avatar_url": "https://avatars.githubusercontent.com/u/20941952?v=4", - "profile": "https://github.com/seiichi1101", - "contributions": [ - "code" - ] - }, - { - "login": "odeke-em", - "name": "Emmanuel T Odeke", - "avatar_url": "https://avatars.githubusercontent.com/u/4898263?v=4", - "profile": "https://orijtech.com/", - "contributions": [ - "code" - ] - }, - { - "login": "isoppp", - "name": "Hiroki Isogai", - "avatar_url": "https://avatars.githubusercontent.com/u/16318727?v=4", - "profile": "https://isoppp.com", - "contributions": [ - "doc" - ] - }, - { - "login": "tsingsun", - "name": "李清山", - "avatar_url": "https://avatars.githubusercontent.com/u/5848549?v=4", - "profile": "https://github.com/tsingsun", - "contributions": [ - "code" - ] - }, - { - "login": "s-takehana", - "name": "s-takehana", - "avatar_url": "https://avatars.githubusercontent.com/u/3423547?v=4", - "profile": "https://github.com/s-takehana", - "contributions": [ - "doc" - ] - }, - { - "login": "EndlessIdea", - "name": "Kuiba", - "avatar_url": "https://avatars.githubusercontent.com/u/1527796?v=4", - "profile": "https://github.com/EndlessIdea", - "contributions": [ - "code" - ] - }, - { - "login": "storyicon", - "name": "storyicon", - "avatar_url": "https://avatars.githubusercontent.com/u/29772821?v=4", - "profile": "https://github.com/storyicon", - "contributions": [ - "code" - ] - }, - { - "login": "evanlurvey", - "name": "Evan Lurvey", - "avatar_url": "https://avatars.githubusercontent.com/u/54965655?v=4", - "profile": "https://github.com/evanlurvey", - "contributions": [ - "code" - ] - }, - { - "login": "attackordie", - "name": "Brian", - "avatar_url": "https://avatars.githubusercontent.com/u/20145334?v=4", - "profile": "https://github.com/attackordie", - "contributions": [ - "doc" - ] - }, - { - "login": "ThinkontrolSY", - "name": "Shen Yang", - "avatar_url": "https://avatars.githubusercontent.com/u/11331554?v=4", - "profile": "http://www.thinkontrol.com", - "contributions": [ - "code" - ] - }, - { - "login": "sivchari", - "name": "sivchari", - "avatar_url": "https://avatars.githubusercontent.com/u/55221074?v=4", - "profile": "https://twitter.com/sivchari", - "contributions": [ - "code" - ] - }, - { - "login": "mookjp", - "name": "mook", - "avatar_url": "https://avatars.githubusercontent.com/u/1519309?v=4", - "profile": "https://blog.mookjp.io", - "contributions": [ - "code" - ] - }, - { - "login": "heliumbrain", - "name": "heliumbrain", - "avatar_url": "https://avatars.githubusercontent.com/u/1607668?v=4", - "profile": "http://www.entiros.se", - "contributions": [ - "doc" - ] - }, - { - "login": "JeremyV2014", - "name": "Jeremy Maxey-Vesperman", - "avatar_url": "https://avatars.githubusercontent.com/u/9276415?v=4", - "profile": "https://github.com/JeremyV2014", - "contributions": [ - "code", - "doc" - ] - }, - { - "login": "tankbusta", - "name": "Christopher Schmitt", - "avatar_url": "https://avatars.githubusercontent.com/u/592749?v=4", - "profile": "https://github.com/tankbusta", - "contributions": [ - "doc" - ] - }, - { - "login": "grevych", - "name": "Gerardo Reyes", - "avatar_url": "https://avatars.githubusercontent.com/u/3792003?v=4", - "profile": "https://github.com/grevych", - "contributions": [ - "code" - ] - }, - { - "login": "naormatania", - "name": "Naor Matania", - "avatar_url": "https://avatars.githubusercontent.com/u/6978437?v=4", - "profile": "https://github.com/naormatania", - "contributions": [ - "code" - ] - }, - { - "login": "idc77", - "name": "idc77", - "avatar_url": "https://avatars.githubusercontent.com/u/87644834?v=4", - "profile": "https://github.com/idc77", - "contributions": [ - "doc" - ] - }, - { - "login": "HurSungYun", - "name": "Sungyun Hur", - "avatar_url": "https://avatars.githubusercontent.com/u/8033896?v=4", - "profile": "http://ethanhur.me", - "contributions": [ - "doc" - ] - }, - { - "login": "peanut-cc", - "name": "peanut-pg", - "avatar_url": "https://avatars.githubusercontent.com/u/55480838?v=4", - "profile": "https://github.com/peanut-cc", - "contributions": [ - "doc" - ] - }, - { - "login": "m3hm3t", - "name": "Mehmet Yılmaz", - "avatar_url": "https://avatars.githubusercontent.com/u/22320354?v=4", - "profile": "https://github.com/m3hm3t", - "contributions": [ - "code" - ] - }, - { - "login": "Laconty", - "name": "Roman Maklakov", - "avatar_url": "https://avatars.githubusercontent.com/u/17760166?v=4", - "profile": "https://github.com/Laconty", - "contributions": [ - "code" - ] - }, - { - "login": "genevieve", - "name": "Genevieve", - "avatar_url": "https://avatars.githubusercontent.com/u/12158641?v=4", - "profile": "https://github.com/genevieve", - "contributions": [ - "code" - ] - }, - { - "login": "cjraa", - "name": "Clarence", - "avatar_url": "https://avatars.githubusercontent.com/u/62199269?v=4", - "profile": "https://github.com/cjraa", - "contributions": [ - "code" - ] - }, - { - "login": "iamnande", - "name": "Nicholas Anderson", - "avatar_url": "https://avatars.githubusercontent.com/u/7806510?v=4", - "profile": "https://www.linkedin.com/in/iamnande/", - "contributions": [ - "code" - ] - }, - { - "login": "hezhizhen", - "name": "Zhizhen He", - "avatar_url": "https://avatars.githubusercontent.com/u/7611700?v=4", - "profile": "https://github.com/hezhizhen", - "contributions": [ - "code" - ] - }, - { - "login": "crossworth", - "name": "Pedro Henrique", - "avatar_url": "https://avatars.githubusercontent.com/u/1251151?v=4", - "profile": "https://pedro.dev.br", - "contributions": [ - "code" - ] - }, - { - "login": "MrParano1d", - "name": "MrParano1d", - "avatar_url": "https://avatars.githubusercontent.com/u/7414374?v=4", - "profile": "https://2jp.de", - "contributions": [ - "code" - ] - }, - { - "login": "tprebs", - "name": "Thomas Prebble", - "avatar_url": "https://avatars.githubusercontent.com/u/6523587?v=4", - "profile": "https://github.com/tprebs", - "contributions": [ - "code" - ] - }, - { - "login": "imhuytq", - "name": "Huy TQ", - "avatar_url": "https://avatars.githubusercontent.com/u/5723282?v=4", - "profile": "https://huytq.com", - "contributions": [ - "code" - ] - }, - { - "login": "maorlipchuk", - "name": "maorlipchuk", - "avatar_url": "https://avatars.githubusercontent.com/u/7034637?v=4", - "profile": "https://github.com/maorlipchuk", - "contributions": [ - "code" - ] - }, - { - "login": "iwata", - "name": "Motonori Iwata", - "avatar_url": "https://avatars.githubusercontent.com/u/121048?v=4", - "profile": "https://mobcov.hatenadiary.org/", - "contributions": [ - "doc" - ] - }, - { - "login": "CharlesGe129", - "name": "Charles Ge", - "avatar_url": "https://avatars.githubusercontent.com/u/20162173?v=4", - "profile": "https://github.com/CharlesGe129", - "contributions": [ - "code" - ] - }, - { - "login": "thmeitz", - "name": "Thomas Meitz", - "avatar_url": "https://avatars.githubusercontent.com/u/92851940?v=4", - "profile": "https://github.com/thmeitz", - "contributions": [ - "code", - "doc" - ] - }, - { - "login": "booleangate", - "name": "Justin Johnson", - "avatar_url": "https://avatars.githubusercontent.com/u/181567?v=4", - "profile": "http://justinjohnson.org", - "contributions": [ - "code" - ] - }, - { - "login": "hax10", - "name": "hax10", - "avatar_url": "https://avatars.githubusercontent.com/u/85743468?v=4", - "profile": "https://github.com/hax10", - "contributions": [ - "code" - ] - } - ], - "contributorsPerLine": 7, - "projectName": "ent", - "projectOwner": "ent", - "repoType": "github", - "repoHost": "https://github.com", - "skipCi": true -} diff --git a/vendor/entgo.io/ent/.golangci.yml b/vendor/entgo.io/ent/.golangci.yml deleted file mode 100644 index 12c3e2f6..00000000 --- a/vendor/entgo.io/ent/.golangci.yml +++ /dev/null @@ -1,75 +0,0 @@ -run: - go: '1.17' - timeout: 5m - -linters-settings: - errcheck: - ignore: fmt:.*,Read|Write|Close|Exec,io:Copy - dupl: - threshold: 100 - funlen: - lines: 115 - statements: 115 - goheader: - template: |- - 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. -linters: - disable-all: true - enable: - - bodyclose - - deadcode - - depguard - - dogsled - - dupl - - errcheck - - funlen - - gocritic - - gofmt - - goheader - - gosec - - gosimple - - govet - - ineffassign - - misspell - - staticcheck - - structcheck - - stylecheck - - typecheck - - unconvert - - unused - - varcheck - - whitespace - -issues: - exclude-rules: - - path: _test\.go - linters: - - dupl - - funlen - - gosec - - gocritic - - linters: - - unused - source: ent.Schema - - path: dialect/sql/schema - linters: - - dupl - - gosec - - text: "Expect WriteFile permissions to be 0600 or less" - linters: - - gosec - - path: privacy/privacy.go - linters: - - stylecheck - - path: entc/load/schema.go - linters: - - staticcheck - - path: entc/gen/graph.go - linters: - - gocritic - - path: entc/integration/multischema/multischema_test.go - linters: - - staticcheck - text: SA1019 diff --git a/vendor/entgo.io/ent/CODE_OF_CONDUCT.md b/vendor/entgo.io/ent/CODE_OF_CONDUCT.md deleted file mode 100644 index d1abc700..00000000 --- a/vendor/entgo.io/ent/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,77 +0,0 @@ -# Code of Conduct - -## Our Pledge - -In the interest of fostering an open and welcoming environment, we as -contributors and maintainers pledge to make participation in our project and -our community a harassment-free experience for everyone, regardless of age, body -size, disability, ethnicity, sex characteristics, gender identity and expression, -level of experience, education, socio-economic status, nationality, personal -appearance, race, religion, or sexual identity and orientation. - -## Our Standards - -Examples of behavior that contributes to creating a positive environment -include: - -* Using welcoming and inclusive language -* Being respectful of differing viewpoints and experiences -* Gracefully accepting constructive criticism -* Focusing on what is best for the community -* Showing empathy towards other community members - -Examples of unacceptable behavior by participants include: - -* The use of sexualized language or imagery and unwelcome sexual attention or - advances -* Trolling, insulting/derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or electronic - address, without explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Our Responsibilities - -Project maintainers are responsible for clarifying the standards of acceptable -behavior and are expected to take appropriate and fair corrective action in -response to any instances of unacceptable behavior. - -Project maintainers have the right and responsibility to remove, edit, or -reject comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct, or to ban temporarily or -permanently any contributor for other behaviors that they deem inappropriate, -threatening, offensive, or harmful. - -## Scope - -This Code of Conduct applies within all project spaces, and it also applies when -an individual is representing the project or its community in public spaces. -Examples of representing a project or community include using an official -project e-mail address, posting via an official social media account, or acting -as an appointed representative at an online or offline event. Representation of -a project may be further defined and clarified by project maintainers. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at . All -complaints will be reviewed and investigated and will result in a response that -is deemed necessary and appropriate to the circumstances. The project team is -obligated to maintain confidentiality with regard to the reporter of an incident. -Further details of specific enforcement policies may be posted separately. - -Project maintainers who do not follow or enforce the Code of Conduct in good -faith may face temporary or permanent repercussions as determined by other -members of the project's leadership. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html - -[homepage]: https://www.contributor-covenant.org - -For answers to common questions about this code of conduct, see -https://www.contributor-covenant.org/faq - diff --git a/vendor/entgo.io/ent/CONTRIBUTING.md b/vendor/entgo.io/ent/CONTRIBUTING.md deleted file mode 100644 index 4017874e..00000000 --- a/vendor/entgo.io/ent/CONTRIBUTING.md +++ /dev/null @@ -1,69 +0,0 @@ -# Contributing to ent -We want to make contributing to this project as easy and transparent as -possible. - -# Project structure - -- `dialect` - Contains SQL and Gremlin code used by the generated code. - - `dialect/sql/schema` - Auto migration logic resides there. - -- `schema` - User schema API. - - `schema/{field, edge, index, mixin}` - provides schema builders API. - - `schema/field/gen` - Templates and codegen for numeric builders. - -- `entc` - Codegen of `ent`. - - `entc/load` - `entc` loader API for loading user schemas into a Go objects at runtime. - - `entc/gen` - The actual code generation logic resides in this package (and its `templates` package). - - `integration` - Integration tests for `entc`. - -- `privacy` - Runtime code for [privacy layer](https://entgo.io/docs/privacy/). - -- `doc` - Documentation code for `entgo.io` (uses [Docusaurus](https://docusaurus.io)). - - `doc/md` - Markdown files for documentation. - - `doc/website` - Website code and assets. - - In order to test your documentation changes, run `npm start` from the `doc/website` directory, and open [localhost:3000](http://localhost:3000/). - -# Run integration tests -If you touch any file in `entc`, run the following command in `entc`: - -``` -go generate ./... -``` - -Then, in `entc/integration` run `docker-compose` in order to spin-up all database containers: - -``` -docker-compose -f docker-compose.yaml up -d -``` - -Then, run `go test ./...` to run all integration tests. - - -## Pull Requests -We actively welcome your pull requests. - -1. Fork the repo and create your branch from `master`. -2. If you've added code that should be tested, add tests. -3. If you've changed APIs, update the documentation. -4. Ensure the test suite passes. -5. Make sure your code lints. -6. If you haven't already, complete the Contributor License Agreement ("CLA"). - -## Contributor License Agreement ("CLA") -In order to accept your pull request, we need you to submit a CLA. You only need -to do this once to work on any of Facebook's open source projects. - -Complete your CLA here: - -## Issues -We use GitHub issues to track public bugs. Please ensure your description is -clear and has sufficient instructions to be able to reproduce the issue. - -Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe -disclosure of security bugs. In those cases, please go through the process -outlined on that page and do not file a public issue. - -## License -By contributing to ent, you agree that your contributions will be licensed -under the LICENSE file in the root directory of this source tree. diff --git a/vendor/entgo.io/ent/LICENSE b/vendor/entgo.io/ent/LICENSE deleted file mode 100644 index 7a4a3ea2..00000000 --- a/vendor/entgo.io/ent/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/vendor/entgo.io/ent/README.md b/vendor/entgo.io/ent/README.md deleted file mode 100644 index 90ddb5e5..00000000 --- a/vendor/entgo.io/ent/README.md +++ /dev/null @@ -1,58 +0,0 @@ -## ent - An Entity Framework For Go - -[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/entgo_io.svg?style=social&label=Follow%20%40entgo_io)](https://twitter.com/entgo_io) -[![Discord](https://img.shields.io/discord/885059418646003782?label=discord&logo=discord&style=flat-square&logoColor=white)](https://discord.gg/qZmPgTE6RX) - -[English](README.md) | [中文](README_zh.md) | [日本語](README_jp.md) - - - -Simple, yet powerful entity framework for Go, that makes it easy to build and maintain applications -with large data-models. - -- **Schema As Code** - model any database schema as Go objects. -- **Easily Traverse Any Graph** - run queries, aggregations and traverse any graph structure easily. -- **Statically Typed And Explicit API** - 100% statically typed and explicit API using code generation. -- **Multi Storage Driver** - supports MySQL, MariaDB, TiDB, PostgreSQL, CockroachDB, SQLite and Gremlin. -- **Extendable** - simple to extend and customize using Go templates. - -## Quick Installation -```console -go install entgo.io/ent/cmd/ent@latest -``` - -For proper installation using [Go modules], visit [entgo.io website][entgo instal]. - -## Docs and Support -The documentation for developing and using ent is available at: https://entgo.io - -For discussion and support, [open an issue](https://github.com/ent/ent/issues/new/choose) or join our [channel](https://gophers.slack.com/archives/C01FMSQDT53) in the gophers Slack. - -## Join the ent Community -Building `ent` would not have been possible without the collective work of our entire community. We maintain a [contributors page](doc/md/contributors.md) -which lists the contributors to this `ent`. - -In order to contribute to `ent`, see the [CONTRIBUTING](CONTRIBUTING.md) file for how to go get started. -If your company or your product is using `ent`, please let us know by adding yourself to the [ent users page](https://github.com/ent/ent/wiki/ent-users). - -For updates, follow us on Twitter at https://twitter.com/entgo_io - - - -## About the Project -The `ent` project was inspired by Ent, an entity framework we use internally. It is developed and maintained -by [a8m](https://github.com/a8m) and [alexsn](https://github.com/alexsn) -from the [Facebook Connectivity][fbc] team. It is used by multiple teams and projects in production, -and the roadmap for its v1 release is described [here](https://github.com/ent/ent/issues/46). -Read more about the motivation of the project [here](https://entgo.io/blog/2019/10/03/introducing-ent). - -## License -ent is licensed under Apache 2.0 as found in the [LICENSE file](LICENSE). - - -[entgo instal]: https://entgo.io/docs/code-gen/#version-compatibility-between-entc-and-ent -[Go modules]: https://github.com/golang/go/wiki/Modules#quick-start -[fbc]: https://connectivity.fb.com diff --git a/vendor/entgo.io/ent/README_jp.md b/vendor/entgo.io/ent/README_jp.md deleted file mode 100644 index 5c5884e6..00000000 --- a/vendor/entgo.io/ent/README_jp.md +++ /dev/null @@ -1,54 +0,0 @@ -## ent - Goのエンティティーフレームワーク - -[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/entgo_io.svg?style=social&label=Follow%20%40entgo_io)](https://twitter.com/entgo_io) - -[English](README.md) | [中文](README_zh.md) | [日本語](README_jp.md) - - - -シンプルながらもパワフルなGoのエンティティフレームワークであり、大規模なデータモデルを持つアプリケーションを容易に構築・保守できるようにします。 - -- **Schema As Code(コードとしてのスキーマ)** - あらゆるデータベーススキーマをGoオブジェクトとしてモデル化します。 -- **任意のグラフを簡単にトラバースできます** - クエリや集約の実行、任意のグラフ構造の走査を容易に実行できます。 -- **100%静的に型付けされた明示的なAPI** - コード生成により、100%静的に型付けされた曖昧さのないAPIを提供します。 -- **マルチストレージドライバ** - MySQL、PostgreSQL、SQLite、Gremlinをサポートしています。 -- **拡張性** - Goテンプレートを使用して簡単に拡張、カスタマイズできます。 - -## クイックインストール -```console -go install entgo.io/ent/cmd/ent@latest -``` - -[Go modules]を使ったインストールについては、[entgo.io website][entgo instal]をご覧ください。 - -## ドキュメントとサポート -entを開発・使用するためのドキュメントは、こちら。: https://entgo.io - -議論やサポートについては、[Issueを立てる](https://github.com/ent/ent/issues/new/choose)か、gophers Slackの[チャンネル](https://gophers.slack.com/archives/C01FMSQDT53)に参加してください。 - -## entコミュニティへの参加 -`ent`の構築は、コミュニティ全体の協力なしには実現できませんでした。 私たちは、この`ent`の貢献者をリストアップした[contributorsページ](doc/md/contributors.md)を管理しています。 - -`ent`に貢献するときは、まず[CONTRIBUTING](CONTRIBUTING.md)を参照してください。 -もし、あなたの会社や製品で`ent`を利用している場合は、[ent usersページ](https://github.com/ent/ent/wiki/ent-users)に追記する形で、そのことをぜひ教えて下さい。 - -最新情報については、Twitter()をフォローしてください。 - - - -## プロジェクトについて -`ent`プロジェクトは、私たちが社内で使用しているエンティティフレームワークである`Ent`からインスピレーションを得ています。 -entは、[Facebook Connectivity][fbc]チームの[a8m](https://github.com/a8m)と[alexsn](https://github.com/alexsn)が開発・保守しています。 -本番環境では複数のチームやプロジェクトで使用されており、v1リリースまでのロードマップは[こちら](https://github.com/ent/ent/issues/46)に記載されています。 -このプロジェクトの動機については[こちら](https://entgo.io/blog/2019/10/03/introducing-ent)をご覧ください。 - -## ライセンス -entは、[LICENSEファイル](LICENSE)にもある通り、Apache 2.0でライセンスされています。 - - -[entgo instal]: https://entgo.io/docs/code-gen/#version-compatibility-between-entc-and-ent -[Go modules]: https://github.com/golang/go/wiki/Modules#quick-start -[fbc]: https://connectivity.fb.com diff --git a/vendor/entgo.io/ent/README_zh.md b/vendor/entgo.io/ent/README_zh.md deleted file mode 100644 index 05034b08..00000000 --- a/vendor/entgo.io/ent/README_zh.md +++ /dev/null @@ -1,44 +0,0 @@ -## ent - 一个强大的Go语言实体框架 - -[English](README.md) | [中文](README_zh.md) | [日本語](README_jp.md) - - - -ent是一个简单而又功能强大的Go语言实体框架,ent易于构建和维护应用程序与大数据模型。 - -- **图就是代码** - 将任何数据库表建模为Go对象。 -- **轻松地遍历任何图形** - 可以轻松地运行查询、聚合和遍历任何图形结构。 -- **静态类型和显式API** - 使用代码生成静态类型和显式API,查询数据更加便捷。 -- **多存储驱动程序** - 支持MySQL, PostgreSQL, SQLite 和 Gremlin。 -- **可扩展** - 简单地扩展和使用Go模板自定义。 - -## 快速安装 -```console -go install entgo.io/ent/cmd/ent@latest -``` - -请访问[entgo.io website][entgo instal]以使用[Go modules]进行正确安装。 - -## 文档和支持 -开发和使用ent的文档请参照: https://entgo.io - -如要讨论问题和支持, [创建一个issue](https://github.com/ent/ent/issues/new/choose) 或者加入我们的Gopher Slack(Slack软件,类似于论坛)[讨论组](https://gophers.slack.com/archives/C01FMSQDT53) - -## 加入 ent 社区 -如果你想为`ent`做出贡献, [贡献代码](CONTRIBUTING.md) 中写了如何做出自己的贡献 -如果你的公司或者产品在使用`ent`,请让我们知道你已经加入 [ent 用户](https://github.com/ent/ent/wiki/ent-users) - -## 关于项目 -`ent` 项目灵感来自于Ent,Ent是一个facebook内部使用的一个实体框架项目。 它由 [Facebook Connectivity][fbc] 团队通过 [a8m](https://github.com/a8m) 和 [alexsn](https://github.com/alexsn) 开发和维护 -, 它被生产中的多个团队和项目使用。它的v1版本的路线图为 [版本的路线图](https://github.com/ent/ent/issues/46). -关于项目更多的信息 [ent介绍](https://entgo.io/blog/2019/10/03/introducing-ent)。 - -## 声明 -ent使用Apache 2.0协议授权,可以在[LICENSE文件](LICENSE)中找到。 - -[entgo instal]: https://entgo.io/docs/code-gen/#version-compatibility-between-entc-and-ent -[Go modules]: https://github.com/golang/go/wiki/Modules#quick-start -[fbc]: https://connectivity.fb.com diff --git a/vendor/entgo.io/ent/ent.go b/vendor/entgo.io/ent/ent.go deleted file mode 100644 index 69aa9b40..00000000 --- a/vendor/entgo.io/ent/ent.go +++ /dev/null @@ -1,365 +0,0 @@ -// 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. - -// Package ent is the interface between end-user schemas and entc (ent codegen). -package ent - -import ( - "context" - - "entgo.io/ent/schema" - "entgo.io/ent/schema/edge" - "entgo.io/ent/schema/field" - "entgo.io/ent/schema/index" -) - -type ( - // The Interface type describes the requirements for an exported type defined in the schema package. - // It functions as the interface between the user's schema types and codegen loader. - // Users should use the Schema type for embedding as follows: - // - // type T struct { - // ent.Schema - // } - // - Interface interface { - // Type is a dummy method, that is used in edge declaration. - // - // The Type method should be used as follows: - // - // type S struct { ent.Schema } - // - // type T struct { ent.Schema } - // - // func (T) Edges() []ent.Edge { - // return []ent.Edge{ - // edge.To("S", S.Type), - // } - // } - // - Type() - // Fields returns the fields of the schema. - Fields() []Field - // Edges returns the edges of the schema. - Edges() []Edge - // Indexes returns the indexes of the schema. - Indexes() []Index - // Config returns an optional config for the schema. - // - // Deprecated: the Config method predates the Annotations method, and it - // is planned be removed in v0.5.0. New code should use Annotations instead. - // - // func (T) Annotations() []schema.Annotation { - // return []schema.Annotation{ - // entsql.Annotation{Table: "Name"}, - // } - // } - // - Config() Config - // Mixin returns an optional list of Mixin to extends - // the schema. - Mixin() []Mixin - // Hooks returns an optional list of Hook to apply on - // mutations. - Hooks() []Hook - // Policy returns the privacy policy of the schema. - Policy() Policy - // Annotations returns a list of schema annotations to be used by - // codegen extensions. - Annotations() []schema.Annotation - } - - // A Field interface returns a field descriptor for vertex fields/properties. - // The usage for the interface is as follows: - // - // func (T) Fields() []ent.Field { - // return []ent.Field{ - // field.Int("int"), - // } - // } - // - Field interface { - Descriptor() *field.Descriptor - } - - // An Edge interface returns an edge descriptor for vertex edges. - // The usage for the interface is as follows: - // - // func (T) Edges() []ent.Edge { - // return []ent.Edge{ - // edge.To("S", S.Type), - // } - // } - // - Edge interface { - Descriptor() *edge.Descriptor - } - - // An Index interface returns an index descriptor for vertex indexes. - // The usage for the interface is as follows: - // - // func (T) Indexes() []ent.Index { - // return []ent.Index{ - // index.Fields("f1", "f2"). - // Unique(), - // } - // } - // - Index interface { - Descriptor() *index.Descriptor - } - - // A Config structure is used to configure an entity schema. - // The usage of this structure is as follows: - // - // func (T) Config() ent.Config { - // return ent.Config{ - // Table: "Name", - // } - // } - // - // Deprecated: the Config object predates the schema.Annotation method and it - // is planned be removed in v0.5.0. New code should use Annotations instead. - // - // func (T) Annotations() []schema.Annotation { - // return []schema.Annotation{ - // entsql.Annotation{Table: "Name"}, - // } - // } - // - Config struct { - // A Table is an optional table name defined for the schema. - Table string - } - - // The Mixin type describes a set of methods that can extend - // other methods in the schema without calling them directly. - // - // type TimeMixin struct {} - // - // func (TimeMixin) Fields() []ent.Field { - // return []ent.Field{ - // field.Time("created_at"). - // Immutable(). - // Default(time.Now), - // field.Time("updated_at"). - // Default(time.Now). - // UpdateDefault(time.Now), - // } - // } - // - // type T struct { - // ent.Schema - // } - // - // func(T) Mixin() []ent.Mixin { - // return []ent.Mixin{ - // TimeMixin{}, - // } - // } - // - Mixin interface { - // Fields returns a slice of fields to add to the schema. - Fields() []Field - // Edges returns a slice of edges to add to the schema. - Edges() []Edge - // Indexes returns a slice of indexes to add to the schema. - Indexes() []Index - // Hooks returns a slice of hooks to add to the schema. - // Note that mixin hooks are executed before schema hooks. - Hooks() []Hook - // Policy returns a privacy policy to add to the schema. - // Note that mixin policy are executed before schema policy. - Policy() Policy - // Annotations returns a list of schema annotations to add - // to the schema annotations. - Annotations() []schema.Annotation - } - - // The Policy type defines the write privacy policy of an entity. - // The usage for the interface is as follows: - // - // type T struct { - // ent.Schema - // } - // - // func(T) Policy() ent.Policy { - // return privacy.AlwaysAllowReadWrite() - // } - // - Policy interface { - EvalMutation(context.Context, Mutation) error - EvalQuery(context.Context, Query) error - } - - // Schema is the default implementation for the schema Interface. - // It can be embedded in end-user schemas as follows: - // - // type T struct { - // ent.Schema - // } - // - Schema struct { - Interface - } -) - -// Fields of the schema. -func (Schema) Fields() []Field { return nil } - -// Edges of the schema. -func (Schema) Edges() []Edge { return nil } - -// Indexes of the schema. -func (Schema) Indexes() []Index { return nil } - -// Config of the schema. -func (Schema) Config() Config { return Config{} } - -// Mixin of the schema. -func (Schema) Mixin() []Mixin { return nil } - -// Hooks of the schema. -func (Schema) Hooks() []Hook { return nil } - -// Policy of the schema. -func (Schema) Policy() Policy { return nil } - -// Annotations of the schema. -func (Schema) Annotations() []schema.Annotation { return nil } - -type ( - // Value represents a value returned by ent. - Value interface{} - // Query represents an ent query builder. - Query interface{} - // Mutation represents an operation that mutate the graph. - // For example, adding a new node, updating many, or dropping - // data. The implementation is generated by entc (ent codegen). - Mutation interface { - // Op returns the operation name generated by entc. - Op() Op - // Type returns the schema type for this mutation. - Type() string - - // Fields returns all fields that were changed during - // this mutation. Note that, in order to get all numeric - // fields that were in/decremented, call AddedFields(). - Fields() []string - // Field returns the value of a field with the given name. - // The second boolean value indicates that this field was - // not set, or was not defined in the schema. - Field(name string) (Value, bool) - // SetField sets the value for the given name. It returns an - // error if the field is not defined in the schema, or if the - // type mismatch the field type. - SetField(name string, value Value) error - - // AddedFields returns all numeric fields that were incremented - // or decremented during this mutation. - AddedFields() []string - // AddedField returns the numeric value that was in/decremented - // from a field with the given name. The second value indicates - // that this field was not set, or was not define in the schema. - AddedField(name string) (Value, bool) - // AddField adds the value for the given name. It returns an - // error if the field is not defined in the schema, or if the - // type mismatch the field type. - AddField(name string, value Value) error - - // ClearedFields returns all nullable fields that were cleared - // during this mutation. - ClearedFields() []string - // FieldCleared returns a bool indicates if this field was - // cleared in this mutation. - FieldCleared(name string) bool - // ClearField clears the value for the given name. It returns an - // error if the field is not defined in the schema. - ClearField(name string) error - - // ResetField resets all changes in the mutation regarding the - // given field name. It returns an error if the field is not - // defined in the schema. - ResetField(name string) error - - // AddedEdges returns all edge names that were set/added in this - // mutation. - AddedEdges() []string - // AddedIDs returns all ids (to other nodes) that were added for - // the given edge name. - AddedIDs(name string) []Value - - // RemovedEdges returns all edge names that were removed in this - // mutation. - RemovedEdges() []string - // RemovedIDs returns all ids (to other nodes) that were removed for - // the given edge name. - RemovedIDs(name string) []Value - - // ClearedEdges returns all edge names that were cleared in this - // mutation. - ClearedEdges() []string - // EdgeCleared returns a bool indicates if this edge was - // cleared in this mutation. - EdgeCleared(name string) bool - // ClearEdge clears the value for the given name. It returns an - // error if the edge name is not defined in the schema. - ClearEdge(name string) error - - // ResetEdge resets all changes in the mutation regarding the - // given edge name. It returns an error if the edge is not - // defined in the schema. - ResetEdge(name string) error - - // OldField returns the old value of the field from the database. - // An error is returned if the mutation operation is not UpdateOne, - // or the query to the database was failed. - OldField(ctx context.Context, name string) (Value, error) - } - - // Mutator is the interface that wraps the Mutate method. - Mutator interface { - // Mutate apply the given mutation on the graph. - Mutate(context.Context, Mutation) (Value, error) - } - - // The MutateFunc type is an adapter to allow the use of ordinary - // function as mutator. If f is a function with the appropriate signature, - // MutateFunc(f) is a Mutator that calls f. - MutateFunc func(context.Context, Mutation) (Value, error) - - // Hook defines the "mutation middleware". A function that gets a Mutator - // and returns a Mutator. For example: - // - // hook := func(next ent.Mutator) ent.Mutator { - // return ent.MutateFunc(func(ctx context.Context, m ent.Mutation) (ent.Value, error) { - // fmt.Printf("Type: %s, Operation: %s, ConcreteType: %T\n", m.Type(), m.Op(), m) - // return next.Mutate(ctx, m) - // }) - // } - // - Hook func(Mutator) Mutator -) - -// Mutate calls f(ctx, m). -func (f MutateFunc) Mutate(ctx context.Context, m Mutation) (Value, error) { - return f(ctx, m) -} - -// An Op represents a mutation operation. -type Op uint - -// Mutation operations. -const ( - OpCreate Op = 1 << iota // node creation. - OpUpdate // update nodes by predicate (if any). - OpUpdateOne // update one node. - OpDelete // delete nodes by predicate (if any). - OpDeleteOne // delete one node. -) - -// Is reports whether o is match the given operation. -func (i Op) Is(o Op) bool { return i&o != 0 } - -//go:generate go run golang.org/x/tools/cmd/stringer -type Op diff --git a/vendor/entgo.io/ent/op_string.go b/vendor/entgo.io/ent/op_string.go deleted file mode 100644 index b8bf9da4..00000000 --- a/vendor/entgo.io/ent/op_string.go +++ /dev/null @@ -1,43 +0,0 @@ -// Code generated by "stringer -type Op"; DO NOT EDIT. - -package ent - -import "strconv" - -func _() { - // An "invalid array index" compiler error signifies that the constant values have changed. - // Re-run the stringer command to generate them again. - var x [1]struct{} - _ = x[OpCreate-1] - _ = x[OpUpdate-2] - _ = x[OpUpdateOne-4] - _ = x[OpDelete-8] - _ = x[OpDeleteOne-16] -} - -const ( - _Op_name_0 = "OpCreateOpUpdate" - _Op_name_1 = "OpUpdateOne" - _Op_name_2 = "OpDelete" - _Op_name_3 = "OpDeleteOne" -) - -var ( - _Op_index_0 = [...]uint8{0, 8, 16} -) - -func (i Op) String() string { - switch { - case 1 <= i && i <= 2: - i -= 1 - return _Op_name_0[_Op_index_0[i]:_Op_index_0[i+1]] - case i == 4: - return _Op_name_1 - case i == 8: - return _Op_name_2 - case i == 16: - return _Op_name_3 - default: - return "Op(" + strconv.FormatInt(int64(i), 10) + ")" - } -} diff --git a/vendor/entgo.io/ent/schema/edge/annotation.go b/vendor/entgo.io/ent/schema/edge/annotation.go deleted file mode 100644 index f2d64685..00000000 --- a/vendor/entgo.io/ent/schema/edge/annotation.go +++ /dev/null @@ -1,49 +0,0 @@ -// 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. - -package edge - -import "entgo.io/ent/schema" - -// Annotation is a builtin schema annotation for -// configuring the edges' behavior in codegen. -type Annotation struct { - // The StructTag option allows overriding the struct-tag - // of the `Edges` field in the generated entity. For example: - // - // edge.Annotation{ - // StructTag: `json: "pet_edges"` - // } - // - StructTag string -} - -// Name describes the annotation name. -func (Annotation) Name() string { - return "Edges" -} - -// Merge implements the schema.Merger interface. -func (a Annotation) Merge(other schema.Annotation) schema.Annotation { - var ant Annotation - switch other := other.(type) { - case Annotation: - ant = other - case *Annotation: - if other != nil { - ant = *other - } - default: - return a - } - if tag := ant.StructTag; tag != "" { - a.StructTag = tag - } - return a -} - -var ( - _ schema.Annotation = (*Annotation)(nil) - _ schema.Merger = (*Annotation)(nil) -) diff --git a/vendor/entgo.io/ent/schema/edge/edge.go b/vendor/entgo.io/ent/schema/edge/edge.go deleted file mode 100644 index 354bf4f1..00000000 --- a/vendor/entgo.io/ent/schema/edge/edge.go +++ /dev/null @@ -1,270 +0,0 @@ -// 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. - -package edge - -import ( - "reflect" - - "entgo.io/ent/schema" -) - -// A Descriptor for edge configuration. -type Descriptor struct { - Tag string // struct tag. - Type string // edge type. - Name string // edge name. - Field string // edge field name (e.g. foreign-key). - RefName string // ref name; inverse only. - Ref *Descriptor // edge reference; to/from of the same type. - Through *struct{ N, T string } // through type and name. - Unique bool // unique edge. - Inverse bool // inverse edge. - Required bool // required on creation. - StorageKey *StorageKey // optional storage-key configuration. - Annotations []schema.Annotation // edge annotations. - Comment string // edge comment. -} - -// To defines an association edge between two vertices. -func To(name string, t interface{}) *assocBuilder { - return &assocBuilder{desc: &Descriptor{Name: name, Type: typ(t)}} -} - -// From represents a reversed-edge between two vertices that has a back-reference to its source edge. -func From(name string, t interface{}) *inverseBuilder { - return &inverseBuilder{desc: &Descriptor{Name: name, Type: typ(t), Inverse: true}} -} - -func typ(t interface{}) string { - if rt := reflect.TypeOf(t); rt.NumIn() > 0 { - return rt.In(0).Name() - } - return "" -} - -// assocBuilder is the builder for assoc edges. -type assocBuilder struct { - desc *Descriptor -} - -// Unique sets the edge type to be unique. Basically, it limits the edge to be one of the two: -// one2one or one2many. one2one applied if the inverse-edge is also unique. -func (b *assocBuilder) Unique() *assocBuilder { - b.desc.Unique = true - return b -} - -// Required indicates that this edge is a required field on creation. -// Unlike fields, edges are optional by default. -func (b *assocBuilder) Required() *assocBuilder { - b.desc.Required = true - return b -} - -// StructTag sets the struct tag of the assoc edge. -func (b *assocBuilder) StructTag(s string) *assocBuilder { - b.desc.Tag = s - return b -} - -// From creates an inverse-edge with the same type. -func (b *assocBuilder) From(name string) *inverseBuilder { - return &inverseBuilder{desc: &Descriptor{Name: name, Type: b.desc.Type, Inverse: true, Ref: b.desc}} -} - -// Field is used to bind an edge (with a foreign-key) to a field in the schema. -// -// field.Int("owner_id"). -// Optional() -// -// edge.To("owner", User.Type). -// Field("owner_id"). -// Unique(), -// -func (b *assocBuilder) Field(f string) *assocBuilder { - b.desc.Field = f - return b -} - -// Through allows setting an "edge schema" to interact explicitly with M2M edges. -// -// edge.To("friends", User.Type). -// Through("friendships", Friendship.Type) -// -func (b *assocBuilder) Through(name string, t interface{}) *assocBuilder { - b.desc.Through = &struct{ N, T string }{N: name, T: typ(t)} - return b -} - -// Comment used to put annotations on the schema. -func (b *assocBuilder) Comment(c string) *assocBuilder { - b.desc.Comment = c - return b -} - -// StorageKey sets the storage key of the edge. -// -// edge.To("groups", Group.Type). -// StorageKey(edge.Table("user_groups"), edge.Columns("user_id", "group_id")) -// -func (b *assocBuilder) StorageKey(opts ...StorageOption) *assocBuilder { - if b.desc.StorageKey == nil { - b.desc.StorageKey = &StorageKey{} - } - for i := range opts { - opts[i](b.desc.StorageKey) - } - return b -} - -// Annotations adds a list of annotations to the edge object to be used by -// codegen extensions. -// -// edge.To("pets", Pet.Type). -// Annotations(entgql.Bind()) -// -func (b *assocBuilder) Annotations(annotations ...schema.Annotation) *assocBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Descriptor interface. -func (b *assocBuilder) Descriptor() *Descriptor { - return b.desc -} - -// inverseBuilder is the builder for inverse edges. -type inverseBuilder struct { - desc *Descriptor -} - -// Ref sets the referenced-edge of this inverse edge. -func (b *inverseBuilder) Ref(ref string) *inverseBuilder { - b.desc.RefName = ref - return b -} - -// Unique sets the edge type to be unique. Basically, it limits the edge to be one of the two: -// one2one or one2many. one2one applied if the inverse-edge is also unique. -func (b *inverseBuilder) Unique() *inverseBuilder { - b.desc.Unique = true - return b -} - -// Required indicates that this edge is a required field on creation. -// Unlike fields, edges are optional by default. -func (b *inverseBuilder) Required() *inverseBuilder { - b.desc.Required = true - return b -} - -// StructTag sets the struct tag of the inverse edge. -func (b *inverseBuilder) StructTag(s string) *inverseBuilder { - b.desc.Tag = s - return b -} - -// Comment used to put annotations on the schema. -func (b *inverseBuilder) Comment(c string) *inverseBuilder { - b.desc.Comment = c - return b -} - -// Field is used to bind an edge (with a foreign-key) to a field in the schema. -// -// field.Int("owner_id"). -// Optional() -// -// edge.From("owner", User.Type). -// Ref("pets"). -// Field("owner_id"). -// Unique(), -// -func (b *inverseBuilder) Field(f string) *inverseBuilder { - b.desc.Field = f - return b -} - -// Through allows setting an "edge schema" to interact explicitly with M2M edges. -// -// edge.From("liked_users", User.Type). -// Ref("liked_tweets"). -// Through("likes", TweetLike.Type) -// -func (b *inverseBuilder) Through(name string, t interface{}) *inverseBuilder { - b.desc.Through = &struct{ N, T string }{N: name, T: typ(t)} - return b -} - -// Annotations adds a list of annotations to the edge object to be used by -// codegen extensions. -// -// edge.From("owner", User.Type). -// Ref("pets"). -// Unique(). -// Annotations(entgql.Bind()) -// -func (b *inverseBuilder) Annotations(annotations ...schema.Annotation) *inverseBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Descriptor interface. -func (b *inverseBuilder) Descriptor() *Descriptor { - return b.desc -} - -// StorageKey holds the configuration for edge storage-key. -type StorageKey struct { - Table string // Table or label. - Symbols []string // Symbols/names of the foreign-key constraints. - Columns []string // Foreign-key columns. -} - -// StorageOption allows for setting the storage configuration using functional options. -type StorageOption func(*StorageKey) - -// Table sets the table name option for M2M edges. -func Table(name string) StorageOption { - return func(key *StorageKey) { - key.Table = name - } -} - -// Symbol sets the symbol/name of the foreign-key constraint for O2O, O2M and M2O edges. -// Note that, for M2M edges (2 columns and 2 constraints), use the edge.Symbols option. -func Symbol(symbol string) StorageOption { - return func(key *StorageKey) { - key.Symbols = []string{symbol} - } -} - -// Symbols sets the symbol/name of the foreign-key constraints for M2M edges. -// The 1st column defines the name of the "To" edge, and the 2nd defines -// the name of the "From" edge (inverse edge). -// Note that, for O2O, O2M and M2O edges, use the edge.Symbol option. -func Symbols(to, from string) StorageOption { - return func(key *StorageKey) { - key.Symbols = []string{to, from} - } -} - -// Column sets the foreign-key column name option for O2O, O2M and M2O edges. -// Note that, for M2M edges (2 columns), use the edge.Columns option. -func Column(name string) StorageOption { - return func(key *StorageKey) { - key.Columns = []string{name} - } -} - -// Columns sets the foreign-key column names option for M2M edges. -// The 1st column defines the name of the "To" edge, and the 2nd defines -// the name of the "From" edge (inverse edge). -// Note that, for O2O, O2M and M2O edges, use the edge.Column option. -func Columns(to, from string) StorageOption { - return func(key *StorageKey) { - key.Columns = []string{to, from} - } -} diff --git a/vendor/entgo.io/ent/schema/field/annotation.go b/vendor/entgo.io/ent/schema/field/annotation.go deleted file mode 100644 index 6ac208b0..00000000 --- a/vendor/entgo.io/ent/schema/field/annotation.go +++ /dev/null @@ -1,81 +0,0 @@ -// 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. - -package field - -import "entgo.io/ent/schema" - -// Annotation is a builtin schema annotation for -// configuring the schema fields in codegen. -type Annotation struct { - // The StructTag option allows overriding the struct-tag - // of the fields in the generated entity. For example: - // - // field.Annotation{ - // StructTag: map[string]string{ - // "id": `json:"id,omitempty" yaml:"-"`, - // }, - // } - // - StructTag map[string]string - - // ID defines a multi-field schema identifier. Note, - // the annotation is valid only for edge schemas. - // - // func (TweetLike) Annotations() []schema.Annotation { - // return []schema.Annotation{ - // field.ID("user_id", "tweet_id"), - // } - // } - // - ID []string -} - -// ID defines a multi-field schema identifier. Note, the -// annotation is valid only for edge schemas. -// -// func (TweetLike) Annotations() []schema.Annotation { -// return []schema.Annotation{ -// field.ID("user_id", "tweet_id"), -// } -// } -// -func ID(first, second string, fields ...string) *Annotation { - return &Annotation{ID: append([]string{first, second}, fields...)} -} - -// Name describes the annotation name. -func (Annotation) Name() string { - return "Fields" -} - -// Merge implements the schema.Merger interface. -func (a Annotation) Merge(other schema.Annotation) schema.Annotation { - var ant Annotation - switch other := other.(type) { - case Annotation: - ant = other - case *Annotation: - if other != nil { - ant = *other - } - default: - return a - } - for k, v := range ant.StructTag { - if a.StructTag == nil { - a.StructTag = make(map[string]string) - } - a.StructTag[k] = v - } - if len(ant.ID) > 0 { - a.ID = ant.ID - } - return a -} - -var _ interface { - schema.Annotation - schema.Merger -} = (*Annotation)(nil) diff --git a/vendor/entgo.io/ent/schema/field/field.go b/vendor/entgo.io/ent/schema/field/field.go deleted file mode 100644 index 35b63dd8..00000000 --- a/vendor/entgo.io/ent/schema/field/field.go +++ /dev/null @@ -1,1267 +0,0 @@ -// 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. - -package field - -import ( - "database/sql" - "database/sql/driver" - "errors" - "fmt" - "math" - "reflect" - "regexp" - "time" - - "entgo.io/ent/schema" -) - -// String returns a new Field with type string. -func String(name string) *stringBuilder { - return &stringBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeString}, - }} -} - -// Text returns a new string field without limitation on the size. -// In MySQL, it is the "longtext" type, but in SQLite and Gremlin it has no effect. -func Text(name string) *stringBuilder { - return &stringBuilder{&Descriptor{ - Name: name, - Size: math.MaxInt32, - Info: &TypeInfo{Type: TypeString}, - }} -} - -// Bytes returns a new Field with type bytes/buffer. -// In MySQL and SQLite, it is the "BLOB" type, and it does not support for Gremlin. -func Bytes(name string) *bytesBuilder { - return &bytesBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeBytes, Nillable: true}, - }} -} - -// Bool returns a new Field with type bool. -func Bool(name string) *boolBuilder { - return &boolBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeBool}, - }} -} - -// Time returns a new Field with type timestamp. -func Time(name string) *timeBuilder { - return &timeBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeTime, PkgPath: "time"}, - }} -} - -// JSON returns a new Field with type json that is serialized to the given object. -// For example: -// -// field.JSON("dirs", []http.Dir{}). -// Optional() -// -// -// field.JSON("info", &Info{}). -// Optional() -// -func JSON(name string, typ interface{}) *jsonBuilder { - b := &jsonBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{ - Type: TypeJSON, - }, - }} - t := reflect.TypeOf(typ) - if t == nil { - b.desc.Err = errors.New("expect a Go value as JSON type, but got nil") - return b - } - b.desc.Info.Ident = t.String() - b.desc.Info.PkgPath = t.PkgPath() - b.desc.goType(typ, t) - switch t.Kind() { - case reflect.Slice, reflect.Array, reflect.Ptr, reflect.Map: - b.desc.Info.Nillable = true - b.desc.Info.PkgPath = pkgPath(t) - } - return b -} - -// Strings returns a new JSON Field with type []string. -func Strings(name string) *jsonBuilder { - return JSON(name, []string{}) -} - -// Ints returns a new JSON Field with type []int. -func Ints(name string) *jsonBuilder { - return JSON(name, []int{}) -} - -// Floats returns a new JSON Field with type []float. -func Floats(name string) *jsonBuilder { - return JSON(name, []float64{}) -} - -// Enum returns a new Field with type enum. An example for defining enum is as follows: -// -// field.Enum("state"). -// Values( -// "on", -// "off", -// ). -// Default("on") -// -func Enum(name string) *enumBuilder { - return &enumBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeEnum}, - }} -} - -// UUID returns a new Field with type UUID. An example for defining UUID field is as follows: -// -// field.UUID("id", uuid.New()) -// -func UUID(name string, typ driver.Valuer) *uuidBuilder { - rt := reflect.TypeOf(typ) - b := &uuidBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{ - Type: TypeUUID, - Ident: rt.String(), - PkgPath: indirect(rt).PkgPath(), - }, - }} - b.desc.goType(typ, valueScannerType) - return b -} - -// Other represents a field that is not a good fit for any of the standard field types. -// -// The second argument defines the GoType and must implement the ValueScanner interface. -// The SchemaType option must be set because the field type cannot be inferred. -// An example for defining Other field is as follows: -// -// field.Other("link", &Link{}). -// SchemaType(map[string]string{ -// dialect.MySQL: "text", -// dialect.Postgres: "varchar", -// }) -// -func Other(name string, typ driver.Valuer) *otherBuilder { - ob := &otherBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeOther}, - }} - ob.desc.goType(typ, valueScannerType) - return ob -} - -// stringBuilder is the builder for string fields. -type stringBuilder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *stringBuilder) Unique() *stringBuilder { - b.desc.Unique = true - return b -} - -// Sensitive fields not printable and not serializable. -func (b *stringBuilder) Sensitive() *stringBuilder { - b.desc.Sensitive = true - return b -} - -// Match adds a regex matcher for this field. Operation fails if the regex fails. -func (b *stringBuilder) Match(re *regexp.Regexp) *stringBuilder { - b.desc.Validators = append(b.desc.Validators, func(v string) error { - if !re.MatchString(v) { - return errors.New("value does not match validation") - } - return nil - }) - return b -} - -// MinLen adds a length validator for this field. -// Operation fails if the length of the string is less than the given value. -func (b *stringBuilder) MinLen(i int) *stringBuilder { - b.desc.Validators = append(b.desc.Validators, func(v string) error { - if len(v) < i { - return errors.New("value is less than the required length") - } - return nil - }) - return b -} - -// NotEmpty adds a length validator for this field. -// Operation fails if the length of the string is zero. -func (b *stringBuilder) NotEmpty() *stringBuilder { - return b.MinLen(1) -} - -// MaxLen adds a length validator for this field. -// Operation fails if the length of the string is greater than the given value. -func (b *stringBuilder) MaxLen(i int) *stringBuilder { - b.desc.Size = i - b.desc.Validators = append(b.desc.Validators, func(v string) error { - if len(v) > i { - return errors.New("value is greater than the required length") - } - return nil - }) - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *stringBuilder) Validate(fn func(string) error) *stringBuilder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// Default sets the default value of the field. -func (b *stringBuilder) Default(s string) *stringBuilder { - b.desc.Default = s - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. For example: -// -// field.String("cuid"). -// DefaultFunc(cuid.New) -// -func (b *stringBuilder) DefaultFunc(fn interface{}) *stringBuilder { - b.desc.Default = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *stringBuilder) Nillable() *stringBuilder { - b.desc.Nillable = true - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *stringBuilder) Optional() *stringBuilder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *stringBuilder) Immutable() *stringBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *stringBuilder) Comment(c string) *stringBuilder { - b.desc.Comment = c - return b -} - -// StructTag sets the struct tag of the field. -func (b *stringBuilder) StructTag(s string) *stringBuilder { - b.desc.Tag = s - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *stringBuilder) StorageKey(key string) *stringBuilder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for string. -// -// field.String("name"). -// SchemaType(map[string]string{ -// dialect.MySQL: "text", -// dialect.Postgres: "varchar", -// }) -// -func (b *stringBuilder) SchemaType(types map[string]string) *stringBuilder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.String("dir"). -// GoType(http.Dir("dir")) -// -func (b *stringBuilder) GoType(typ interface{}) *stringBuilder { - b.desc.goType(typ, stringType) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.String("dir"). -// Annotations( -// entgql.OrderField("DIR"), -// ) -// -func (b *stringBuilder) Annotations(annotations ...schema.Annotation) *stringBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *stringBuilder) Descriptor() *Descriptor { - if b.desc.Default != nil { - b.desc.checkDefaultFunc(stringType) - } - return b.desc -} - -// timeBuilder is the builder for time fields. -type timeBuilder struct { - desc *Descriptor -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *timeBuilder) Nillable() *timeBuilder { - b.desc.Nillable = true - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *timeBuilder) Optional() *timeBuilder { - b.desc.Optional = true - return b -} - -// Immutable fields are fields that can be set only in the creation of the entity. -// i.e., no setters will be generated for the entity updaters (one and many). -func (b *timeBuilder) Immutable() *timeBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *timeBuilder) Comment(c string) *timeBuilder { - b.desc.Comment = c - return b -} - -// StructTag sets the struct tag of the field. -func (b *timeBuilder) StructTag(s string) *timeBuilder { - b.desc.Tag = s - return b -} - -// Default sets the function that is applied to set default value -// of the field on creation. For example: -// -// field.Time("created_at"). -// Default(time.Now) -// -func (b *timeBuilder) Default(fn interface{}) *timeBuilder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Time("updated_at"). -// Default(time.Now). -// UpdateDefault(time.Now), -// -// field.Time("deleted_at"). -// Optional(). -// GoType(&sql.NullTime{}). -// UpdateDefault(NewNullTime), -// -func (b *timeBuilder) UpdateDefault(fn interface{}) *timeBuilder { - b.desc.UpdateDefault = fn - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *timeBuilder) StorageKey(key string) *timeBuilder { - b.desc.StorageKey = key - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Time("deleted_at"). -// GoType(&sql.NullTime{}) -// -func (b *timeBuilder) GoType(typ interface{}) *timeBuilder { - b.desc.goType(typ, timeType) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Time("deleted_at"). -// Annotations( -// entgql.OrderField("DELETED_AT"), -// ) -// -func (b *timeBuilder) Annotations(annotations ...schema.Annotation) *timeBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *timeBuilder) Descriptor() *Descriptor { - if b.desc.Default != nil { - b.desc.checkDefaultFunc(timeType) - } - return b.desc -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for time. -// -// field.Time("created_at"). -// SchemaType(map[string]string{ -// dialect.MySQL: "datetime", -// dialect.Postgres: "time with time zone", -// }) -// -func (b *timeBuilder) SchemaType(types map[string]string) *timeBuilder { - b.desc.SchemaType = types - return b -} - -// boolBuilder is the builder for boolean fields. -type boolBuilder struct { - desc *Descriptor -} - -// Default sets the default value of the field. -func (b *boolBuilder) Default(v bool) *boolBuilder { - b.desc.Default = v - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *boolBuilder) Nillable() *boolBuilder { - b.desc.Nillable = true - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *boolBuilder) Optional() *boolBuilder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *boolBuilder) Immutable() *boolBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *boolBuilder) Comment(c string) *boolBuilder { - b.desc.Comment = c - return b -} - -// StructTag sets the struct tag of the field. -func (b *boolBuilder) StructTag(s string) *boolBuilder { - b.desc.Tag = s - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *boolBuilder) StorageKey(key string) *boolBuilder { - b.desc.StorageKey = key - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Bool("deleted"). -// GoType(&sql.NullBool{}) -// -func (b *boolBuilder) GoType(typ interface{}) *boolBuilder { - b.desc.goType(typ, boolType) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Bool("deleted"). -// Annotations( -// entgql.OrderField("DELETED"), -// ) -// -func (b *boolBuilder) Annotations(annotations ...schema.Annotation) *boolBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *boolBuilder) Descriptor() *Descriptor { - return b.desc -} - -// bytesBuilder is the builder for bytes fields. -type bytesBuilder struct { - desc *Descriptor -} - -// Default sets the default value of the field. -func (b *bytesBuilder) Default(v []byte) *bytesBuilder { - b.desc.Default = v - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. For example: -// -// field.Bytes("cuid"). -// DefaultFunc(cuid.New) -// -func (b *bytesBuilder) DefaultFunc(fn interface{}) *bytesBuilder { - b.desc.Default = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *bytesBuilder) Nillable() *bytesBuilder { - b.desc.Nillable = true - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *bytesBuilder) Optional() *bytesBuilder { - b.desc.Optional = true - return b -} - -// Sensitive fields not printable and not serializable. -func (b *bytesBuilder) Sensitive() *bytesBuilder { - b.desc.Sensitive = true - return b -} - -// Unique makes the field unique within all vertices of this type. -// Only supported in PostgreSQL. -func (b *bytesBuilder) Unique() *bytesBuilder { - b.desc.Unique = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *bytesBuilder) Immutable() *bytesBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *bytesBuilder) Comment(c string) *bytesBuilder { - b.desc.Comment = c - return b -} - -// StructTag sets the struct tag of the field. -func (b *bytesBuilder) StructTag(s string) *bytesBuilder { - b.desc.Tag = s - return b -} - -// MaxLen sets the max-length of the bytes type in the database. -// In MySQL, this affects the BLOB type (tiny 2^8-1, regular 2^16-1, medium 2^24-1, long 2^32-1). -// In SQLite, it does not have any effect on the type size, which is default to 1B bytes. -func (b *bytesBuilder) MaxLen(i int) *bytesBuilder { - b.desc.Size = i - b.desc.Validators = append(b.desc.Validators, func(buf []byte) error { - if len(buf) > i { - return errors.New("value is greater than the required length") - } - return nil - }) - return b -} - -// MinLen adds a length validator for this field. -// Operation fails if the length of the buffer is less than the given value. -func (b *bytesBuilder) MinLen(i int) *bytesBuilder { - b.desc.Validators = append(b.desc.Validators, func(b []byte) error { - if len(b) < i { - return errors.New("value is less than the required length") - } - return nil - }) - return b -} - -// NotEmpty adds a length validator for this field. -// Operation fails if the length of the buffer is zero. -func (b *bytesBuilder) NotEmpty() *bytesBuilder { - return b.MinLen(1) -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -// -// field.Bytes("blob"). -// Validate(func(b []byte) error { -// if len(b) % 2 == 0 { -// return fmt.Errorf("ent/schema: blob length is even: %d", len(b)) -// } -// return nil -// }) -// -func (b *bytesBuilder) Validate(fn func([]byte) error) *bytesBuilder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *bytesBuilder) StorageKey(key string) *bytesBuilder { - b.desc.StorageKey = key - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Bytes("ip"). -// GoType(net.IP("127.0.0.1")) -// -func (b *bytesBuilder) GoType(typ interface{}) *bytesBuilder { - b.desc.goType(typ, bytesType) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -func (b *bytesBuilder) Annotations(annotations ...schema.Annotation) *bytesBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for bytes. -// -// field.Bytes("blob"). -// SchemaType(map[string]string{ -// dialect.MySQL: "tinyblob", -// dialect.SQLite: "tinyblob", -// }) -// -func (b *bytesBuilder) SchemaType(types map[string]string) *bytesBuilder { - b.desc.SchemaType = types - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *bytesBuilder) Descriptor() *Descriptor { - if b.desc.Default != nil { - b.desc.checkDefaultFunc(bytesType) - } - return b.desc -} - -// jsonBuilder is the builder for json fields. -type jsonBuilder struct { - desc *Descriptor -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *jsonBuilder) StorageKey(key string) *jsonBuilder { - b.desc.StorageKey = key - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *jsonBuilder) Optional() *jsonBuilder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *jsonBuilder) Immutable() *jsonBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *jsonBuilder) Comment(c string) *jsonBuilder { - b.desc.Comment = c - return b -} - -// Sensitive fields not printable and not serializable. -func (b *jsonBuilder) Sensitive() *jsonBuilder { - b.desc.Sensitive = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *jsonBuilder) StructTag(s string) *jsonBuilder { - b.desc.Tag = s - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for json. -// -// field.JSON("json"). -// SchemaType(map[string]string{ -// dialect.MySQL: "json", -// dialect.Postgres: "jsonb", -// }) -// -func (b *jsonBuilder) SchemaType(types map[string]string) *jsonBuilder { - b.desc.SchemaType = types - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -func (b *jsonBuilder) Annotations(annotations ...schema.Annotation) *jsonBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Default sets the default value of the field. For example: -// -// field.JSON("dirs", []http.Dir{}). -// // A static default value. -// Default([]http.Dir{"/tmp"}) -// -// field.JSON("dirs", []http.Dir{}). -// // A function for generating the default value. -// Default(DefaultDirs) -// -func (b *jsonBuilder) Default(v interface{}) *jsonBuilder { - b.desc.Default = v - switch fieldT, defaultT := b.desc.Info.RType.rtype, reflect.TypeOf(v); { - case fieldT == defaultT: - case defaultT.Kind() == reflect.Func: - b.desc.checkDefaultFunc(b.desc.Info.RType.rtype) - default: - b.desc.Err = fmt.Errorf("expect type (func() %[1]s) or (%[1]s) for other default value", b.desc.Info) - } - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *jsonBuilder) Descriptor() *Descriptor { - return b.desc -} - -// enumBuilder is the builder for enum fields. -type enumBuilder struct { - desc *Descriptor -} - -// Values adds given values to the enum values. -// -// field.Enum("priority"). -// Values("low", "mid", "high") -// -func (b *enumBuilder) Values(values ...string) *enumBuilder { - for _, v := range values { - b.desc.Enums = append(b.desc.Enums, struct{ N, V string }{N: v, V: v}) - } - return b -} - -// NamedValues adds the given name, value pairs to the enum value. -// The "name" defines the Go identifier of the enum, and the value -// defines the actual value in the database. -// -// NamedValues returns an error if given an odd number of arguments. -// -// field.Enum("priority"). -// NamedValues( -// "Low", "LOW", -// "Mid", "MID", -// "High", "HIGH", -// ) -// -func (b *enumBuilder) NamedValues(namevalue ...string) *enumBuilder { - if len(namevalue)%2 == 1 { - b.desc.Err = fmt.Errorf("Enum.NamedValues: odd argument count") - return b - } - for i := 0; i < len(namevalue); i += 2 { - b.desc.Enums = append(b.desc.Enums, struct{ N, V string }{N: namevalue[i], V: namevalue[i+1]}) - } - return b -} - -// Default sets the default value of the field. -func (b *enumBuilder) Default(value string) *enumBuilder { - b.desc.Default = value - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *enumBuilder) StorageKey(key string) *enumBuilder { - b.desc.StorageKey = key - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *enumBuilder) Optional() *enumBuilder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *enumBuilder) Immutable() *enumBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *enumBuilder) Comment(c string) *enumBuilder { - b.desc.Comment = c - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *enumBuilder) Nillable() *enumBuilder { - b.desc.Nillable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *enumBuilder) StructTag(s string) *enumBuilder { - b.desc.Tag = s - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for enum. -// -// field.Enum("enum"). -// SchemaType(map[string]string{ -// dialect.Postgres: "EnumType", -// }) -// -func (b *enumBuilder) SchemaType(types map[string]string) *enumBuilder { - b.desc.SchemaType = types - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Enum("enum"). -// Annotations( -// entgql.OrderField("ENUM"), -// ) -// -func (b *enumBuilder) Annotations(annotations ...schema.Annotation) *enumBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// EnumValues defines the interface for getting the enum values. -type EnumValues interface { - Values() []string -} - -// GoType overrides the default Go type with a custom one. -// -// field.Enum("enum"). -// GoType(role.Enum("role")) -// -func (b *enumBuilder) GoType(ev EnumValues) *enumBuilder { - b.Values(ev.Values()...) - b.desc.goType(ev, stringType) - // If an error already exists, let that be returned instead. - // Otherwise, check that the underlying type is either a string - // or implements Stringer. - if b.desc.Err == nil && b.desc.Info.RType.rtype.Kind() != reflect.String && !b.desc.Info.Stringer() { - b.desc.Err = errors.New("enum values which implement ValueScanner must also implement Stringer") - } - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *enumBuilder) Descriptor() *Descriptor { - return b.desc -} - -// uuidBuilder is the builder for uuid fields. -type uuidBuilder struct { - desc *Descriptor -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *uuidBuilder) StorageKey(key string) *uuidBuilder { - b.desc.StorageKey = key - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *uuidBuilder) Nillable() *uuidBuilder { - b.desc.Nillable = true - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *uuidBuilder) Optional() *uuidBuilder { - b.desc.Optional = true - return b -} - -// Unique makes the field unique within all vertices of this type. -func (b *uuidBuilder) Unique() *uuidBuilder { - b.desc.Unique = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *uuidBuilder) Immutable() *uuidBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *uuidBuilder) Comment(c string) *uuidBuilder { - b.desc.Comment = c - return b -} - -// StructTag sets the struct tag of the field. -func (b *uuidBuilder) StructTag(s string) *uuidBuilder { - b.desc.Tag = s - return b -} - -// Default sets the function that is applied to set default value -// of the field on creation. Codegen fails if the default function -// doesn't return the same concrete that was set for the UUID type. -// -// field.UUID("id", uuid.UUID{}). -// Default(uuid.New) -// -func (b *uuidBuilder) Default(fn interface{}) *uuidBuilder { - typ := reflect.TypeOf(fn) - if typ.Kind() != reflect.Func || typ.NumIn() != 0 || typ.NumOut() != 1 || typ.Out(0).String() != b.desc.Info.String() { - b.desc.Err = fmt.Errorf("expect type (func() %s) for uuid default value", b.desc.Info) - } - b.desc.Default = fn - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for uuid. -// -// field.UUID("id", uuid.New()). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomUUID", -// }) -// -func (b *uuidBuilder) SchemaType(types map[string]string) *uuidBuilder { - b.desc.SchemaType = types - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.UUID("id", uuid.New()). -// Annotations( -// entgql.OrderField("ID"), -// ) -// -func (b *uuidBuilder) Annotations(annotations ...schema.Annotation) *uuidBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *uuidBuilder) Descriptor() *Descriptor { - return b.desc -} - -// otherBuilder is the builder for other fields. -type otherBuilder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *otherBuilder) Unique() *otherBuilder { - b.desc.Unique = true - return b -} - -// Sensitive fields not printable and not serializable. -func (b *otherBuilder) Sensitive() *otherBuilder { - b.desc.Sensitive = true - return b -} - -// Default sets the default value of the field. For example: -// -// field.Other("link", &Link{}). -// SchemaType(map[string]string{ -// dialect.MySQL: "text", -// dialect.Postgres: "varchar", -// }). -// // A static default value. -// Default(&Link{Addr: "0.0.0.0"}) -// -// field.Other("link", &Link{}). -// SchemaType(map[string]string{ -// dialect.MySQL: "text", -// dialect.Postgres: "varchar", -// }). -// // A function for generating the default value. -// Default(NewLink) -// -func (b *otherBuilder) Default(v interface{}) *otherBuilder { - b.desc.Default = v - switch fieldT, defaultT := b.desc.Info.RType.rtype, reflect.TypeOf(v); { - case fieldT == defaultT: - case defaultT.Kind() == reflect.Func: - b.desc.checkDefaultFunc(b.desc.Info.RType.rtype) - default: - b.desc.Err = fmt.Errorf("expect type (func() %[1]s) or (%[1]s) for other default value", b.desc.Info) - } - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated field. -func (b *otherBuilder) Nillable() *otherBuilder { - b.desc.Nillable = true - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *otherBuilder) Optional() *otherBuilder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *otherBuilder) Immutable() *otherBuilder { - b.desc.Immutable = true - return b -} - -// Comment sets the comment of the field. -func (b *otherBuilder) Comment(c string) *otherBuilder { - b.desc.Comment = c - return b -} - -// StructTag sets the struct tag of the field. -func (b *otherBuilder) StructTag(s string) *otherBuilder { - b.desc.Tag = s - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *otherBuilder) StorageKey(key string) *otherBuilder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for string. -// -// field.Other("link", Link{}). -// SchemaType(map[string]string{ -// dialect.MySQL: "text", -// dialect.Postgres: "varchar", -// }) -// -func (b *otherBuilder) SchemaType(types map[string]string) *otherBuilder { - b.desc.SchemaType = types - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Other("link", &Link{}). -// SchemaType(map[string]string{ -// dialect.MySQL: "text", -// dialect.Postgres: "varchar", -// }). -// Annotations( -// entgql.OrderField("LINK"), -// ) -// -func (b *otherBuilder) Annotations(annotations ...schema.Annotation) *otherBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *otherBuilder) Descriptor() *Descriptor { - if len(b.desc.SchemaType) == 0 { - b.desc.Err = fmt.Errorf("expect SchemaType to be set for other field") - } - return b.desc -} - -// A Descriptor for field configuration. -type Descriptor struct { - Tag string // struct tag. - Size int // varchar size. - Name string // field name. - Info *TypeInfo // field type info. - Unique bool // unique index of field. - Nillable bool // nillable struct field. - Optional bool // nullable field in database. - Immutable bool // create-only field. - Default interface{} // default value on create. - UpdateDefault interface{} // default value on update. - Validators []interface{} // validator functions. - StorageKey string // sql column or gremlin property. - Enums []struct{ N, V string } // enum values. - Sensitive bool // sensitive info string field. - SchemaType map[string]string // override the schema type. - Annotations []schema.Annotation // field annotations. - Comment string // field comment. - Err error -} - -func (d *Descriptor) goType(typ interface{}, expectType reflect.Type) { - t := reflect.TypeOf(typ) - tv := indirect(t) - info := &TypeInfo{ - Type: d.Info.Type, - Ident: t.String(), - PkgPath: tv.PkgPath(), - RType: &RType{ - rtype: t, - Kind: t.Kind(), - Name: tv.Name(), - Ident: tv.String(), - PkgPath: tv.PkgPath(), - Methods: make(map[string]struct{ In, Out []*RType }, t.NumMethod()), - }, - } - methods(t, info.RType) - switch t.Kind() { - case reflect.Slice, reflect.Ptr, reflect.Map: - info.Nillable = true - } - switch pt := reflect.PtrTo(t); { - case pt.Implements(valueScannerType), t.Implements(valueScannerType), - t.Kind() == expectType.Kind() && t.ConvertibleTo(expectType): - default: - d.Err = fmt.Errorf("GoType must be a %q type or ValueScanner", expectType) - } - d.Info = info -} - -func methods(t reflect.Type, rtype *RType) { - // For type T, add methods with - // pointer receiver as well (*T). - if t.Kind() != reflect.Ptr { - t = reflect.PtrTo(t) - } - n := t.NumMethod() - for i := 0; i < n; i++ { - m := t.Method(i) - in := make([]*RType, m.Type.NumIn()-1) - for j := range in { - arg := m.Type.In(j + 1) - in[j] = &RType{Name: arg.Name(), Ident: arg.String(), Kind: arg.Kind(), PkgPath: arg.PkgPath()} - } - out := make([]*RType, m.Type.NumOut()) - for j := range out { - ret := m.Type.Out(j) - out[j] = &RType{Name: ret.Name(), Ident: ret.String(), Kind: ret.Kind(), PkgPath: ret.PkgPath()} - } - rtype.Methods[m.Name] = struct{ In, Out []*RType }{in, out} - } -} - -func (d *Descriptor) checkDefaultFunc(expectType reflect.Type) { - for _, typ := range []reflect.Type{reflect.TypeOf(d.Default), reflect.TypeOf(d.UpdateDefault)} { - if typ == nil || typ.Kind() != reflect.Func || d.Err != nil { - continue - } - err := fmt.Errorf("expect type (func() %s) for default value", d.Info) - if typ.NumIn() != 0 || typ.NumOut() != 1 { - d.Err = err - } - rtype := expectType - if d.Info.RType != nil { - rtype = d.Info.RType.rtype - } - if !typ.Out(0).AssignableTo(rtype) { - d.Err = err - } - } -} - -var ( - boolType = reflect.TypeOf(false) - bytesType = reflect.TypeOf([]byte(nil)) - timeType = reflect.TypeOf(time.Time{}) - stringType = reflect.TypeOf("") - valuerType = reflect.TypeOf((*driver.Valuer)(nil)).Elem() - valueScannerType = reflect.TypeOf((*ValueScanner)(nil)).Elem() -) - -// ValueScanner is the interface that groups the Value and the Scan methods. -type ValueScanner interface { - driver.Valuer - sql.Scanner -} - -// indirect returns the type at the end of indirection. -func indirect(t reflect.Type) reflect.Type { - for t.Kind() == reflect.Ptr { - t = t.Elem() - } - return t -} - -func pkgPath(t reflect.Type) string { - pkg := t.PkgPath() - if pkg != "" { - return pkg - } - switch t.Kind() { - case reflect.Slice, reflect.Array, reflect.Ptr, reflect.Map: - return pkgPath(t.Elem()) - } - return pkg -} diff --git a/vendor/entgo.io/ent/schema/field/numeric.go b/vendor/entgo.io/ent/schema/field/numeric.go deleted file mode 100644 index 0a40875d..00000000 --- a/vendor/entgo.io/ent/schema/field/numeric.go +++ /dev/null @@ -1,2176 +0,0 @@ -// 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 internal/numeric.tmpl, DO NOT EDIT. - -package field - -import ( - "errors" - "reflect" - - "entgo.io/ent/schema" -) - -//go:generate go run internal/gen.go - -// Int returns a new Field with type int. -func Int(name string) *intBuilder { - return &intBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeInt}, - }} -} - -// Uint returns a new Field with type uint. -func Uint(name string) *uintBuilder { - return &uintBuilder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeUint}, - }} -} - -// Int8 returns a new Field with type int8. -func Int8(name string) *int8Builder { - return &int8Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeInt8}, - }} -} - -// Int16 returns a new Field with type int16. -func Int16(name string) *int16Builder { - return &int16Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeInt16}, - }} -} - -// Int32 returns a new Field with type int32. -func Int32(name string) *int32Builder { - return &int32Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeInt32}, - }} -} - -// Int64 returns a new Field with type int64. -func Int64(name string) *int64Builder { - return &int64Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeInt64}, - }} -} - -// Uint8 returns a new Field with type uint8. -func Uint8(name string) *uint8Builder { - return &uint8Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeUint8}, - }} -} - -// Uint16 returns a new Field with type uint16. -func Uint16(name string) *uint16Builder { - return &uint16Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeUint16}, - }} -} - -// Uint32 returns a new Field with type uint32. -func Uint32(name string) *uint32Builder { - return &uint32Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeUint32}, - }} -} - -// Uint64 returns a new Field with type uint64. -func Uint64(name string) *uint64Builder { - return &uint64Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeUint64}, - }} -} - -// Float returns a new Field with type float64. -func Float(name string) *float64Builder { - return &float64Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeFloat64}, - }} -} - -// Float32 returns a new Field with type float32. -func Float32(name string) *float32Builder { - return &float32Builder{&Descriptor{ - Name: name, - Info: &TypeInfo{Type: TypeFloat32}, - }} -} - -// intBuilder is the builder for int field. -type intBuilder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *intBuilder) Unique() *intBuilder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *intBuilder) Range(i, j int) *intBuilder { - b.desc.Validators = append(b.desc.Validators, func(v int) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *intBuilder) Min(i int) *intBuilder { - b.desc.Validators = append(b.desc.Validators, func(v int) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *intBuilder) Max(i int) *intBuilder { - b.desc.Validators = append(b.desc.Validators, func(v int) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *intBuilder) Positive() *intBuilder { - return b.Min(1) -} - -// Negative adds a maximum value validator with the value of -1. Operation fails if the validator fails. -func (b *intBuilder) Negative() *intBuilder { - return b.Max(-1) -} - -// NonNegative adds a minimum value validator with the value of 0. Operation fails if the validator fails. -func (b *intBuilder) NonNegative() *intBuilder { - return b.Min(0) -} - -// Default sets the default value of the field. -func (b *intBuilder) Default(i int) *intBuilder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *intBuilder) DefaultFunc(fn interface{}) *intBuilder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Int("int"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *intBuilder) UpdateDefault(fn interface{}) *intBuilder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *intBuilder) Nillable() *intBuilder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *intBuilder) Comment(c string) *intBuilder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *intBuilder) Optional() *intBuilder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *intBuilder) Immutable() *intBuilder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *intBuilder) StructTag(s string) *intBuilder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *intBuilder) Validate(fn func(int) error) *intBuilder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *intBuilder) StorageKey(key string) *intBuilder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for int. -// -// field.Int("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *intBuilder) SchemaType(types map[string]string) *intBuilder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Int("int"). -// GoType(pkg.Int(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *intBuilder) GoType(typ interface{}) *intBuilder { - b.desc.goType(typ, intType) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Int("int"). -// Annotations(entgql.OrderField("INT")) -// -func (b *intBuilder) Annotations(annotations ...schema.Annotation) *intBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *intBuilder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(intType) - } - return b.desc -} - -// uintBuilder is the builder for uint field. -type uintBuilder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *uintBuilder) Unique() *uintBuilder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *uintBuilder) Range(i, j uint) *uintBuilder { - b.desc.Validators = append(b.desc.Validators, func(v uint) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *uintBuilder) Min(i uint) *uintBuilder { - b.desc.Validators = append(b.desc.Validators, func(v uint) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *uintBuilder) Max(i uint) *uintBuilder { - b.desc.Validators = append(b.desc.Validators, func(v uint) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *uintBuilder) Positive() *uintBuilder { - return b.Min(1) -} - -// Default sets the default value of the field. -func (b *uintBuilder) Default(i uint) *uintBuilder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *uintBuilder) DefaultFunc(fn interface{}) *uintBuilder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Uint("uint"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *uintBuilder) UpdateDefault(fn interface{}) *uintBuilder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *uintBuilder) Nillable() *uintBuilder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *uintBuilder) Comment(c string) *uintBuilder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *uintBuilder) Optional() *uintBuilder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *uintBuilder) Immutable() *uintBuilder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *uintBuilder) StructTag(s string) *uintBuilder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *uintBuilder) Validate(fn func(uint) error) *uintBuilder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *uintBuilder) StorageKey(key string) *uintBuilder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for uint. -// -// field.Uint("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *uintBuilder) SchemaType(types map[string]string) *uintBuilder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Uint("uint"). -// GoType(pkg.Uint(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *uintBuilder) GoType(typ interface{}) *uintBuilder { - b.desc.goType(typ, uintType) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Uint("uint"). -// Annotations(entgql.OrderField("UINT")) -// -func (b *uintBuilder) Annotations(annotations ...schema.Annotation) *uintBuilder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *uintBuilder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(uintType) - } - return b.desc -} - -// int8Builder is the builder for int8 field. -type int8Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *int8Builder) Unique() *int8Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *int8Builder) Range(i, j int8) *int8Builder { - b.desc.Validators = append(b.desc.Validators, func(v int8) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *int8Builder) Min(i int8) *int8Builder { - b.desc.Validators = append(b.desc.Validators, func(v int8) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *int8Builder) Max(i int8) *int8Builder { - b.desc.Validators = append(b.desc.Validators, func(v int8) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *int8Builder) Positive() *int8Builder { - return b.Min(1) -} - -// Negative adds a maximum value validator with the value of -1. Operation fails if the validator fails. -func (b *int8Builder) Negative() *int8Builder { - return b.Max(-1) -} - -// NonNegative adds a minimum value validator with the value of 0. Operation fails if the validator fails. -func (b *int8Builder) NonNegative() *int8Builder { - return b.Min(0) -} - -// Default sets the default value of the field. -func (b *int8Builder) Default(i int8) *int8Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *int8Builder) DefaultFunc(fn interface{}) *int8Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Int8("int8"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *int8Builder) UpdateDefault(fn interface{}) *int8Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *int8Builder) Nillable() *int8Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *int8Builder) Comment(c string) *int8Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *int8Builder) Optional() *int8Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *int8Builder) Immutable() *int8Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *int8Builder) StructTag(s string) *int8Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *int8Builder) Validate(fn func(int8) error) *int8Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *int8Builder) StorageKey(key string) *int8Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for int8. -// -// field.Int8("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *int8Builder) SchemaType(types map[string]string) *int8Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Int8("int8"). -// GoType(pkg.Int8(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *int8Builder) GoType(typ interface{}) *int8Builder { - b.desc.goType(typ, int8Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Int8("int8"). -// Annotations(entgql.OrderField("INT8")) -// -func (b *int8Builder) Annotations(annotations ...schema.Annotation) *int8Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *int8Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(int8Type) - } - return b.desc -} - -// int16Builder is the builder for int16 field. -type int16Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *int16Builder) Unique() *int16Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *int16Builder) Range(i, j int16) *int16Builder { - b.desc.Validators = append(b.desc.Validators, func(v int16) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *int16Builder) Min(i int16) *int16Builder { - b.desc.Validators = append(b.desc.Validators, func(v int16) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *int16Builder) Max(i int16) *int16Builder { - b.desc.Validators = append(b.desc.Validators, func(v int16) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *int16Builder) Positive() *int16Builder { - return b.Min(1) -} - -// Negative adds a maximum value validator with the value of -1. Operation fails if the validator fails. -func (b *int16Builder) Negative() *int16Builder { - return b.Max(-1) -} - -// NonNegative adds a minimum value validator with the value of 0. Operation fails if the validator fails. -func (b *int16Builder) NonNegative() *int16Builder { - return b.Min(0) -} - -// Default sets the default value of the field. -func (b *int16Builder) Default(i int16) *int16Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *int16Builder) DefaultFunc(fn interface{}) *int16Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Int16("int16"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *int16Builder) UpdateDefault(fn interface{}) *int16Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *int16Builder) Nillable() *int16Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *int16Builder) Comment(c string) *int16Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *int16Builder) Optional() *int16Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *int16Builder) Immutable() *int16Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *int16Builder) StructTag(s string) *int16Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *int16Builder) Validate(fn func(int16) error) *int16Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *int16Builder) StorageKey(key string) *int16Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for int16. -// -// field.Int16("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *int16Builder) SchemaType(types map[string]string) *int16Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Int16("int16"). -// GoType(pkg.Int16(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *int16Builder) GoType(typ interface{}) *int16Builder { - b.desc.goType(typ, int16Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Int16("int16"). -// Annotations(entgql.OrderField("INT16")) -// -func (b *int16Builder) Annotations(annotations ...schema.Annotation) *int16Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *int16Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(int16Type) - } - return b.desc -} - -// int32Builder is the builder for int32 field. -type int32Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *int32Builder) Unique() *int32Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *int32Builder) Range(i, j int32) *int32Builder { - b.desc.Validators = append(b.desc.Validators, func(v int32) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *int32Builder) Min(i int32) *int32Builder { - b.desc.Validators = append(b.desc.Validators, func(v int32) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *int32Builder) Max(i int32) *int32Builder { - b.desc.Validators = append(b.desc.Validators, func(v int32) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *int32Builder) Positive() *int32Builder { - return b.Min(1) -} - -// Negative adds a maximum value validator with the value of -1. Operation fails if the validator fails. -func (b *int32Builder) Negative() *int32Builder { - return b.Max(-1) -} - -// NonNegative adds a minimum value validator with the value of 0. Operation fails if the validator fails. -func (b *int32Builder) NonNegative() *int32Builder { - return b.Min(0) -} - -// Default sets the default value of the field. -func (b *int32Builder) Default(i int32) *int32Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *int32Builder) DefaultFunc(fn interface{}) *int32Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Int32("int32"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *int32Builder) UpdateDefault(fn interface{}) *int32Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *int32Builder) Nillable() *int32Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *int32Builder) Comment(c string) *int32Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *int32Builder) Optional() *int32Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *int32Builder) Immutable() *int32Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *int32Builder) StructTag(s string) *int32Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *int32Builder) Validate(fn func(int32) error) *int32Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *int32Builder) StorageKey(key string) *int32Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for int32. -// -// field.Int32("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *int32Builder) SchemaType(types map[string]string) *int32Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Int32("int32"). -// GoType(pkg.Int32(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *int32Builder) GoType(typ interface{}) *int32Builder { - b.desc.goType(typ, int32Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Int32("int32"). -// Annotations(entgql.OrderField("INT32")) -// -func (b *int32Builder) Annotations(annotations ...schema.Annotation) *int32Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *int32Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(int32Type) - } - return b.desc -} - -// int64Builder is the builder for int64 field. -type int64Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *int64Builder) Unique() *int64Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *int64Builder) Range(i, j int64) *int64Builder { - b.desc.Validators = append(b.desc.Validators, func(v int64) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *int64Builder) Min(i int64) *int64Builder { - b.desc.Validators = append(b.desc.Validators, func(v int64) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *int64Builder) Max(i int64) *int64Builder { - b.desc.Validators = append(b.desc.Validators, func(v int64) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *int64Builder) Positive() *int64Builder { - return b.Min(1) -} - -// Negative adds a maximum value validator with the value of -1. Operation fails if the validator fails. -func (b *int64Builder) Negative() *int64Builder { - return b.Max(-1) -} - -// NonNegative adds a minimum value validator with the value of 0. Operation fails if the validator fails. -func (b *int64Builder) NonNegative() *int64Builder { - return b.Min(0) -} - -// Default sets the default value of the field. -func (b *int64Builder) Default(i int64) *int64Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *int64Builder) DefaultFunc(fn interface{}) *int64Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Int64("int64"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *int64Builder) UpdateDefault(fn interface{}) *int64Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *int64Builder) Nillable() *int64Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *int64Builder) Comment(c string) *int64Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *int64Builder) Optional() *int64Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *int64Builder) Immutable() *int64Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *int64Builder) StructTag(s string) *int64Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *int64Builder) Validate(fn func(int64) error) *int64Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *int64Builder) StorageKey(key string) *int64Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for int64. -// -// field.Int64("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *int64Builder) SchemaType(types map[string]string) *int64Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Int64("int64"). -// GoType(pkg.Int64(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *int64Builder) GoType(typ interface{}) *int64Builder { - b.desc.goType(typ, int64Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Int64("int64"). -// Annotations(entgql.OrderField("INT64")) -// -func (b *int64Builder) Annotations(annotations ...schema.Annotation) *int64Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *int64Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(int64Type) - } - return b.desc -} - -// uint8Builder is the builder for uint8 field. -type uint8Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *uint8Builder) Unique() *uint8Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *uint8Builder) Range(i, j uint8) *uint8Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint8) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *uint8Builder) Min(i uint8) *uint8Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint8) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *uint8Builder) Max(i uint8) *uint8Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint8) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *uint8Builder) Positive() *uint8Builder { - return b.Min(1) -} - -// Default sets the default value of the field. -func (b *uint8Builder) Default(i uint8) *uint8Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *uint8Builder) DefaultFunc(fn interface{}) *uint8Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Uint8("uint8"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *uint8Builder) UpdateDefault(fn interface{}) *uint8Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *uint8Builder) Nillable() *uint8Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *uint8Builder) Comment(c string) *uint8Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *uint8Builder) Optional() *uint8Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *uint8Builder) Immutable() *uint8Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *uint8Builder) StructTag(s string) *uint8Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *uint8Builder) Validate(fn func(uint8) error) *uint8Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *uint8Builder) StorageKey(key string) *uint8Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for uint8. -// -// field.Uint8("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *uint8Builder) SchemaType(types map[string]string) *uint8Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Uint8("uint8"). -// GoType(pkg.Uint8(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *uint8Builder) GoType(typ interface{}) *uint8Builder { - b.desc.goType(typ, uint8Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Uint8("uint8"). -// Annotations(entgql.OrderField("UINT8")) -// -func (b *uint8Builder) Annotations(annotations ...schema.Annotation) *uint8Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *uint8Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(uint8Type) - } - return b.desc -} - -// uint16Builder is the builder for uint16 field. -type uint16Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *uint16Builder) Unique() *uint16Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *uint16Builder) Range(i, j uint16) *uint16Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint16) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *uint16Builder) Min(i uint16) *uint16Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint16) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *uint16Builder) Max(i uint16) *uint16Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint16) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *uint16Builder) Positive() *uint16Builder { - return b.Min(1) -} - -// Default sets the default value of the field. -func (b *uint16Builder) Default(i uint16) *uint16Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *uint16Builder) DefaultFunc(fn interface{}) *uint16Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Uint16("uint16"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *uint16Builder) UpdateDefault(fn interface{}) *uint16Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *uint16Builder) Nillable() *uint16Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *uint16Builder) Comment(c string) *uint16Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *uint16Builder) Optional() *uint16Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *uint16Builder) Immutable() *uint16Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *uint16Builder) StructTag(s string) *uint16Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *uint16Builder) Validate(fn func(uint16) error) *uint16Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *uint16Builder) StorageKey(key string) *uint16Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for uint16. -// -// field.Uint16("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *uint16Builder) SchemaType(types map[string]string) *uint16Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Uint16("uint16"). -// GoType(pkg.Uint16(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *uint16Builder) GoType(typ interface{}) *uint16Builder { - b.desc.goType(typ, uint16Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Uint16("uint16"). -// Annotations(entgql.OrderField("UINT16")) -// -func (b *uint16Builder) Annotations(annotations ...schema.Annotation) *uint16Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *uint16Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(uint16Type) - } - return b.desc -} - -// uint32Builder is the builder for uint32 field. -type uint32Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *uint32Builder) Unique() *uint32Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *uint32Builder) Range(i, j uint32) *uint32Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint32) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *uint32Builder) Min(i uint32) *uint32Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint32) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *uint32Builder) Max(i uint32) *uint32Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint32) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *uint32Builder) Positive() *uint32Builder { - return b.Min(1) -} - -// Default sets the default value of the field. -func (b *uint32Builder) Default(i uint32) *uint32Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *uint32Builder) DefaultFunc(fn interface{}) *uint32Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Uint32("uint32"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *uint32Builder) UpdateDefault(fn interface{}) *uint32Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *uint32Builder) Nillable() *uint32Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *uint32Builder) Comment(c string) *uint32Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *uint32Builder) Optional() *uint32Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *uint32Builder) Immutable() *uint32Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *uint32Builder) StructTag(s string) *uint32Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *uint32Builder) Validate(fn func(uint32) error) *uint32Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *uint32Builder) StorageKey(key string) *uint32Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for uint32. -// -// field.Uint32("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *uint32Builder) SchemaType(types map[string]string) *uint32Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Uint32("uint32"). -// GoType(pkg.Uint32(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *uint32Builder) GoType(typ interface{}) *uint32Builder { - b.desc.goType(typ, uint32Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Uint32("uint32"). -// Annotations(entgql.OrderField("UINT32")) -// -func (b *uint32Builder) Annotations(annotations ...schema.Annotation) *uint32Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *uint32Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(uint32Type) - } - return b.desc -} - -// uint64Builder is the builder for uint64 field. -type uint64Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *uint64Builder) Unique() *uint64Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *uint64Builder) Range(i, j uint64) *uint64Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint64) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *uint64Builder) Min(i uint64) *uint64Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint64) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *uint64Builder) Max(i uint64) *uint64Builder { - b.desc.Validators = append(b.desc.Validators, func(v uint64) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 1. Operation fails if the validator fails. -func (b *uint64Builder) Positive() *uint64Builder { - return b.Min(1) -} - -// Default sets the default value of the field. -func (b *uint64Builder) Default(i uint64) *uint64Builder { - b.desc.Default = i - return b -} - -// DefaultFunc sets the function that is applied to set the default value -// of the field on creation. -func (b *uint64Builder) DefaultFunc(fn interface{}) *uint64Builder { - b.desc.Default = fn - return b -} - -// UpdateDefault sets the function that is applied to set default value -// of the field on update. For example: -// -// field.Uint64("uint64"). -// Default(0). -// UpdateDefault(GenNumber), -// -func (b *uint64Builder) UpdateDefault(fn interface{}) *uint64Builder { - b.desc.UpdateDefault = fn - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *uint64Builder) Nillable() *uint64Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *uint64Builder) Comment(c string) *uint64Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *uint64Builder) Optional() *uint64Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *uint64Builder) Immutable() *uint64Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *uint64Builder) StructTag(s string) *uint64Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *uint64Builder) Validate(fn func(uint64) error) *uint64Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *uint64Builder) StorageKey(key string) *uint64Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for uint64. -// -// field.Uint64("oid"). -// SchemaType(map[string]string{ -// dialect.Postgres: "CustomType", -// }) -// -func (b *uint64Builder) SchemaType(types map[string]string) *uint64Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Uint64("uint64"). -// GoType(pkg.Uint64(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *uint64Builder) GoType(typ interface{}) *uint64Builder { - b.desc.goType(typ, uint64Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Uint64("uint64"). -// Annotations(entgql.OrderField("UINT64")) -// -func (b *uint64Builder) Annotations(annotations ...schema.Annotation) *uint64Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *uint64Builder) Descriptor() *Descriptor { - if b.desc.Default != nil || b.desc.UpdateDefault != nil { - b.desc.checkDefaultFunc(uint64Type) - } - return b.desc -} - -var ( - intType = reflect.TypeOf(int(0)) - uintType = reflect.TypeOf(uint(0)) - int8Type = reflect.TypeOf(int8(0)) - int16Type = reflect.TypeOf(int16(0)) - int32Type = reflect.TypeOf(int32(0)) - int64Type = reflect.TypeOf(int64(0)) - uint8Type = reflect.TypeOf(uint8(0)) - uint16Type = reflect.TypeOf(uint16(0)) - uint32Type = reflect.TypeOf(uint32(0)) - uint64Type = reflect.TypeOf(uint64(0)) -) - -// float64Builder is the builder for float fields. -type float64Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *float64Builder) Unique() *float64Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *float64Builder) Range(i, j float64) *float64Builder { - b.desc.Validators = append(b.desc.Validators, func(v float64) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *float64Builder) Min(i float64) *float64Builder { - b.desc.Validators = append(b.desc.Validators, func(v float64) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *float64Builder) Max(i float64) *float64Builder { - b.desc.Validators = append(b.desc.Validators, func(v float64) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 0.000001. Operation fails if the validator fails. -func (b *float64Builder) Positive() *float64Builder { - return b.Min(1e-06) -} - -// Negative adds a maximum value validator with the value of -0.000001. Operation fails if the validator fails. -func (b *float64Builder) Negative() *float64Builder { - return b.Max(-1e-06) -} - -// Default sets the default value of the field. -func (b *float64Builder) Default(i float64) *float64Builder { - b.desc.Default = i - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *float64Builder) Nillable() *float64Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *float64Builder) Comment(c string) *float64Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *float64Builder) Optional() *float64Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *float64Builder) Immutable() *float64Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *float64Builder) StructTag(s string) *float64Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *float64Builder) Validate(fn func(float64) error) *float64Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *float64Builder) StorageKey(key string) *float64Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for float64. -// -// field.Float64("amount"). -// SchemaType(map[string]string{ -// dialect.MySQL: "decimal(5, 2)", -// dialect.Postgres: "numeric(5, 2)", -// }) -// -func (b *float64Builder) SchemaType(types map[string]string) *float64Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Float64("float64"). -// GoType(pkg.Float64(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *float64Builder) GoType(typ interface{}) *float64Builder { - b.desc.goType(typ, float64Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Float64("float64"). -// Annotations(entgql.OrderField("FLOAT64")) -// -func (b *float64Builder) Annotations(annotations ...schema.Annotation) *float64Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *float64Builder) Descriptor() *Descriptor { - return b.desc -} - -// float32Builder is the builder for float fields. -type float32Builder struct { - desc *Descriptor -} - -// Unique makes the field unique within all vertices of this type. -func (b *float32Builder) Unique() *float32Builder { - b.desc.Unique = true - return b -} - -// Range adds a range validator for this field where the given value needs to be in the range of [i, j]. -func (b *float32Builder) Range(i, j float32) *float32Builder { - b.desc.Validators = append(b.desc.Validators, func(v float32) error { - if v < i || v > j { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Min adds a minimum value validator for this field. Operation fails if the validator fails. -func (b *float32Builder) Min(i float32) *float32Builder { - b.desc.Validators = append(b.desc.Validators, func(v float32) error { - if v < i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Max adds a maximum value validator for this field. Operation fails if the validator fails. -func (b *float32Builder) Max(i float32) *float32Builder { - b.desc.Validators = append(b.desc.Validators, func(v float32) error { - if v > i { - return errors.New("value out of range") - } - return nil - }) - return b -} - -// Positive adds a minimum value validator with the value of 0.000001. Operation fails if the validator fails. -func (b *float32Builder) Positive() *float32Builder { - return b.Min(1e-06) -} - -// Negative adds a maximum value validator with the value of -0.000001. Operation fails if the validator fails. -func (b *float32Builder) Negative() *float32Builder { - return b.Max(-1e-06) -} - -// Default sets the default value of the field. -func (b *float32Builder) Default(i float32) *float32Builder { - b.desc.Default = i - return b -} - -// Nillable indicates that this field is a nillable. -// Unlike "Optional" only fields, "Nillable" fields are pointers in the generated struct. -func (b *float32Builder) Nillable() *float32Builder { - b.desc.Nillable = true - return b -} - -// Comment sets the comment of the field. -func (b *float32Builder) Comment(c string) *float32Builder { - b.desc.Comment = c - return b -} - -// Optional indicates that this field is optional on create. -// Unlike edges, fields are required by default. -func (b *float32Builder) Optional() *float32Builder { - b.desc.Optional = true - return b -} - -// Immutable indicates that this field cannot be updated. -func (b *float32Builder) Immutable() *float32Builder { - b.desc.Immutable = true - return b -} - -// StructTag sets the struct tag of the field. -func (b *float32Builder) StructTag(s string) *float32Builder { - b.desc.Tag = s - return b -} - -// Validate adds a validator for this field. Operation fails if the validation fails. -func (b *float32Builder) Validate(fn func(float32) error) *float32Builder { - b.desc.Validators = append(b.desc.Validators, fn) - return b -} - -// StorageKey sets the storage key of the field. -// In SQL dialects is the column name and Gremlin is the property. -func (b *float32Builder) StorageKey(key string) *float32Builder { - b.desc.StorageKey = key - return b -} - -// SchemaType overrides the default database type with a custom -// schema type (per dialect) for float32. -// -// field.Float32("amount"). -// SchemaType(map[string]string{ -// dialect.MySQL: "decimal(5, 2)", -// dialect.Postgres: "numeric(5, 2)", -// }) -// -func (b *float32Builder) SchemaType(types map[string]string) *float32Builder { - b.desc.SchemaType = types - return b -} - -// GoType overrides the default Go type with a custom one. -// -// field.Float32("float32"). -// GoType(pkg.Float32(0)) -// -// Note that, the custom Go type `T` needs to implement the -// `Add(T) T` method in order to support the `Add` operation -// in mutations. For example: -// -// func(t1 T) Add(t2 T) T { -// return add(t1, t2) -// } -// -func (b *float32Builder) GoType(typ interface{}) *float32Builder { - b.desc.goType(typ, float32Type) - return b -} - -// Annotations adds a list of annotations to the field object to be used by -// codegen extensions. -// -// field.Float32("float32"). -// Annotations(entgql.OrderField("FLOAT32")) -// -func (b *float32Builder) Annotations(annotations ...schema.Annotation) *float32Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Field interface by returning its descriptor. -func (b *float32Builder) Descriptor() *Descriptor { - return b.desc -} - -var ( - float64Type = reflect.TypeOf(float64(0)) - float32Type = reflect.TypeOf(float32(0)) -) diff --git a/vendor/entgo.io/ent/schema/field/type.go b/vendor/entgo.io/ent/schema/field/type.go deleted file mode 100644 index 15e1964b..00000000 --- a/vendor/entgo.io/ent/schema/field/type.go +++ /dev/null @@ -1,244 +0,0 @@ -// 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. - -package field - -import ( - "fmt" - "reflect" - "strings" -) - -// A Type represents a field type. -type Type uint8 - -// List of field types. -const ( - TypeInvalid Type = iota - TypeBool - TypeTime - TypeJSON - TypeUUID - TypeBytes - TypeEnum - TypeString - TypeOther - TypeInt8 - TypeInt16 - TypeInt32 - TypeInt - TypeInt64 - TypeUint8 - TypeUint16 - TypeUint32 - TypeUint - TypeUint64 - TypeFloat32 - TypeFloat64 - endTypes -) - -// String returns the string representation of a type. -func (t Type) String() string { - if t < endTypes { - return typeNames[t] - } - return typeNames[TypeInvalid] -} - -// Numeric reports if the given type is a numeric type. -func (t Type) Numeric() bool { - return t >= TypeInt8 && t < endTypes -} - -// Float reports if the given type is a float type. -func (t Type) Float() bool { - return t == TypeFloat32 || t == TypeFloat64 -} - -// Integer reports if the given type is an integral type. -func (t Type) Integer() bool { - return t.Numeric() && !t.Float() -} - -// Valid reports if the given type if known type. -func (t Type) Valid() bool { - return t > TypeInvalid && t < endTypes -} - -// ConstName returns the constant name of an info type. -// It's used by entc for printing the constant name in templates. -func (t Type) ConstName() string { - switch { - case !t.Valid(): - return typeNames[TypeInvalid] - case int(t) < len(constNames) && constNames[t] != "": - return constNames[t] - default: - return "Type" + strings.Title(typeNames[t]) - } -} - -// TypeInfo holds the information regarding field type. -// Used by complex types like JSON and Bytes. -type TypeInfo struct { - Type Type - Ident string - PkgPath string // import path. - PkgName string // local package name. - Nillable bool // slices or pointers. - RType *RType -} - -// String returns the string representation of a type. -func (t TypeInfo) String() string { - switch { - case t.Ident != "": - return t.Ident - case t.Type < endTypes: - return typeNames[t.Type] - default: - return typeNames[TypeInvalid] - } -} - -// Valid reports if the given type if known type. -func (t TypeInfo) Valid() bool { - return t.Type.Valid() -} - -// Numeric reports if the given type is a numeric type. -func (t TypeInfo) Numeric() bool { - return t.Type.Numeric() -} - -// ConstName returns the const name of the info type. -func (t TypeInfo) ConstName() string { - return t.Type.ConstName() -} - -// ValueScanner indicates if this type implements the ValueScanner interface. -func (t TypeInfo) ValueScanner() bool { - return t.RType.Implements(valueScannerType) -} - -// Valuer indicates if this type implements the driver.Valuer interface. -func (t TypeInfo) Valuer() bool { - return t.RType.Implements(valuerType) -} - -// Comparable reports whether values of this type are comparable. -func (t TypeInfo) Comparable() bool { - switch t.Type { - case TypeBool, TypeTime, TypeUUID, TypeEnum, TypeString: - return true - case TypeOther: - // Always accept custom types as comparable on the database side. - // In the future, we should consider adding an interface to let - // custom types tell if they are comparable or not (see #1304). - return true - default: - return t.Numeric() - } -} - -var stringerType = reflect.TypeOf((*fmt.Stringer)(nil)).Elem() - -// Stringer indicates if this type implements the Stringer interface. -func (t TypeInfo) Stringer() bool { - return t.RType.Implements(stringerType) -} - -var ( - typeNames = [...]string{ - TypeInvalid: "invalid", - TypeBool: "bool", - TypeTime: "time.Time", - TypeJSON: "json.RawMessage", - TypeUUID: "[16]byte", - TypeBytes: "[]byte", - TypeEnum: "string", - TypeString: "string", - TypeOther: "other", - TypeInt: "int", - TypeInt8: "int8", - TypeInt16: "int16", - TypeInt32: "int32", - TypeInt64: "int64", - TypeUint: "uint", - TypeUint8: "uint8", - TypeUint16: "uint16", - TypeUint32: "uint32", - TypeUint64: "uint64", - TypeFloat32: "float32", - TypeFloat64: "float64", - } - constNames = [...]string{ - TypeJSON: "TypeJSON", - TypeUUID: "TypeUUID", - TypeTime: "TypeTime", - TypeEnum: "TypeEnum", - TypeBytes: "TypeBytes", - TypeOther: "TypeOther", - } -) - -// RType holds a serializable reflect.Type information of -// Go object. Used by the entc package. -type RType struct { - Name string // reflect.Type.Name - Ident string // reflect.Type.String - Kind reflect.Kind - PkgPath string - Methods map[string]struct{ In, Out []*RType } - // Used only for in-package checks. - rtype reflect.Type -} - -// TypeEqual reports if the underlying type is equal to the RType (after pointer indirections). -func (r *RType) TypeEqual(t reflect.Type) bool { - tv := indirect(t) - return r.Name == tv.Name() && r.Kind == t.Kind() && r.PkgPath == tv.PkgPath() -} - -// RType returns the string value of the indirect reflect.Type. -func (r *RType) String() string { - if r.rtype != nil { - return r.rtype.String() - } - return r.Ident -} - -// IsPtr reports if the reflect-type is a pointer type. -func (r *RType) IsPtr() bool { - return r != nil && r.Kind == reflect.Ptr -} - -// Implements reports whether the RType ~implements the given interface type. -func (r *RType) Implements(typ reflect.Type) bool { - if r == nil { - return false - } - n := typ.NumMethod() - for i := 0; i < n; i++ { - m0 := typ.Method(i) - m1, ok := r.Methods[m0.Name] - if !ok || len(m1.In) != m0.Type.NumIn() || len(m1.Out) != m0.Type.NumOut() { - return false - } - in := m0.Type.NumIn() - for j := 0; j < in; j++ { - if !m1.In[j].TypeEqual(m0.Type.In(j)) { - return false - } - } - out := m0.Type.NumOut() - for j := 0; j < out; j++ { - if !m1.Out[j].TypeEqual(m0.Type.Out(j)) { - return false - } - } - } - return true -} diff --git a/vendor/entgo.io/ent/schema/index/index.go b/vendor/entgo.io/ent/schema/index/index.go deleted file mode 100644 index 23c15c6e..00000000 --- a/vendor/entgo.io/ent/schema/index/index.go +++ /dev/null @@ -1,121 +0,0 @@ -// 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. - -package index - -import "entgo.io/ent/schema" - -// A Descriptor for index configuration. -type Descriptor struct { - Unique bool // unique index. - Edges []string // edge columns. - Fields []string // field columns. - StorageKey string // custom index name. - Annotations []schema.Annotation // index annotations. -} - -// Builder for indexes on vertex columns and edges in the graph. -type Builder struct { - desc *Descriptor -} - -// Fields creates an index on the given vertex fields. -// Note that indexes are implemented only for SQL dialects, and does not support gremlin. -// -// func (T) Indexes() []ent.Index { -// -// // Unique index on 2 fields. -// index.Fields("first", "last"). -// Unique(), -// -// // Unique index of field under specific edge. -// index.Fields("name"). -// Edges("parent"). -// Unique(), -// -// } -// -func Fields(fields ...string) *Builder { - return &Builder{desc: &Descriptor{Fields: fields}} -} - -// Edges creates an index on the given vertex edge fields. -// Note that indexes are implemented only for SQL dialects, and does not support gremlin. -// -// func (T) Indexes() []ent.Index { -// -// // Unique index of field under 2 edges. -// index.Fields("name"). -// Edges("parent", "type"). -// Unique(), -// -// } -// -func Edges(edges ...string) *Builder { - return &Builder{desc: &Descriptor{Edges: edges}} -} - -// Fields sets the fields of the index. -// -// func (T) Indexes() []ent.Index { -// -// // Unique "name" and "age" fields under the "parent" edge. -// index.Edges("parent"). -// Fields("name", "age"). -// Unique(), -// -// } -func (b *Builder) Fields(fields ...string) *Builder { - b.desc.Fields = fields - return b -} - -// Edges sets the fields index to be unique under the set of edges (sub-graph). For example: -// -// func (T) Indexes() []ent.Index { -// -// // Unique "name" field under the "parent" edge. -// index.Fields("name"). -// Edges("parent"). -// Unique(), -// } -// -func (b *Builder) Edges(edges ...string) *Builder { - b.desc.Edges = edges - return b -} - -// Unique sets the index to be a unique index. -// Note that defining a uniqueness on optional fields won't prevent -// duplicates if one of the column contains NULL values. -func (b *Builder) Unique() *Builder { - b.desc.Unique = true - return b -} - -// StorageKey sets the storage key of the index. In SQL dialects, it's the index name. -func (b *Builder) StorageKey(key string) *Builder { - b.desc.StorageKey = key - return b -} - -// Annotations adds a list of annotations to the index object to be used by codegen extensions. -// -// func (T) Indexes() []ent.Index { -// -// // Partial index on name where the entity is not deleted. -// index.Fields("name"). -// Annotations(entsql.Prefix(100)) -// -// } -// -func (b *Builder) Annotations(annotations ...schema.Annotation) *Builder { - b.desc.Annotations = append(b.desc.Annotations, annotations...) - return b -} - -// Descriptor implements the ent.Descriptor interface. -func (b *Builder) Descriptor() *Descriptor { - return b.desc -} diff --git a/vendor/entgo.io/ent/schema/schema.go b/vendor/entgo.io/ent/schema/schema.go deleted file mode 100644 index d805b449..00000000 --- a/vendor/entgo.io/ent/schema/schema.go +++ /dev/null @@ -1,24 +0,0 @@ -// 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. - -package schema - -// Annotation is used to attach arbitrary metadata to the schema objects in codegen. -// The object must be serializable to JSON raw value (e.g. struct, map or slice). -// -// Template extensions can retrieve this metadata and use it inside their templates. -// Read more about it in ent website: https://entgo.io/docs/templates/#annotations. -type Annotation interface { - // Name defines the name of the annotation to be retrieved by the codegen. - Name() string -} - -// Merger wraps the single Merge function allows custom annotation to provide -// an implementation for merging 2 or more annotations from the same type. -// -// A common use case is where the same Annotation type is defined both in -// mixin.Schema and ent.Schema. -type Merger interface { - Merge(Annotation) Annotation -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 232b298d..76f97c6e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1,10 +1,3 @@ -# entgo.io/ent v0.11.1 -## explicit; go 1.17 -entgo.io/ent -entgo.io/ent/schema -entgo.io/ent/schema/edge -entgo.io/ent/schema/field -entgo.io/ent/schema/index # gitee.com/chunanyong/dm v1.8.5 ## explicit; go 1.13 gitee.com/chunanyong/dm