diff --git a/examples/auto/yesql.go b/examples/auto/yesql.go index eeac606..e138e3c 100644 --- a/examples/auto/yesql.go +++ b/examples/auto/yesql.go @@ -1,6 +1,6 @@ // Code generated by Yesql. DO NOT EDIT. // versions: -// - Yesql v1.2.0 +// - Yesql v1.4.0 package yesql @@ -21,36 +21,36 @@ const ( _UserInfoB = `SELECT ` + "`" + `username` + "`" + `, ` + "`" + `nickname` + "`" + ` FROM @user WHERE username=?` _UserInfoC = `SELECT "username" FROM @user WHERE username=?` _UserInfoD = `SELECT "username", "nickname" FROM @user WHERE username=?` - _DecrTagsById_Shutter = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)` - _HotTags_Shutter = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?` - _IncrTagsById_Shutter = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)` - _InsertTag_Shutter = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)` - _NewestTags_Shutter = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.id DESC LIMIT ? OFFSET ?` - _TagsByIdA_Shutter = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0` - _TagsByIdB_Shutter = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)` - _TagsByKeywordA_Shutter = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6` - _TagsByKeywordB_Shutter = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6` - _TagsForIncr_Shutter = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)` - _DecrTagsById_TagsInfo = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)` - _HotTags_TagsInfo = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?` - _IncrTagsById_TagsInfo = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)` - _InsertTag_TagsInfo = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)` - _NewestTags_TagsInfo = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.id DESC LIMIT ? OFFSET ?` - _TagsByIdA_TagsInfo = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0` - _TagsByIdB_TagsInfo = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)` - _TagsByKeywordA_TagsInfo = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6` - _TagsByKeywordB_TagsInfo = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6` - _TagsForIncr_TagsInfo = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)` - _DecrTagsById_Topic = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)` - _HotTags_Topic = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?` - _IncrTagsById_Topic = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)` - _InsertTag_Topic = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)` - _NewestTags_Topic = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.id DESC LIMIT ? OFFSET ?` - _TagsByIdA_Topic = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0` - _TagsByIdB_Topic = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)` - _TagsByKeywordA_Topic = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6` - _TagsByKeywordB_Topic = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6` - _TagsForIncr_Topic = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)` + _Shutter_DecrTagsById = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)` + _Shutter_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?` + _Shutter_IncrTagsById = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)` + _Shutter_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)` + _Shutter_NewestTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.id DESC LIMIT ? OFFSET ?` + _Shutter_TagsByIdA = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0` + _Shutter_TagsByIdB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)` + _Shutter_TagsByKeywordA = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6` + _Shutter_TagsByKeywordB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6` + _Shutter_TagsForIncr = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)` + _TagsInfo_DecrTagsById = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)` + _TagsInfo_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?` + _TagsInfo_IncrTagsById = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)` + _TagsInfo_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)` + _TagsInfo_NewestTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.id DESC LIMIT ? OFFSET ?` + _TagsInfo_TagsByIdA = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0` + _TagsInfo_TagsByIdB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)` + _TagsInfo_TagsByKeywordA = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6` + _TagsInfo_TagsByKeywordB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6` + _TagsInfo_TagsForIncr = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)` + _Topic_DecrTagsById = `UPDATE @tag SET quote_num=quote_num-1, modified_on=? WHERE id IN (?)` + _Topic_HotTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.quote_num DESC LIMIT ? OFFSET ?` + _Topic_IncrTagsById = `UPDATE @tag SET quote_num=quote_num+1, is_del=0, modified_on=? WHERE id IN (?)` + _Topic_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1)` + _Topic_NewestTags = `SELECT t.id id, t.user_id user_id, t.tag tag, t.quote_num quote_num, u.id, u.nickname, u.username, u.status, u.avatar, u.is_admin FROM @tag t JOIN @user u ON t.user_id = u.id WHERE t.is_del = 0 AND t.quote_num > 0 ORDER BY t.id DESC LIMIT ? OFFSET ?` + _Topic_TagsByIdA = `SELECT id FROM @tag WHERE id IN (?) AND is_del = 0 AND quote_num > 0` + _Topic_TagsByIdB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE id IN (?)` + _Topic_TagsByKeywordA = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 ORDER BY quote_num DESC LIMIT 6` + _Topic_TagsByKeywordB = `SELECT id, user_id, tag, quote_num FROM @tag WHERE is_del = 0 AND tag LIKE ? ORDER BY quote_num DESC LIMIT 6` + _Topic_TagsForIncr = `SELECT id, user_id, tag, quote_num FROM @tag WHERE tag IN (?)` ) type Yesql struct { @@ -146,25 +146,25 @@ func BuildShutter(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Shutter c = context.Background() } obj = &Shutter{ - DecrTagsById: p.QueryHook(_DecrTagsById_Shutter), - IncrTagsById: p.QueryHook(_IncrTagsById_Shutter), - TagsByIdA: p.QueryHook(_TagsByIdA_Shutter), - TagsByIdB: p.QueryHook(_TagsByIdB_Shutter), - TagsForIncr: p.QueryHook(_TagsForIncr_Shutter), + DecrTagsById: p.QueryHook(_Shutter_DecrTagsById), + IncrTagsById: p.QueryHook(_Shutter_IncrTagsById), + TagsByIdA: p.QueryHook(_Shutter_TagsByIdA), + TagsByIdB: p.QueryHook(_Shutter_TagsByIdB), + TagsForIncr: p.QueryHook(_Shutter_TagsForIncr), } - if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_HotTags_Shutter))); err != nil { + if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Shutter_HotTags))); err != nil { return } - if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsByKeywordA_Shutter))); err != nil { + if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Shutter_TagsByKeywordA))); err != nil { return } - if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsByKeywordB_Shutter))); err != nil { + if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Shutter_TagsByKeywordB))); err != nil { return } - if obj.InsertTag, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_InsertTag_Shutter))); err != nil { + if obj.InsertTag, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Shutter_InsertTag))); err != nil { return } - if obj.NewestTags, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_NewestTags_Shutter))); err != nil { + if obj.NewestTags, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Shutter_NewestTags))); err != nil { return } return @@ -178,25 +178,25 @@ func BuildTagsInfo(p yesql.PreparexBuilder, ctx ...context.Context) (obj *TagsIn c = context.Background() } obj = &TagsInfo{ - DecrTagsById: p.QueryHook(_DecrTagsById_TagsInfo), - IncrTagsById: p.QueryHook(_IncrTagsById_TagsInfo), - TagsByIdA: p.QueryHook(_TagsByIdA_TagsInfo), - TagsByIdB: p.QueryHook(_TagsByIdB_TagsInfo), - TagsForIncr: p.QueryHook(_TagsForIncr_TagsInfo), + DecrTagsById: p.QueryHook(_TagsInfo_DecrTagsById), + IncrTagsById: p.QueryHook(_TagsInfo_IncrTagsById), + TagsByIdA: p.QueryHook(_TagsInfo_TagsByIdA), + TagsByIdB: p.QueryHook(_TagsInfo_TagsByIdB), + TagsForIncr: p.QueryHook(_TagsInfo_TagsForIncr), } - if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_HotTags_TagsInfo))); err != nil { + if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsInfo_HotTags))); err != nil { return } - if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsByKeywordA_TagsInfo))); err != nil { + if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsInfo_TagsByKeywordA))); err != nil { return } - if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsByKeywordB_TagsInfo))); err != nil { + if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsInfo_TagsByKeywordB))); err != nil { return } - if obj.InsertTag, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_InsertTag_TagsInfo))); err != nil { + if obj.InsertTag, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_TagsInfo_InsertTag))); err != nil { return } - if obj.NewestTags, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_NewestTags_TagsInfo))); err != nil { + if obj.NewestTags, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_TagsInfo_NewestTags))); err != nil { return } return @@ -210,25 +210,25 @@ func BuildTopic(p yesql.PreparexBuilder, ctx ...context.Context) (obj *Topic, er c = context.Background() } obj = &Topic{ - DecrTagsById: p.QueryHook(_DecrTagsById_Topic), - IncrTagsById: p.QueryHook(_IncrTagsById_Topic), - TagsByIdA: p.QueryHook(_TagsByIdA_Topic), - TagsByIdB: p.QueryHook(_TagsByIdB_Topic), - TagsForIncr: p.QueryHook(_TagsForIncr_Topic), + DecrTagsById: p.QueryHook(_Topic_DecrTagsById), + IncrTagsById: p.QueryHook(_Topic_IncrTagsById), + TagsByIdA: p.QueryHook(_Topic_TagsByIdA), + TagsByIdB: p.QueryHook(_Topic_TagsByIdB), + TagsForIncr: p.QueryHook(_Topic_TagsForIncr), } - if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_HotTags_Topic))); err != nil { + if obj.HotTags, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Topic_HotTags))); err != nil { return } - if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsByKeywordA_Topic))); err != nil { + if obj.TagsByKeywordA, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Topic_TagsByKeywordA))); err != nil { return } - if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TagsByKeywordB_Topic))); err != nil { + if obj.TagsByKeywordB, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_Topic_TagsByKeywordB))); err != nil { return } - if obj.InsertTag, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_InsertTag_Topic))); err != nil { + if obj.InsertTag, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Topic_InsertTag))); err != nil { return } - if obj.NewestTags, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_NewestTags_Topic))); err != nil { + if obj.NewestTags, err = p.PrepareNamedContext(c, p.Rebind(p.QueryHook(_Topic_NewestTags))); err != nil { return } return diff --git a/examples/go.mod b/examples/go.mod index 2ba2801..f4c394a 100644 --- a/examples/go.mod +++ b/examples/go.mod @@ -3,6 +3,6 @@ module github.com/alimy/yesql/examples go 1.18 require ( - github.com/alimy/yesql v1.2.0 + github.com/alimy/yesql v1.4.0 github.com/jmoiron/sqlx v1.3.5 ) diff --git a/examples/go.sum b/examples/go.sum index 1b6ab5b..7c810bd 100644 --- a/examples/go.sum +++ b/examples/go.sum @@ -1,5 +1,5 @@ -github.com/alimy/yesql v1.2.0 h1:yWa4kYk/7E2iYtS/4xvjlKQvGsfRhAHqr58s5Sig33A= -github.com/alimy/yesql v1.2.0/go.mod h1:Y0FdRIwIbJyTv56wSX+MpaIHiAW1PyKTDYO6K/er4JY= +github.com/alimy/yesql v1.4.0 h1:8q5PgUnLR1u9vi5Y9cLj1/cuie2I/4ShpCOp2jE1V6A= +github.com/alimy/yesql v1.4.0/go.mod h1:Y0FdRIwIbJyTv56wSX+MpaIHiAW1PyKTDYO6K/er4JY= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/jmoiron/sqlx v1.3.5 h1:vFFPA71p1o5gAeqtEAwLU4dnX2napprKtHr7PYIcN3g=