This commit is contained in:
parent
2b59dca9a6
commit
c73decb38a
12
go.mod
12
go.mod
@ -1,6 +1,6 @@
|
|||||||
module git.paulbsd.com/paulbsd/qrz
|
module git.paulbsd.com/paulbsd/qrz
|
||||||
|
|
||||||
go 1.20
|
go 1.21
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/antchfx/htmlquery v1.3.0
|
github.com/antchfx/htmlquery v1.3.0
|
||||||
@ -13,13 +13,13 @@ require (
|
|||||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||||
github.com/onsi/gomega v1.23.0 // indirect
|
github.com/onsi/gomega v1.23.0 // indirect
|
||||||
github.com/robfig/cron v1.2.0
|
github.com/robfig/cron v1.2.0
|
||||||
golang.org/x/crypto v0.12.0 // indirect
|
golang.org/x/crypto v0.13.0 // indirect
|
||||||
golang.org/x/net v0.14.0
|
golang.org/x/net v0.15.0
|
||||||
golang.org/x/sys v0.11.0 // indirect
|
golang.org/x/sys v0.12.0 // indirect
|
||||||
golang.org/x/text v0.12.0 // indirect
|
golang.org/x/text v0.13.0 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0
|
gopkg.in/ini.v1 v1.67.0
|
||||||
xorm.io/builder v0.3.13 // indirect
|
xorm.io/builder v0.3.13 // indirect
|
||||||
xorm.io/xorm v1.3.2
|
xorm.io/xorm v1.3.3
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
83
go.sum
83
go.sum
@ -3,6 +3,9 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
|||||||
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
|
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=
|
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
|
||||||
gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE=
|
gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0=
|
||||||
|
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||||
@ -36,6 +39,9 @@ github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n
|
|||||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY=
|
||||||
|
github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic=
|
||||||
|
github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||||
@ -52,7 +58,9 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
|
|||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||||
|
github.com/denisenkom/go-mssqldb v0.12.3/go.mod h1:k0mtMFOnU+AihqFxPMiF05rtiDrorD1Vrm1KEz5hxDo=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
|
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||||
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||||
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
|
||||||
@ -72,12 +80,14 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
|
|||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o=
|
||||||
|
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
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/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||||
github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.8.1/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||||
@ -92,6 +102,7 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a
|
|||||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||||
|
github.com/golang-sql/sqlexp v0.1.0/go.mod h1:J4ad9Vo8ZCWQ2GMrC4UCQy1JpCbwU9m3EOqtpKwwwHI=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
@ -119,7 +130,9 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
|
|||||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
|
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo=
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
@ -154,6 +167,7 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
|
|||||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||||
|
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||||
@ -168,9 +182,12 @@ github.com/jackc/pgconn v1.5.1-0.20200601181101-fa742c524853/go.mod h1:QeD3lBfpT
|
|||||||
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
||||||
github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g=
|
github.com/jackc/pgconn v1.8.1/go.mod h1:JV6m6b6jhjdmzchES0drzCcYcAHS1OPD5xu3OZ/lE2g=
|
||||||
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
||||||
|
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
|
||||||
|
github.com/jackc/pgconn v1.14.0/go.mod h1:9mBNlny0UvkgJdCDvdVHYSjI+8tD2rnKK69Wz8ti++E=
|
||||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
||||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
||||||
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
|
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
|
||||||
|
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
||||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||||
@ -180,8 +197,10 @@ github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:
|
|||||||
github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
github.com/jackc/pgproto3/v2 v2.0.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
|
github.com/jackc/pgproto3/v2 v2.3.2/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
github.com/jackc/pgservicefile v0.0.0-20200307190119-3430c5407db8/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||||
|
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||||
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
||||||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||||
@ -190,6 +209,8 @@ github.com/jackc/pgtype v1.3.1-0.20200510190516-8cd94a14c75a/go.mod h1:vaogEUkAL
|
|||||||
github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ=
|
github.com/jackc/pgtype v1.3.1-0.20200606141011-f6355165a91c/go.mod h1:cvk9Bgu/VzJ9/lxTO5R5sf80p0DiucVtN7ZxvaC4GmQ=
|
||||||
github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE=
|
github.com/jackc/pgtype v1.7.0/go.mod h1:ZnHF+rMePVqDKaOfJVI4Q8IVvAQMryDlDkZnKOI75BE=
|
||||||
github.com/jackc/pgtype v1.8.0/go.mod h1:PqDKcEBtllAtk/2p6z6SHdXW5UB+MhE75tUol2OKexE=
|
github.com/jackc/pgtype v1.8.0/go.mod h1:PqDKcEBtllAtk/2p6z6SHdXW5UB+MhE75tUol2OKexE=
|
||||||
|
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
|
||||||
|
github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
||||||
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
||||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||||
@ -198,11 +219,14 @@ github.com/jackc/pgx/v4 v4.6.1-0.20200510190926-94ba730bb1e9/go.mod h1:t3/cdRQl6
|
|||||||
github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
|
github.com/jackc/pgx/v4 v4.6.1-0.20200606145419-4e5062306904/go.mod h1:ZDaNWkt9sW1JMiNn0kdYBaLelIhw7Pg4qd+Vk6tw7Hg=
|
||||||
github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc=
|
github.com/jackc/pgx/v4 v4.11.0/go.mod h1:i62xJgdrtVDsnL3U8ekyrQXEwGNTRoG7/8r+CIdYfcc=
|
||||||
github.com/jackc/pgx/v4 v4.12.0/go.mod h1:fE547h6VulLPA3kySjfnSG/e2D861g/50JlVUa/ub60=
|
github.com/jackc/pgx/v4 v4.12.0/go.mod h1:fE547h6VulLPA3kySjfnSG/e2D861g/50JlVUa/ub60=
|
||||||
|
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
||||||
|
github.com/jackc/pgx/v4 v4.18.0/go.mod h1:FydWkUyadDmdNH/mHnGob881GawxeEm7TcMCzkb+qQE=
|
||||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
|
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
||||||
@ -265,6 +289,8 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP
|
|||||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||||
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
|
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible h1:gXHsfypPkaMZrKbD5209QV9jbUTJKjyR5WD3HYQSd+U=
|
||||||
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
github.com/mattn/go-sqlite3 v2.0.3+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||||
@ -283,6 +309,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN
|
|||||||
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
|
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
|
||||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||||
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg=
|
||||||
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU=
|
||||||
@ -322,6 +349,7 @@ github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP
|
|||||||
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
|
||||||
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
|
||||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||||
|
github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA=
|
||||||
@ -362,6 +390,7 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
|
|||||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||||
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
|
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||||
@ -378,12 +407,17 @@ github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5J
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE=
|
||||||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
|
||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||||
@ -427,10 +461,14 @@ golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||||
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
|
||||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||||
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
||||||
@ -439,6 +477,8 @@ golang.org/x/crypto v0.10.0 h1:LKqV2xt9+kDzSTfOhx4FrkEBcMrAgHSYgzywV9zcGmM=
|
|||||||
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
|
golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I=
|
||||||
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk=
|
||||||
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
||||||
|
golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck=
|
||||||
|
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
@ -469,8 +509,11 @@ golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLL
|
|||||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||||
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||||
@ -479,6 +522,8 @@ golang.org/x/net v0.11.0 h1:Gi2tvZIJyBtO9SDr1q9h5hEQCp/4L2RQ+ar0qjx2oNU=
|
|||||||
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
|
golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ=
|
||||||
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14=
|
||||||
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
||||||
|
golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8=
|
||||||
|
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@ -518,16 +563,19 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20211103235746-7861aae1554b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
|
||||||
@ -536,10 +584,13 @@ golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
|
|||||||
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
|
||||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
|
||||||
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
||||||
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
@ -547,6 +598,7 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||||
@ -555,6 +607,8 @@ golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58=
|
|||||||
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc=
|
||||||
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
@ -625,16 +679,20 @@ gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bl
|
|||||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
|
lukechampine.com/uint128 v1.1.1 h1:pnxCASz787iMf+02ssImqk6OLt+Z5QHMoZyUXR4z6JU=
|
||||||
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
|
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
|
||||||
|
lukechampine.com/uint128 v1.2.0/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
|
||||||
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
modernc.org/cc/v3 v3.33.6/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
modernc.org/cc/v3 v3.33.9/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
modernc.org/cc/v3 v3.33.11/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
@ -650,6 +708,11 @@ modernc.org/cc/v3 v3.35.16/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g
|
|||||||
modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
modernc.org/cc/v3 v3.35.17/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
modernc.org/cc/v3 v3.35.18 h1:rMZhRcWrba0y3nVmdiQ7kxAgOOSq2m2f2VzjHLgEs6U=
|
modernc.org/cc/v3 v3.35.18 h1:rMZhRcWrba0y3nVmdiQ7kxAgOOSq2m2f2VzjHLgEs6U=
|
||||||
modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
modernc.org/cc/v3 v3.35.18/go.mod h1:iPJg1pkwXqAV16SNgFBVYmggfMg6xhs+2oiO0vclK3g=
|
||||||
|
modernc.org/cc/v3 v3.37.0/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20=
|
||||||
|
modernc.org/cc/v3 v3.38.1/go.mod h1:vtL+3mdHx/wcj3iEGz84rQa8vEqR6XM84v5Lcvfph20=
|
||||||
|
modernc.org/cc/v3 v3.40.0/go.mod h1:/bTg4dnWkSXowUO6ssQKnOV0yMVxDYNIsIrzqTFDGH0=
|
||||||
|
modernc.org/ccgo/v3 v3.0.0-20220904174949-82d86e1b6d56/go.mod h1:YSXjPL62P2AMSxBphRHPn7IkzhVHqkvOnRKAKh+W6ZI=
|
||||||
|
modernc.org/ccgo/v3 v3.0.0-20220910160915-348f15de615a/go.mod h1:8p47QxPkdugex9J4n9P2tLZ9bK01yngIVp00g4nomW0=
|
||||||
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
|
modernc.org/ccgo/v3 v3.9.5/go.mod h1:umuo2EP2oDSBnD3ckjaVUXMrmeAw8C8OSICVa0iFf60=
|
||||||
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
|
modernc.org/ccgo/v3 v3.10.0/go.mod h1:c0yBmkRFi7uW4J7fwx/JiijwOjeAeR2NoSaRVFPmjMw=
|
||||||
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
|
modernc.org/ccgo/v3 v3.11.0/go.mod h1:dGNposbDp9TOZ/1KBxghxtUp/bzErD0/0QW4hhSaBMI=
|
||||||
@ -686,7 +749,10 @@ modernc.org/ccgo/v3 v3.12.73/go.mod h1:hngkB+nUUqzOf3iqsM48Gf1FZhY599qzVg1iX+BT3
|
|||||||
modernc.org/ccgo/v3 v3.12.81/go.mod h1:p2A1duHoBBg1mFtYvnhAnQyI6vL0uw5PGYLSIgF6rYY=
|
modernc.org/ccgo/v3 v3.12.81/go.mod h1:p2A1duHoBBg1mFtYvnhAnQyI6vL0uw5PGYLSIgF6rYY=
|
||||||
modernc.org/ccgo/v3 v3.12.82 h1:wudcnJyjLj1aQQCXF3IM9Gz2X6UNjw+afIghzdtn0v8=
|
modernc.org/ccgo/v3 v3.12.82 h1:wudcnJyjLj1aQQCXF3IM9Gz2X6UNjw+afIghzdtn0v8=
|
||||||
modernc.org/ccgo/v3 v3.12.82/go.mod h1:ApbflUfa5BKadjHynCficldU1ghjen84tuM5jRynB7w=
|
modernc.org/ccgo/v3 v3.12.82/go.mod h1:ApbflUfa5BKadjHynCficldU1ghjen84tuM5jRynB7w=
|
||||||
|
modernc.org/ccgo/v3 v3.16.13-0.20221017192402-261537637ce8/go.mod h1:fUB3Vn0nVPReA+7IG7yZDfjv1TMWjhQP8gCxrFAtL5g=
|
||||||
|
modernc.org/ccgo/v3 v3.16.13/go.mod h1:2Quk+5YgpImhPjv2Qsob1DnZ/4som1lJTodubIcoUkY=
|
||||||
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
modernc.org/ccorpus v1.11.1/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||||
|
modernc.org/ccorpus v1.11.6/go.mod h1:2gEUTrWqdpH2pXsmTM1ZkjeSrUWDpjMu2T6m29L/ErQ=
|
||||||
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
|
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
|
||||||
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
|
modernc.org/libc v1.9.8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
|
||||||
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
|
modernc.org/libc v1.9.11/go.mod h1:NyF3tsA5ArIjJ83XB0JlqhjTabTCHm9aX4XMPHyQn0Q=
|
||||||
@ -724,24 +790,39 @@ modernc.org/libc v1.11.82/go.mod h1:NF+Ek1BOl2jeC7lw3a7Jj5PWyHPwWD4aq3wVKxqV1fI=
|
|||||||
modernc.org/libc v1.11.86/go.mod h1:ePuYgoQLmvxdNT06RpGnaDKJmDNEkV7ZPKI2jnsvZoE=
|
modernc.org/libc v1.11.86/go.mod h1:ePuYgoQLmvxdNT06RpGnaDKJmDNEkV7ZPKI2jnsvZoE=
|
||||||
modernc.org/libc v1.11.87 h1:PzIzOqtlzMDDcCzJ5cUP6h/Ku6Fa9iyflP2ccTY64aE=
|
modernc.org/libc v1.11.87 h1:PzIzOqtlzMDDcCzJ5cUP6h/Ku6Fa9iyflP2ccTY64aE=
|
||||||
modernc.org/libc v1.11.87/go.mod h1:Qvd5iXTeLhI5PS0XSyqMY99282y+3euapQFxM7jYnpY=
|
modernc.org/libc v1.11.87/go.mod h1:Qvd5iXTeLhI5PS0XSyqMY99282y+3euapQFxM7jYnpY=
|
||||||
|
modernc.org/libc v1.17.4/go.mod h1:WNg2ZH56rDEwdropAJeZPQkXmDwh+JCA1s/htl6r2fA=
|
||||||
|
modernc.org/libc v1.18.0/go.mod h1:vj6zehR5bfc98ipowQOM2nIDUZnVew/wNC/2tOGS+q0=
|
||||||
|
modernc.org/libc v1.19.0/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
|
||||||
|
modernc.org/libc v1.20.3/go.mod h1:ZRfIaEkgrYgZDl6pa4W39HgN5G/yDW+NRmNKZBDFrk0=
|
||||||
|
modernc.org/libc v1.21.4/go.mod h1:przBsL5RDOZajTVslkugzLBj1evTue36jEomFQOoYuI=
|
||||||
|
modernc.org/libc v1.22.2/go.mod h1:uvQavJ1pZ0hIoC/jfqNoMLURIMhKzINIWypNM17puug=
|
||||||
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
modernc.org/mathutil v1.4.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8=
|
modernc.org/mathutil v1.4.1 h1:ij3fYGe8zBF4Vu+g0oT7mB06r8sqGWKuJu1yXeR4by8=
|
||||||
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
modernc.org/mathutil v1.4.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
|
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||||
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
|
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
|
||||||
modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14=
|
modernc.org/memory v1.0.5 h1:XRch8trV7GgvTec2i7jc33YlUI0RKVDBvZ5eZ5m8y14=
|
||||||
modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM=
|
modernc.org/memory v1.0.5/go.mod h1:B7OYswTRnfGg+4tDH1t1OeUNnsy2viGTdME4tzd+IjM=
|
||||||
|
modernc.org/memory v1.3.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
|
||||||
|
modernc.org/memory v1.4.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
|
||||||
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
|
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
|
||||||
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||||
|
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
|
||||||
modernc.org/sqlite v1.14.2 h1:ohsW2+e+Qe2To1W6GNezzKGwjXwSax6R+CrhRxVaFbE=
|
modernc.org/sqlite v1.14.2 h1:ohsW2+e+Qe2To1W6GNezzKGwjXwSax6R+CrhRxVaFbE=
|
||||||
modernc.org/sqlite v1.14.2/go.mod h1:yqfn85u8wVOE6ub5UT8VI9JjhrwBUUCNyTACN0h6Sx8=
|
modernc.org/sqlite v1.14.2/go.mod h1:yqfn85u8wVOE6ub5UT8VI9JjhrwBUUCNyTACN0h6Sx8=
|
||||||
|
modernc.org/sqlite v1.20.4/go.mod h1:zKcGyrICaxNTMEHSr1HQ2GUraP0j+845GYw37+EyT6A=
|
||||||
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
|
modernc.org/strutil v1.1.1 h1:xv+J1BXY3Opl2ALrBwyfEikFAj8pmqcpnfmuwUwcozs=
|
||||||
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
|
modernc.org/strutil v1.1.1/go.mod h1:DE+MQQ/hjKBZS2zNInV5hhcipt5rLPWkmpbGeW5mmdw=
|
||||||
|
modernc.org/strutil v1.1.3/go.mod h1:MEHNA7PdEnEwLvspRMtWTNnp2nnyvMfkimT1NKNAGbw=
|
||||||
modernc.org/tcl v1.8.13/go.mod h1:V+q/Ef0IJaNUSECieLU4o+8IScapxnMyFV6i/7uQlAY=
|
modernc.org/tcl v1.8.13/go.mod h1:V+q/Ef0IJaNUSECieLU4o+8IScapxnMyFV6i/7uQlAY=
|
||||||
|
modernc.org/tcl v1.15.0/go.mod h1:xRoGotBZ6dU+Zo2tca+2EqVEeMmOUBzHnhIwq4YrVnE=
|
||||||
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
|
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
|
||||||
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
|
modernc.org/token v1.0.1/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||||
modernc.org/z v1.2.19/go.mod h1:+ZpP0pc4zz97eukOzW3xagV/lS82IpPN9NGG5pNF9vY=
|
modernc.org/z v1.2.19/go.mod h1:+ZpP0pc4zz97eukOzW3xagV/lS82IpPN9NGG5pNF9vY=
|
||||||
|
modernc.org/z v1.7.0/go.mod h1:hVdgNMh8ggTuRG1rGU8x+xGRFfiQUIAw0ZqlPy8+HyQ=
|
||||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||||
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
|
||||||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
||||||
@ -751,3 +832,5 @@ xorm.io/builder v0.3.13 h1:a3jmiVVL19psGeXx8GIurTp7p0IIgqeDmwhcR6BAOAo=
|
|||||||
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
xorm.io/builder v0.3.13/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
|
||||||
xorm.io/xorm v1.3.2 h1:uTRRKF2jYzbZ5nsofXVUx6ncMaek+SHjWYtCXyZo1oM=
|
xorm.io/xorm v1.3.2 h1:uTRRKF2jYzbZ5nsofXVUx6ncMaek+SHjWYtCXyZo1oM=
|
||||||
xorm.io/xorm v1.3.2/go.mod h1:9NbjqdnjX6eyjRRhh01GHm64r6N9shTb/8Ak3YRt8Nw=
|
xorm.io/xorm v1.3.2/go.mod h1:9NbjqdnjX6eyjRRhh01GHm64r6N9shTb/8Ak3YRt8Nw=
|
||||||
|
xorm.io/xorm v1.3.3 h1:L5/GOhvgMcwJYYRjzPf3lTTTf6JcaTd1Mb9A/Iqvccw=
|
||||||
|
xorm.io/xorm v1.3.3/go.mod h1:qFJGFoVYbbIdnz2vaL5OxSQ2raleMpyRRalnq3n9OJo=
|
||||||
|
51
vendor/golang.org/x/net/http2/Dockerfile
generated
vendored
51
vendor/golang.org/x/net/http2/Dockerfile
generated
vendored
@ -1,51 +0,0 @@
|
|||||||
#
|
|
||||||
# This Dockerfile builds a recent curl with HTTP/2 client support, using
|
|
||||||
# a recent nghttp2 build.
|
|
||||||
#
|
|
||||||
# See the Makefile for how to tag it. If Docker and that image is found, the
|
|
||||||
# Go tests use this curl binary for integration tests.
|
|
||||||
#
|
|
||||||
|
|
||||||
FROM ubuntu:trusty
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get upgrade -y && \
|
|
||||||
apt-get install -y git-core build-essential wget
|
|
||||||
|
|
||||||
RUN apt-get install -y --no-install-recommends \
|
|
||||||
autotools-dev libtool pkg-config zlib1g-dev \
|
|
||||||
libcunit1-dev libssl-dev libxml2-dev libevent-dev \
|
|
||||||
automake autoconf
|
|
||||||
|
|
||||||
# The list of packages nghttp2 recommends for h2load:
|
|
||||||
RUN apt-get install -y --no-install-recommends make binutils \
|
|
||||||
autoconf automake autotools-dev \
|
|
||||||
libtool pkg-config zlib1g-dev libcunit1-dev libssl-dev libxml2-dev \
|
|
||||||
libev-dev libevent-dev libjansson-dev libjemalloc-dev \
|
|
||||||
cython python3.4-dev python-setuptools
|
|
||||||
|
|
||||||
# Note: setting NGHTTP2_VER before the git clone, so an old git clone isn't cached:
|
|
||||||
ENV NGHTTP2_VER 895da9a
|
|
||||||
RUN cd /root && git clone https://github.com/tatsuhiro-t/nghttp2.git
|
|
||||||
|
|
||||||
WORKDIR /root/nghttp2
|
|
||||||
RUN git reset --hard $NGHTTP2_VER
|
|
||||||
RUN autoreconf -i
|
|
||||||
RUN automake
|
|
||||||
RUN autoconf
|
|
||||||
RUN ./configure
|
|
||||||
RUN make
|
|
||||||
RUN make install
|
|
||||||
|
|
||||||
WORKDIR /root
|
|
||||||
RUN wget https://curl.se/download/curl-7.45.0.tar.gz
|
|
||||||
RUN tar -zxvf curl-7.45.0.tar.gz
|
|
||||||
WORKDIR /root/curl-7.45.0
|
|
||||||
RUN ./configure --with-ssl --with-nghttp2=/usr/local
|
|
||||||
RUN make
|
|
||||||
RUN make install
|
|
||||||
RUN ldconfig
|
|
||||||
|
|
||||||
CMD ["-h"]
|
|
||||||
ENTRYPOINT ["/usr/local/bin/curl"]
|
|
||||||
|
|
3
vendor/golang.org/x/net/http2/Makefile
generated
vendored
3
vendor/golang.org/x/net/http2/Makefile
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
curlimage:
|
|
||||||
docker build -t gohttp2/curl .
|
|
||||||
|
|
8
vendor/golang.org/x/net/http2/server.go
generated
vendored
8
vendor/golang.org/x/net/http2/server.go
generated
vendored
@ -1012,14 +1012,6 @@ func (sc *serverConn) serve() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sc *serverConn) awaitGracefulShutdown(sharedCh <-chan struct{}, privateCh chan struct{}) {
|
|
||||||
select {
|
|
||||||
case <-sc.doneServing:
|
|
||||||
case <-sharedCh:
|
|
||||||
close(privateCh)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type serverMessage int
|
type serverMessage int
|
||||||
|
|
||||||
// Message values sent to serveMsgCh.
|
// Message values sent to serveMsgCh.
|
||||||
|
3
vendor/golang.org/x/net/http2/transport.go
generated
vendored
3
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@ -291,8 +291,7 @@ func (t *Transport) initConnPool() {
|
|||||||
// HTTP/2 server.
|
// HTTP/2 server.
|
||||||
type ClientConn struct {
|
type ClientConn struct {
|
||||||
t *Transport
|
t *Transport
|
||||||
tconn net.Conn // usually *tls.Conn, except specialized impls
|
tconn net.Conn // usually *tls.Conn, except specialized impls
|
||||||
tconnClosed bool
|
|
||||||
tlsState *tls.ConnectionState // nil only for specialized impls
|
tlsState *tls.ConnectionState // nil only for specialized impls
|
||||||
reused uint32 // whether conn is being reused; atomic
|
reused uint32 // whether conn is being reused; atomic
|
||||||
singleUse bool // whether being used for a single http.Request
|
singleUse bool // whether being used for a single http.Request
|
||||||
|
1
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
1
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@ -583,6 +583,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^PERF_/ ||
|
$2 ~ /^PERF_/ ||
|
||||||
$2 ~ /^SECCOMP_MODE_/ ||
|
$2 ~ /^SECCOMP_MODE_/ ||
|
||||||
$2 ~ /^SEEK_/ ||
|
$2 ~ /^SEEK_/ ||
|
||||||
|
$2 ~ /^SCHED_/ ||
|
||||||
$2 ~ /^SPLICE_/ ||
|
$2 ~ /^SPLICE_/ ||
|
||||||
$2 ~ /^SYNC_FILE_RANGE_/ ||
|
$2 ~ /^SYNC_FILE_RANGE_/ ||
|
||||||
$2 !~ /IOC_MAGIC/ &&
|
$2 !~ /IOC_MAGIC/ &&
|
||||||
|
23
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
23
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
@ -2471,6 +2471,29 @@ func Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *
|
|||||||
return pselect6(nfd, r, w, e, mutableTimeout, kernelMask)
|
return pselect6(nfd, r, w, e, mutableTimeout, kernelMask)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys schedSetattr(pid int, attr *SchedAttr, flags uint) (err error)
|
||||||
|
//sys schedGetattr(pid int, attr *SchedAttr, size uint, flags uint) (err error)
|
||||||
|
|
||||||
|
// SchedSetAttr is a wrapper for sched_setattr(2) syscall.
|
||||||
|
// https://man7.org/linux/man-pages/man2/sched_setattr.2.html
|
||||||
|
func SchedSetAttr(pid int, attr *SchedAttr, flags uint) error {
|
||||||
|
if attr == nil {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
attr.Size = SizeofSchedAttr
|
||||||
|
return schedSetattr(pid, attr, flags)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SchedGetAttr is a wrapper for sched_getattr(2) syscall.
|
||||||
|
// https://man7.org/linux/man-pages/man2/sched_getattr.2.html
|
||||||
|
func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
|
||||||
|
attr := &SchedAttr{}
|
||||||
|
if err := schedGetattr(pid, attr, SizeofSchedAttr, flags); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return attr, nil
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Unimplemented
|
* Unimplemented
|
||||||
*/
|
*/
|
||||||
|
3
vendor/golang.org/x/sys/unix/syscall_unix.go
generated
vendored
3
vendor/golang.org/x/sys/unix/syscall_unix.go
generated
vendored
@ -549,6 +549,9 @@ func SetNonblock(fd int, nonblocking bool) (err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if (flag&O_NONBLOCK != 0) == nonblocking {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if nonblocking {
|
if nonblocking {
|
||||||
flag |= O_NONBLOCK
|
flag |= O_NONBLOCK
|
||||||
} else {
|
} else {
|
||||||
|
17
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
17
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
@ -2821,6 +2821,23 @@ const (
|
|||||||
RWF_SUPPORTED = 0x1f
|
RWF_SUPPORTED = 0x1f
|
||||||
RWF_SYNC = 0x4
|
RWF_SYNC = 0x4
|
||||||
RWF_WRITE_LIFE_NOT_SET = 0x0
|
RWF_WRITE_LIFE_NOT_SET = 0x0
|
||||||
|
SCHED_BATCH = 0x3
|
||||||
|
SCHED_DEADLINE = 0x6
|
||||||
|
SCHED_FIFO = 0x1
|
||||||
|
SCHED_FLAG_ALL = 0x7f
|
||||||
|
SCHED_FLAG_DL_OVERRUN = 0x4
|
||||||
|
SCHED_FLAG_KEEP_ALL = 0x18
|
||||||
|
SCHED_FLAG_KEEP_PARAMS = 0x10
|
||||||
|
SCHED_FLAG_KEEP_POLICY = 0x8
|
||||||
|
SCHED_FLAG_RECLAIM = 0x2
|
||||||
|
SCHED_FLAG_RESET_ON_FORK = 0x1
|
||||||
|
SCHED_FLAG_UTIL_CLAMP = 0x60
|
||||||
|
SCHED_FLAG_UTIL_CLAMP_MAX = 0x40
|
||||||
|
SCHED_FLAG_UTIL_CLAMP_MIN = 0x20
|
||||||
|
SCHED_IDLE = 0x5
|
||||||
|
SCHED_NORMAL = 0x0
|
||||||
|
SCHED_RESET_ON_FORK = 0x40000000
|
||||||
|
SCHED_RR = 0x2
|
||||||
SCM_CREDENTIALS = 0x2
|
SCM_CREDENTIALS = 0x2
|
||||||
SCM_RIGHTS = 0x1
|
SCM_RIGHTS = 0x1
|
||||||
SCM_TIMESTAMP = 0x1d
|
SCM_TIMESTAMP = 0x1d
|
||||||
|
20
vendor/golang.org/x/sys/unix/zsyscall_linux.go
generated
vendored
20
vendor/golang.org/x/sys/unix/zsyscall_linux.go
generated
vendored
@ -2197,3 +2197,23 @@ func getresgid(rgid *_C_int, egid *_C_int, sgid *_C_int) {
|
|||||||
RawSyscallNoError(SYS_GETRESGID, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid)))
|
RawSyscallNoError(SYS_GETRESGID, uintptr(unsafe.Pointer(rgid)), uintptr(unsafe.Pointer(egid)), uintptr(unsafe.Pointer(sgid)))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func schedSetattr(pid int, attr *SchedAttr, flags uint) (err error) {
|
||||||
|
_, _, e1 := Syscall(SYS_SCHED_SETATTR, uintptr(pid), uintptr(unsafe.Pointer(attr)), uintptr(flags))
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
|
func schedGetattr(pid int, attr *SchedAttr, size uint, flags uint) (err error) {
|
||||||
|
_, _, e1 := Syscall6(SYS_SCHED_GETATTR, uintptr(pid), uintptr(unsafe.Pointer(attr)), uintptr(size), uintptr(flags), 0, 0)
|
||||||
|
if e1 != 0 {
|
||||||
|
err = errnoErr(e1)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
15
vendor/golang.org/x/sys/unix/ztypes_linux.go
generated
vendored
15
vendor/golang.org/x/sys/unix/ztypes_linux.go
generated
vendored
@ -5868,3 +5868,18 @@ const (
|
|||||||
VIRTIO_NET_HDR_GSO_UDP_L4 = 0x5
|
VIRTIO_NET_HDR_GSO_UDP_L4 = 0x5
|
||||||
VIRTIO_NET_HDR_GSO_ECN = 0x80
|
VIRTIO_NET_HDR_GSO_ECN = 0x80
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type SchedAttr struct {
|
||||||
|
Size uint32
|
||||||
|
Policy uint32
|
||||||
|
Flags uint64
|
||||||
|
Nice int32
|
||||||
|
Priority uint32
|
||||||
|
Runtime uint64
|
||||||
|
Deadline uint64
|
||||||
|
Period uint64
|
||||||
|
Util_min uint32
|
||||||
|
Util_max uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
const SizeofSchedAttr = 0x38
|
||||||
|
2
vendor/golang.org/x/text/unicode/norm/trie.go
generated
vendored
2
vendor/golang.org/x/text/unicode/norm/trie.go
generated
vendored
@ -29,7 +29,7 @@ var (
|
|||||||
nfkcData = newNfkcTrie(0)
|
nfkcData = newNfkcTrie(0)
|
||||||
)
|
)
|
||||||
|
|
||||||
// lookupValue determines the type of block n and looks up the value for b.
|
// lookup determines the type of block n and looks up the value for b.
|
||||||
// For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
|
// For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
|
||||||
// is a list of ranges with an accompanying value. Given a matching range r,
|
// is a list of ranges with an accompanying value. Given a matching range r,
|
||||||
// the value for b is by r.value + (b - r.lo) * stride.
|
// the value for b is by r.value + (b - r.lo) * stride.
|
||||||
|
12
vendor/modules.txt
vendored
12
vendor/modules.txt
vendored
@ -77,11 +77,11 @@ github.com/valyala/bytebufferpool
|
|||||||
# github.com/valyala/fasttemplate v1.2.2
|
# github.com/valyala/fasttemplate v1.2.2
|
||||||
## explicit; go 1.12
|
## explicit; go 1.12
|
||||||
github.com/valyala/fasttemplate
|
github.com/valyala/fasttemplate
|
||||||
# golang.org/x/crypto v0.12.0
|
# golang.org/x/crypto v0.13.0
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
golang.org/x/crypto/acme
|
golang.org/x/crypto/acme
|
||||||
golang.org/x/crypto/acme/autocert
|
golang.org/x/crypto/acme/autocert
|
||||||
# golang.org/x/net v0.14.0
|
# golang.org/x/net v0.15.0
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
golang.org/x/net/html
|
golang.org/x/net/html
|
||||||
golang.org/x/net/html/atom
|
golang.org/x/net/html/atom
|
||||||
@ -91,10 +91,10 @@ golang.org/x/net/http2
|
|||||||
golang.org/x/net/http2/h2c
|
golang.org/x/net/http2/h2c
|
||||||
golang.org/x/net/http2/hpack
|
golang.org/x/net/http2/hpack
|
||||||
golang.org/x/net/idna
|
golang.org/x/net/idna
|
||||||
# golang.org/x/sys v0.11.0
|
# golang.org/x/sys v0.12.0
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
golang.org/x/sys/unix
|
golang.org/x/sys/unix
|
||||||
# golang.org/x/text v0.12.0
|
# golang.org/x/text v0.13.0
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
golang.org/x/text/encoding
|
golang.org/x/text/encoding
|
||||||
golang.org/x/text/encoding/charmap
|
golang.org/x/text/encoding/charmap
|
||||||
@ -122,8 +122,8 @@ gopkg.in/ini.v1
|
|||||||
# xorm.io/builder v0.3.13
|
# xorm.io/builder v0.3.13
|
||||||
## explicit; go 1.11
|
## explicit; go 1.11
|
||||||
xorm.io/builder
|
xorm.io/builder
|
||||||
# xorm.io/xorm v1.3.2
|
# xorm.io/xorm v1.3.3
|
||||||
## explicit; go 1.13
|
## explicit; go 1.16
|
||||||
xorm.io/xorm
|
xorm.io/xorm
|
||||||
xorm.io/xorm/caches
|
xorm.io/xorm/caches
|
||||||
xorm.io/xorm/contexts
|
xorm.io/xorm/contexts
|
||||||
|
437
vendor/xorm.io/xorm/.drone.yml
generated
vendored
437
vendor/xorm.io/xorm/.drone.yml
generated
vendored
@ -1,437 +0,0 @@
|
|||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test-mysql
|
|
||||||
environment:
|
|
||||||
GO111MODULE: "on"
|
|
||||||
GOPROXY: "https://goproxy.io"
|
|
||||||
CGO_ENABLED: 1
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: test-vet
|
|
||||||
image: golang:1.15
|
|
||||||
pull: always
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
commands:
|
|
||||||
- make vet
|
|
||||||
- name: test-sqlite3
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
depends_on:
|
|
||||||
- test-vet
|
|
||||||
commands:
|
|
||||||
- make fmt-check
|
|
||||||
- make test
|
|
||||||
- make test-sqlite3
|
|
||||||
- TEST_CACHE_ENABLE=true make test-sqlite3
|
|
||||||
- name: test-sqlite
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
depends_on:
|
|
||||||
- test-vet
|
|
||||||
commands:
|
|
||||||
- make test-sqlite
|
|
||||||
- TEST_QUOTE_POLICY=reserved make test-sqlite
|
|
||||||
- name: test-mysql
|
|
||||||
image: golang:1.15
|
|
||||||
pull: never
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
depends_on:
|
|
||||||
- test-vet
|
|
||||||
environment:
|
|
||||||
TEST_MYSQL_HOST: mysql
|
|
||||||
TEST_MYSQL_CHARSET: utf8
|
|
||||||
TEST_MYSQL_DBNAME: xorm_test
|
|
||||||
TEST_MYSQL_USERNAME: root
|
|
||||||
TEST_MYSQL_PASSWORD:
|
|
||||||
commands:
|
|
||||||
- TEST_CACHE_ENABLE=true make test-mysql
|
|
||||||
|
|
||||||
- name: test-mysql-utf8mb4
|
|
||||||
image: golang:1.15
|
|
||||||
pull: never
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
depends_on:
|
|
||||||
- test-mysql
|
|
||||||
environment:
|
|
||||||
TEST_MYSQL_HOST: mysql
|
|
||||||
TEST_MYSQL_CHARSET: utf8mb4
|
|
||||||
TEST_MYSQL_DBNAME: xorm_test
|
|
||||||
TEST_MYSQL_USERNAME: root
|
|
||||||
TEST_MYSQL_PASSWORD:
|
|
||||||
commands:
|
|
||||||
- make test-mysql
|
|
||||||
- TEST_QUOTE_POLICY=reserved make test-mysql-tls
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/cache
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: mysql
|
|
||||||
image: mysql:5.7
|
|
||||||
environment:
|
|
||||||
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
|
||||||
MYSQL_DATABASE: xorm_test
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test-mysql8
|
|
||||||
depends_on:
|
|
||||||
- test-mysql
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: test-mysql8
|
|
||||||
image: golang:1.15
|
|
||||||
pull: never
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
environment:
|
|
||||||
TEST_MYSQL_HOST: mysql8
|
|
||||||
TEST_MYSQL_CHARSET: utf8mb4
|
|
||||||
TEST_MYSQL_DBNAME: xorm_test
|
|
||||||
TEST_MYSQL_USERNAME: root
|
|
||||||
TEST_MYSQL_PASSWORD:
|
|
||||||
commands:
|
|
||||||
- make test-mysql
|
|
||||||
- TEST_CACHE_ENABLE=true make test-mysql
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/cache
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: mysql8
|
|
||||||
image: mysql:8.0
|
|
||||||
environment:
|
|
||||||
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
|
||||||
MYSQL_DATABASE: xorm_test
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test-mariadb
|
|
||||||
depends_on:
|
|
||||||
- test-mysql8
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: test-mariadb
|
|
||||||
image: golang:1.15
|
|
||||||
pull: never
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
environment:
|
|
||||||
TEST_MYSQL_HOST: mariadb
|
|
||||||
TEST_MYSQL_CHARSET: utf8mb4
|
|
||||||
TEST_MYSQL_DBNAME: xorm_test
|
|
||||||
TEST_MYSQL_USERNAME: root
|
|
||||||
TEST_MYSQL_PASSWORD:
|
|
||||||
commands:
|
|
||||||
- make test-mysql
|
|
||||||
- TEST_QUOTE_POLICY=reserved make test-mysql
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/cache
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: mariadb
|
|
||||||
image: mariadb:10.4
|
|
||||||
environment:
|
|
||||||
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
|
||||||
MYSQL_DATABASE: xorm_test
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test-postgres
|
|
||||||
depends_on:
|
|
||||||
- test-mariadb
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: test-postgres
|
|
||||||
pull: never
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
environment:
|
|
||||||
TEST_PGSQL_HOST: pgsql
|
|
||||||
TEST_PGSQL_DBNAME: xorm_test
|
|
||||||
TEST_PGSQL_USERNAME: postgres
|
|
||||||
TEST_PGSQL_PASSWORD: postgres
|
|
||||||
commands:
|
|
||||||
- make test-postgres
|
|
||||||
- TEST_CACHE_ENABLE=true make test-postgres
|
|
||||||
|
|
||||||
- name: test-postgres-schema
|
|
||||||
pull: never
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
depends_on:
|
|
||||||
- test-postgres
|
|
||||||
environment:
|
|
||||||
TEST_PGSQL_HOST: pgsql
|
|
||||||
TEST_PGSQL_SCHEMA: xorm
|
|
||||||
TEST_PGSQL_DBNAME: xorm_test
|
|
||||||
TEST_PGSQL_USERNAME: postgres
|
|
||||||
TEST_PGSQL_PASSWORD: postgres
|
|
||||||
commands:
|
|
||||||
- TEST_QUOTE_POLICY=reserved make test-postgres
|
|
||||||
|
|
||||||
- name: test-pgx
|
|
||||||
pull: never
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
depends_on:
|
|
||||||
- test-postgres-schema
|
|
||||||
environment:
|
|
||||||
TEST_PGSQL_HOST: pgsql
|
|
||||||
TEST_PGSQL_DBNAME: xorm_test
|
|
||||||
TEST_PGSQL_USERNAME: postgres
|
|
||||||
TEST_PGSQL_PASSWORD: postgres
|
|
||||||
commands:
|
|
||||||
- make test-pgx
|
|
||||||
- TEST_CACHE_ENABLE=true make test-pgx
|
|
||||||
- TEST_QUOTE_POLICY=reserved make test-pgx
|
|
||||||
|
|
||||||
- name: test-pgx-schema
|
|
||||||
pull: never
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
depends_on:
|
|
||||||
- test-pgx
|
|
||||||
environment:
|
|
||||||
TEST_PGSQL_HOST: pgsql
|
|
||||||
TEST_PGSQL_SCHEMA: xorm
|
|
||||||
TEST_PGSQL_DBNAME: xorm_test
|
|
||||||
TEST_PGSQL_USERNAME: postgres
|
|
||||||
TEST_PGSQL_PASSWORD: postgres
|
|
||||||
commands:
|
|
||||||
- make test-pgx
|
|
||||||
- TEST_CACHE_ENABLE=true make test-pgx
|
|
||||||
- TEST_QUOTE_POLICY=reserved make test-pgx
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/cache
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: pgsql
|
|
||||||
image: postgres:9.5
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: xorm_test
|
|
||||||
POSTGRES_USER: postgres
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test-mssql
|
|
||||||
depends_on:
|
|
||||||
- test-postgres
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: test-mssql
|
|
||||||
pull: never
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
environment:
|
|
||||||
TEST_MSSQL_HOST: mssql
|
|
||||||
TEST_MSSQL_DBNAME: xorm_test
|
|
||||||
TEST_MSSQL_USERNAME: sa
|
|
||||||
TEST_MSSQL_PASSWORD: "yourStrong(!)Password"
|
|
||||||
commands:
|
|
||||||
- make test-mssql
|
|
||||||
- TEST_MSSQL_DEFAULT_VARCHAR=NVARCHAR TEST_MSSQL_DEFAULT_CHAR=NCHAR make test-mssql
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/cache
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: mssql
|
|
||||||
pull: always
|
|
||||||
image: mcr.microsoft.com/mssql/server:latest
|
|
||||||
environment:
|
|
||||||
ACCEPT_EULA: Y
|
|
||||||
SA_PASSWORD: yourStrong(!)Password
|
|
||||||
MSSQL_PID: Standard
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test-tidb
|
|
||||||
depends_on:
|
|
||||||
- test-mssql
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: test-tidb
|
|
||||||
pull: never
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
environment:
|
|
||||||
TEST_TIDB_HOST: "tidb:4000"
|
|
||||||
TEST_TIDB_DBNAME: xorm_test
|
|
||||||
TEST_TIDB_USERNAME: root
|
|
||||||
TEST_TIDB_PASSWORD:
|
|
||||||
commands:
|
|
||||||
- make test-tidb
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/cache
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: tidb
|
|
||||||
image: pingcap/tidb:v3.0.3
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: test-cockroach
|
|
||||||
depends_on:
|
|
||||||
- test-tidb
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: test-cockroach
|
|
||||||
pull: never
|
|
||||||
image: golang:1.15
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
path: /go/pkg/mod
|
|
||||||
environment:
|
|
||||||
TEST_COCKROACH_HOST: "cockroach:26257"
|
|
||||||
TEST_COCKROACH_DBNAME: xorm_test
|
|
||||||
TEST_COCKROACH_USERNAME: root
|
|
||||||
TEST_COCKROACH_PASSWORD:
|
|
||||||
commands:
|
|
||||||
- sleep 10
|
|
||||||
- make test-cockroach
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
- name: cache
|
|
||||||
host:
|
|
||||||
path: /tmp/cache
|
|
||||||
|
|
||||||
services:
|
|
||||||
- name: cockroach
|
|
||||||
image: cockroachdb/cockroach:v19.2.4
|
|
||||||
commands:
|
|
||||||
- /cockroach/cockroach start --insecure
|
|
||||||
|
|
||||||
# ---
|
|
||||||
# kind: pipeline
|
|
||||||
# name: test-dameng
|
|
||||||
# depends_on:
|
|
||||||
# - test-cockroach
|
|
||||||
# trigger:
|
|
||||||
# ref:
|
|
||||||
# - refs/heads/master
|
|
||||||
# - refs/pull/*/head
|
|
||||||
# steps:
|
|
||||||
# - name: test-dameng
|
|
||||||
# pull: never
|
|
||||||
# image: golang:1.15
|
|
||||||
# volumes:
|
|
||||||
# - name: cache
|
|
||||||
# path: /go/pkg/mod
|
|
||||||
# environment:
|
|
||||||
# TEST_DAMENG_HOST: "dameng:5236"
|
|
||||||
# TEST_DAMENG_USERNAME: SYSDBA
|
|
||||||
# TEST_DAMENG_PASSWORD: SYSDBA
|
|
||||||
# commands:
|
|
||||||
# - sleep 30
|
|
||||||
# - make test-dameng
|
|
||||||
|
|
||||||
# volumes:
|
|
||||||
# - name: cache
|
|
||||||
# host:
|
|
||||||
# path: /tmp/cache
|
|
||||||
|
|
||||||
# services:
|
|
||||||
# - name: dameng
|
|
||||||
# image: lunny/dm:v1.0
|
|
||||||
# commands:
|
|
||||||
# - /bin/bash /startDm.sh
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: merge_coverage
|
|
||||||
depends_on:
|
|
||||||
- test-mysql
|
|
||||||
- test-mysql8
|
|
||||||
- test-mariadb
|
|
||||||
- test-postgres
|
|
||||||
- test-mssql
|
|
||||||
- test-tidb
|
|
||||||
- test-cockroach
|
|
||||||
#- test-dameng
|
|
||||||
trigger:
|
|
||||||
ref:
|
|
||||||
- refs/heads/master
|
|
||||||
- refs/pull/*/head
|
|
||||||
steps:
|
|
||||||
- name: merge_coverage
|
|
||||||
image: golang:1.15
|
|
||||||
commands:
|
|
||||||
- make coverage
|
|
||||||
|
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: release-tag
|
|
||||||
trigger:
|
|
||||||
event:
|
|
||||||
- tag
|
|
||||||
steps:
|
|
||||||
- name: release-tag-gitea
|
|
||||||
pull: always
|
|
||||||
image: plugins/gitea-release:latest
|
|
||||||
settings:
|
|
||||||
base_url: https://gitea.com
|
|
||||||
title: '${DRONE_TAG} is released'
|
|
||||||
api_key:
|
|
||||||
from_secret: gitea_token
|
|
7
vendor/xorm.io/xorm/.gitignore
generated
vendored
7
vendor/xorm.io/xorm/.gitignore
generated
vendored
@ -35,6 +35,7 @@ test.db.sql
|
|||||||
|
|
||||||
*coverage.out
|
*coverage.out
|
||||||
test.db
|
test.db
|
||||||
integrations/*.sql
|
tests/*.sql
|
||||||
integrations/test_sqlite*
|
tests/test_sqlite*
|
||||||
cover.out
|
cover.out
|
||||||
|
cover.html
|
||||||
|
7
vendor/xorm.io/xorm/Makefile
generated
vendored
7
vendor/xorm.io/xorm/Makefile
generated
vendored
@ -9,7 +9,7 @@ SED_INPLACE := sed -i
|
|||||||
GO_DIRS := caches contexts integrations core dialects internal log migrate names schemas tags
|
GO_DIRS := caches contexts integrations core dialects internal log migrate names schemas tags
|
||||||
GOFILES := $(wildcard *.go)
|
GOFILES := $(wildcard *.go)
|
||||||
GOFILES += $(shell find $(GO_DIRS) -name "*.go" -type f)
|
GOFILES += $(shell find $(GO_DIRS) -name "*.go" -type f)
|
||||||
INTEGRATION_PACKAGES := xorm.io/xorm/integrations
|
INTEGRATION_PACKAGES := xorm.io/xorm/tests
|
||||||
PACKAGES ?= $(filter-out $(INTEGRATION_PACKAGES),$(shell $(GO) list ./...))
|
PACKAGES ?= $(filter-out $(INTEGRATION_PACKAGES),$(shell $(GO) list ./...))
|
||||||
|
|
||||||
TEST_COCKROACH_HOST ?= cockroach:26257
|
TEST_COCKROACH_HOST ?= cockroach:26257
|
||||||
@ -60,7 +60,7 @@ build: go-check $(GO_SOURCES)
|
|||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
$(GO) clean -i ./...
|
$(GO) clean -i ./...
|
||||||
rm -rf *.sql *.log test.db *coverage.out coverage.all integrations/*.sql
|
rm -rf *.sql *.log test.db cover.out cover.html *coverage.out coverage.all integrations/*.sql
|
||||||
|
|
||||||
.PHONY: coverage
|
.PHONY: coverage
|
||||||
coverage:
|
coverage:
|
||||||
@ -132,7 +132,8 @@ golangci-lint-check:
|
|||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test: go-check
|
test: go-check
|
||||||
$(GO) test $(PACKAGES)
|
$(GO) test -cover -coverprofile=cover.out $(PACKAGES)
|
||||||
|
$(GO) tool cover -html=cover.out -o cover.html
|
||||||
|
|
||||||
.PNONY: test-cockroach
|
.PNONY: test-cockroach
|
||||||
test-cockroach: go-check
|
test-cockroach: go-check
|
||||||
|
3
vendor/xorm.io/xorm/README.md
generated
vendored
3
vendor/xorm.io/xorm/README.md
generated
vendored
@ -45,7 +45,7 @@ Drivers for Go's sql package which currently support database/sql includes:
|
|||||||
|
|
||||||
* [SQLite](https://sqlite.org)
|
* [SQLite](https://sqlite.org)
|
||||||
- [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)
|
- [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)
|
||||||
- [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) (windows unsupported)
|
- [modernc.org/sqlite](https://gitlab.com/cznic/sqlite)
|
||||||
|
|
||||||
* MsSql
|
* MsSql
|
||||||
- [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb)
|
- [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb)
|
||||||
@ -53,6 +53,7 @@ Drivers for Go's sql package which currently support database/sql includes:
|
|||||||
* Oracle
|
* Oracle
|
||||||
- [github.com/godror/godror](https://github.com/godror/godror) (experiment)
|
- [github.com/godror/godror](https://github.com/godror/godror) (experiment)
|
||||||
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (experiment)
|
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (experiment)
|
||||||
|
- [github.com/sijms/go-ora](https://github.com/sijms/go-ora) (experiment)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
3
vendor/xorm.io/xorm/README_CN.md
generated
vendored
3
vendor/xorm.io/xorm/README_CN.md
generated
vendored
@ -44,7 +44,7 @@ v1.0.0 相对于 v0.8.2 有以下不兼容的变更:
|
|||||||
|
|
||||||
* [SQLite](https://sqlite.org)
|
* [SQLite](https://sqlite.org)
|
||||||
- [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)
|
- [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3)
|
||||||
- [modernc.org/sqlite](https://gitlab.com/cznic/sqlite) (Windows试验性支持)
|
- [modernc.org/sqlite](https://gitlab.com/cznic/sqlite)
|
||||||
|
|
||||||
* MsSql
|
* MsSql
|
||||||
- [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb)
|
- [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb)
|
||||||
@ -52,6 +52,7 @@ v1.0.0 相对于 v0.8.2 有以下不兼容的变更:
|
|||||||
* Oracle
|
* Oracle
|
||||||
- [github.com/godror/godror](https://github.com/godror/godror) (试验性支持)
|
- [github.com/godror/godror](https://github.com/godror/godror) (试验性支持)
|
||||||
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (试验性支持)
|
- [github.com/mattn/go-oci8](https://github.com/mattn/go-oci8) (试验性支持)
|
||||||
|
- [github.com/sijms/go-ora](https://github.com/sijms/go-ora) (试验性支持)
|
||||||
|
|
||||||
## 安装
|
## 安装
|
||||||
|
|
||||||
|
14
vendor/xorm.io/xorm/convert/conversion.go
generated
vendored
14
vendor/xorm.io/xorm/convert/conversion.go
generated
vendored
@ -16,11 +16,21 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ConversionFrom is an inteface to allow retrieve data from database
|
||||||
|
type ConversionFrom interface {
|
||||||
|
FromDB([]byte) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConversionTo is an interface to allow store data to database
|
||||||
|
type ConversionTo interface {
|
||||||
|
ToDB() ([]byte, error)
|
||||||
|
}
|
||||||
|
|
||||||
// Conversion is an interface. A type implements Conversion will according
|
// Conversion is an interface. A type implements Conversion will according
|
||||||
// the custom method to fill into database and retrieve from database.
|
// the custom method to fill into database and retrieve from database.
|
||||||
type Conversion interface {
|
type Conversion interface {
|
||||||
FromDB([]byte) error
|
ConversionFrom
|
||||||
ToDB() ([]byte, error)
|
ConversionTo
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrNilPtr represents an error
|
// ErrNilPtr represents an error
|
||||||
|
58
vendor/xorm.io/xorm/convert/int.go
generated
vendored
58
vendor/xorm.io/xorm/convert/int.go
generated
vendored
@ -35,6 +35,56 @@ func AsInt64(src interface{}) (int64, error) {
|
|||||||
return int64(v), nil
|
return int64(v), nil
|
||||||
case uint64:
|
case uint64:
|
||||||
return int64(v), nil
|
return int64(v), nil
|
||||||
|
case *int:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *int16:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *int32:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *int8:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *int64:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return *v, nil
|
||||||
|
case *uint:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *uint8:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *uint16:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *uint32:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
|
case *uint64:
|
||||||
|
if v == nil {
|
||||||
|
return 0, nil
|
||||||
|
}
|
||||||
|
return int64(*v), nil
|
||||||
case []byte:
|
case []byte:
|
||||||
return strconv.ParseInt(string(v), 10, 64)
|
return strconv.ParseInt(string(v), 10, 64)
|
||||||
case string:
|
case string:
|
||||||
@ -110,9 +160,7 @@ func AsUint64(src interface{}) (uint64, error) {
|
|||||||
return 0, fmt.Errorf("unsupported value %T as uint64", src)
|
return 0, fmt.Errorf("unsupported value %T as uint64", src)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var _ sql.Scanner = &NullUint64{}
|
||||||
_ sql.Scanner = &NullUint64{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// NullUint64 represents an uint64 that may be null.
|
// NullUint64 represents an uint64 that may be null.
|
||||||
// NullUint64 implements the Scanner interface so
|
// NullUint64 implements the Scanner interface so
|
||||||
@ -142,9 +190,7 @@ func (n NullUint64) Value() (driver.Value, error) {
|
|||||||
return n.Uint64, nil
|
return n.Uint64, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var _ sql.Scanner = &NullUint32{}
|
||||||
_ sql.Scanner = &NullUint32{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// NullUint32 represents an uint32 that may be null.
|
// NullUint32 represents an uint32 that may be null.
|
||||||
// NullUint32 implements the Scanner interface so
|
// NullUint32 implements the Scanner interface so
|
||||||
|
5
vendor/xorm.io/xorm/convert/interface.go
generated
vendored
5
vendor/xorm.io/xorm/convert/interface.go
generated
vendored
@ -24,7 +24,10 @@ func Interface2Interface(userLocation *time.Location, v interface{}) (interface{
|
|||||||
return vv.String, nil
|
return vv.String, nil
|
||||||
case *sql.RawBytes:
|
case *sql.RawBytes:
|
||||||
if len([]byte(*vv)) > 0 {
|
if len([]byte(*vv)) > 0 {
|
||||||
return []byte(*vv), nil
|
src := []byte(*vv)
|
||||||
|
dest := make([]byte, len(src))
|
||||||
|
copy(dest, src)
|
||||||
|
return dest, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
case *sql.NullInt32:
|
case *sql.NullInt32:
|
||||||
|
57
vendor/xorm.io/xorm/convert/time.go
generated
vendored
57
vendor/xorm.io/xorm/convert/time.go
generated
vendored
@ -15,6 +15,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// String2Time converts a string to time with original location
|
// String2Time converts a string to time with original location
|
||||||
|
// be aware for time strings (HH:mm:ss) returns zero year (LMT) for converted location
|
||||||
func String2Time(s string, originalLocation *time.Location, convertedLocation *time.Location) (*time.Time, error) {
|
func String2Time(s string, originalLocation *time.Location, convertedLocation *time.Location) (*time.Time, error) {
|
||||||
if len(s) == 19 {
|
if len(s) == 19 {
|
||||||
if s == utils.ZeroTime0 || s == utils.ZeroTime1 {
|
if s == utils.ZeroTime0 || s == utils.ZeroTime1 {
|
||||||
@ -27,6 +28,9 @@ func String2Time(s string, originalLocation *time.Location, convertedLocation *t
|
|||||||
dt = dt.In(convertedLocation)
|
dt = dt.In(convertedLocation)
|
||||||
return &dt, nil
|
return &dt, nil
|
||||||
} else if len(s) == 20 && s[10] == 'T' && s[19] == 'Z' {
|
} else if len(s) == 20 && s[10] == 'T' && s[19] == 'Z' {
|
||||||
|
if strings.HasPrefix(s, "0000-00-00T00:00:00") || strings.HasPrefix(s, "0001-01-01T00:00:00") {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
dt, err := time.ParseInLocation("2006-01-02T15:04:05", s[:19], originalLocation)
|
dt, err := time.ParseInLocation("2006-01-02T15:04:05", s[:19], originalLocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -34,14 +38,32 @@ func String2Time(s string, originalLocation *time.Location, convertedLocation *t
|
|||||||
dt = dt.In(convertedLocation)
|
dt = dt.In(convertedLocation)
|
||||||
return &dt, nil
|
return &dt, nil
|
||||||
} else if len(s) == 25 && s[10] == 'T' && s[19] == '+' && s[22] == ':' {
|
} else if len(s) == 25 && s[10] == 'T' && s[19] == '+' && s[22] == ':' {
|
||||||
|
if strings.HasPrefix(s, "0000-00-00T00:00:00") || strings.HasPrefix(s, "0001-01-01T00:00:00") {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
dt, err := time.Parse(time.RFC3339, s)
|
dt, err := time.Parse(time.RFC3339, s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dt = dt.In(convertedLocation)
|
dt = dt.In(convertedLocation)
|
||||||
return &dt, nil
|
return &dt, nil
|
||||||
|
} else if len(s) >= 21 && s[10] == 'T' && s[19] == '.' {
|
||||||
|
if strings.HasPrefix(s, "0000-00-00T00:00:00."+strings.Repeat("0", len(s)-20)) ||
|
||||||
|
strings.HasPrefix(s, "0001-01-01T00:00:00."+strings.Repeat("0", len(s)-20)) {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
|
dt, err := time.Parse(time.RFC3339Nano, s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
dt = dt.In(convertedLocation)
|
||||||
|
return &dt, nil
|
||||||
} else if len(s) >= 21 && s[19] == '.' {
|
} else if len(s) >= 21 && s[19] == '.' {
|
||||||
var layout = "2006-01-02 15:04:05." + strings.Repeat("0", len(s)-20)
|
if strings.HasPrefix(s, "0000-00-00T00:00:00."+strings.Repeat("0", len(s)-20)) ||
|
||||||
|
strings.HasPrefix(s, "0001-01-01T00:00:00."+strings.Repeat("0", len(s)-20)) {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
|
layout := "2006-01-02 15:04:05." + strings.Repeat("0", len(s)-20)
|
||||||
dt, err := time.ParseInLocation(layout, s, originalLocation)
|
dt, err := time.ParseInLocation(layout, s, originalLocation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -58,9 +80,24 @@ func String2Time(s string, originalLocation *time.Location, convertedLocation *t
|
|||||||
}
|
}
|
||||||
dt = dt.In(convertedLocation)
|
dt = dt.In(convertedLocation)
|
||||||
return &dt, nil
|
return &dt, nil
|
||||||
|
} else if len(s) == 8 && s[2] == ':' && s[5] == ':' {
|
||||||
|
dt, err := time.ParseInLocation("15:04:05", s, originalLocation)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
currentDate := time.Now()
|
||||||
|
// add current date for correct time locations
|
||||||
|
dt = dt.AddDate(currentDate.Year(), int(currentDate.Month()), currentDate.Day())
|
||||||
|
dt = dt.In(convertedLocation)
|
||||||
|
// back to zero year
|
||||||
|
dt = dt.AddDate(-currentDate.Year(), int(-currentDate.Month()), -currentDate.Day())
|
||||||
|
return &dt, nil
|
||||||
} else {
|
} else {
|
||||||
i, err := strconv.ParseInt(s, 10, 64)
|
i, err := strconv.ParseInt(s, 10, 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if i == 0 {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
tm := time.Unix(i, 0).In(convertedLocation)
|
tm := time.Unix(i, 0).In(convertedLocation)
|
||||||
return &tm, nil
|
return &tm, nil
|
||||||
}
|
}
|
||||||
@ -87,6 +124,9 @@ func AsTime(src interface{}, dbLoc *time.Location, uiLoc *time.Location) (*time.
|
|||||||
if !t.Valid {
|
if !t.Valid {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
if utils.IsTimeZero(t.Time) {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
z, _ := t.Time.Zone()
|
z, _ := t.Time.Zone()
|
||||||
if len(z) == 0 || t.Time.Year() == 0 || t.Time.Location().String() != dbLoc.String() {
|
if len(z) == 0 || t.Time.Year() == 0 || t.Time.Location().String() != dbLoc.String() {
|
||||||
tm := time.Date(t.Time.Year(), t.Time.Month(), t.Time.Day(), t.Time.Hour(),
|
tm := time.Date(t.Time.Year(), t.Time.Month(), t.Time.Day(), t.Time.Hour(),
|
||||||
@ -96,6 +136,9 @@ func AsTime(src interface{}, dbLoc *time.Location, uiLoc *time.Location) (*time.
|
|||||||
tm := t.Time.In(uiLoc)
|
tm := t.Time.In(uiLoc)
|
||||||
return &tm, nil
|
return &tm, nil
|
||||||
case *time.Time:
|
case *time.Time:
|
||||||
|
if utils.IsTimeZero(*t) {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
z, _ := t.Zone()
|
z, _ := t.Zone()
|
||||||
if len(z) == 0 || t.Year() == 0 || t.Location().String() != dbLoc.String() {
|
if len(z) == 0 || t.Year() == 0 || t.Location().String() != dbLoc.String() {
|
||||||
tm := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(),
|
tm := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(),
|
||||||
@ -105,6 +148,9 @@ func AsTime(src interface{}, dbLoc *time.Location, uiLoc *time.Location) (*time.
|
|||||||
tm := t.In(uiLoc)
|
tm := t.In(uiLoc)
|
||||||
return &tm, nil
|
return &tm, nil
|
||||||
case time.Time:
|
case time.Time:
|
||||||
|
if utils.IsTimeZero(t) {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
z, _ := t.Zone()
|
z, _ := t.Zone()
|
||||||
if len(z) == 0 || t.Year() == 0 || t.Location().String() != dbLoc.String() {
|
if len(z) == 0 || t.Year() == 0 || t.Location().String() != dbLoc.String() {
|
||||||
tm := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(),
|
tm := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(),
|
||||||
@ -114,12 +160,21 @@ func AsTime(src interface{}, dbLoc *time.Location, uiLoc *time.Location) (*time.
|
|||||||
tm := t.In(uiLoc)
|
tm := t.In(uiLoc)
|
||||||
return &tm, nil
|
return &tm, nil
|
||||||
case int:
|
case int:
|
||||||
|
if t == 0 {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
tm := time.Unix(int64(t), 0).In(uiLoc)
|
tm := time.Unix(int64(t), 0).In(uiLoc)
|
||||||
return &tm, nil
|
return &tm, nil
|
||||||
case int64:
|
case int64:
|
||||||
|
if t == 0 {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
tm := time.Unix(t, 0).In(uiLoc)
|
tm := time.Unix(t, 0).In(uiLoc)
|
||||||
return &tm, nil
|
return &tm, nil
|
||||||
case *sql.NullInt64:
|
case *sql.NullInt64:
|
||||||
|
if t.Int64 == 0 {
|
||||||
|
return &time.Time{}, nil
|
||||||
|
}
|
||||||
tm := time.Unix(t.Int64, 0).In(uiLoc)
|
tm := time.Unix(t.Int64, 0).In(uiLoc)
|
||||||
return &tm, nil
|
return &tm, nil
|
||||||
}
|
}
|
||||||
|
18
vendor/xorm.io/xorm/dialects/dameng.go
generated
vendored
18
vendor/xorm.io/xorm/dialects/dameng.go
generated
vendored
@ -659,7 +659,7 @@ func (db *dameng) DropTableSQL(tableName string) (string, bool) {
|
|||||||
|
|
||||||
// ModifyColumnSQL returns a SQL to modify SQL
|
// ModifyColumnSQL returns a SQL to modify SQL
|
||||||
func (db *dameng) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
func (db *dameng) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
s, _ := ColumnString(db.dialect, col, false)
|
s, _ := ColumnString(db.dialect, col, false, false)
|
||||||
return fmt.Sprintf("ALTER TABLE %s MODIFY %s", db.quoter.Quote(tableName), s)
|
return fmt.Sprintf("ALTER TABLE %s MODIFY %s", db.quoter.Quote(tableName), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,7 +692,7 @@ func (db *dameng) CreateTableSQL(ctx context.Context, queryer core.Queryer, tabl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s, _ := ColumnString(db, col, false)
|
s, _ := ColumnString(db, col, false, false)
|
||||||
if _, err := b.WriteString(s); err != nil {
|
if _, err := b.WriteString(s); err != nil {
|
||||||
return "", false, err
|
return "", false, err
|
||||||
}
|
}
|
||||||
@ -709,7 +709,13 @@ func (db *dameng) CreateTableSQL(ctx context.Context, queryer core.Queryer, tabl
|
|||||||
return "", false, err
|
return "", false, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if _, err := b.WriteString(fmt.Sprintf("CONSTRAINT PK_%s PRIMARY KEY (", tableName)); err != nil {
|
if _, err := b.WriteString("CONSTRAINT PK_"); err != nil {
|
||||||
|
return "", false, err
|
||||||
|
}
|
||||||
|
if _, err := b.WriteString(tableName); err != nil {
|
||||||
|
return "", false, err
|
||||||
|
}
|
||||||
|
if _, err := b.WriteString(" PRIMARY KEY ("); err != nil {
|
||||||
return "", false, err
|
return "", false, err
|
||||||
}
|
}
|
||||||
if err := quoter.JoinWrite(&b, pkList, ","); err != nil {
|
if err := quoter.JoinWrite(&b, pkList, ","); err != nil {
|
||||||
@ -837,7 +843,11 @@ func addSingleQuote(name string) string {
|
|||||||
if name[0] == '\'' && name[len(name)-1] == '\'' {
|
if name[0] == '\'' && name[len(name)-1] == '\'' {
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("'%s'", name)
|
var b strings.Builder
|
||||||
|
b.WriteRune('\'')
|
||||||
|
b.WriteString(name)
|
||||||
|
b.WriteRune('\'')
|
||||||
|
return b.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *dameng) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) {
|
func (db *dameng) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) {
|
||||||
|
29
vendor/xorm.io/xorm/dialects/dialect.go
generated
vendored
29
vendor/xorm.io/xorm/dialects/dialect.go
generated
vendored
@ -85,8 +85,6 @@ type Dialect interface {
|
|||||||
AddColumnSQL(tableName string, col *schemas.Column) string
|
AddColumnSQL(tableName string, col *schemas.Column) string
|
||||||
ModifyColumnSQL(tableName string, col *schemas.Column) string
|
ModifyColumnSQL(tableName string, col *schemas.Column) string
|
||||||
|
|
||||||
ForUpdateSQL(query string) string
|
|
||||||
|
|
||||||
Filters() []Filter
|
Filters() []Filter
|
||||||
SetParams(params map[string]string)
|
SetParams(params map[string]string)
|
||||||
}
|
}
|
||||||
@ -135,7 +133,7 @@ func (db *Base) CreateTableSQL(ctx context.Context, queryer core.Queryer, table
|
|||||||
|
|
||||||
for i, colName := range table.ColumnsSeq() {
|
for i, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1)
|
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1, false)
|
||||||
b.WriteString(s)
|
b.WriteString(s)
|
||||||
|
|
||||||
if i != len(table.ColumnsSeq())-1 {
|
if i != len(table.ColumnsSeq())-1 {
|
||||||
@ -209,7 +207,7 @@ func (db *Base) IsColumnExist(queryer core.Queryer, ctx context.Context, tableNa
|
|||||||
|
|
||||||
// AddColumnSQL returns a SQL to add a column
|
// AddColumnSQL returns a SQL to add a column
|
||||||
func (db *Base) AddColumnSQL(tableName string, col *schemas.Column) string {
|
func (db *Base) AddColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
s, _ := ColumnString(db.dialect, col, true)
|
s, _ := ColumnString(db.dialect, col, true, false)
|
||||||
return fmt.Sprintf("ALTER TABLE %s ADD %s", db.dialect.Quoter().Quote(tableName), s)
|
return fmt.Sprintf("ALTER TABLE %s ADD %s", db.dialect.Quoter().Quote(tableName), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,22 +239,15 @@ func (db *Base) DropIndexSQL(tableName string, index *schemas.Index) string {
|
|||||||
|
|
||||||
// ModifyColumnSQL returns a SQL to modify SQL
|
// ModifyColumnSQL returns a SQL to modify SQL
|
||||||
func (db *Base) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
func (db *Base) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
s, _ := ColumnString(db.dialect, col, false)
|
s, _ := ColumnString(db.dialect, col, false, false)
|
||||||
return fmt.Sprintf("ALTER TABLE %s MODIFY COLUMN %s", db.quoter.Quote(tableName), s)
|
return fmt.Sprintf("ALTER TABLE %s MODIFY COLUMN %s", db.quoter.Quote(tableName), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForUpdateSQL returns for updateSQL
|
|
||||||
func (db *Base) ForUpdateSQL(query string) string {
|
|
||||||
return query + " FOR UPDATE"
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetParams set params
|
// SetParams set params
|
||||||
func (db *Base) SetParams(params map[string]string) {
|
func (db *Base) SetParams(params map[string]string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var dialects = map[string]func() Dialect{}
|
||||||
dialects = map[string]func() Dialect{}
|
|
||||||
)
|
|
||||||
|
|
||||||
// RegisterDialect register database dialect
|
// RegisterDialect register database dialect
|
||||||
func RegisterDialect(dbName schemas.DBType, dialectFunc func() Dialect) {
|
func RegisterDialect(dbName schemas.DBType, dialectFunc func() Dialect) {
|
||||||
@ -290,6 +281,7 @@ func regDrvsNDialects() bool {
|
|||||||
"sqlite": {"sqlite3", func() Driver { return &sqlite3Driver{} }, func() Dialect { return &sqlite3{} }},
|
"sqlite": {"sqlite3", func() Driver { return &sqlite3Driver{} }, func() Dialect { return &sqlite3{} }},
|
||||||
"oci8": {"oracle", func() Driver { return &oci8Driver{} }, func() Dialect { return &oracle{} }},
|
"oci8": {"oracle", func() Driver { return &oci8Driver{} }, func() Dialect { return &oracle{} }},
|
||||||
"godror": {"oracle", func() Driver { return &godrorDriver{} }, func() Dialect { return &oracle{} }},
|
"godror": {"oracle", func() Driver { return &godrorDriver{} }, func() Dialect { return &oracle{} }},
|
||||||
|
"oracle": {"oracle", func() Driver { return &oracleDriver{} }, func() Dialect { return &oracle{} }},
|
||||||
}
|
}
|
||||||
|
|
||||||
for driverName, v := range providedDrvsNDialects {
|
for driverName, v := range providedDrvsNDialects {
|
||||||
@ -306,7 +298,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ColumnString generate column description string according dialect
|
// ColumnString generate column description string according dialect
|
||||||
func ColumnString(dialect Dialect, col *schemas.Column, includePrimaryKey bool) (string, error) {
|
func ColumnString(dialect Dialect, col *schemas.Column, includePrimaryKey, supportCollation bool) (string, error) {
|
||||||
bd := strings.Builder{}
|
bd := strings.Builder{}
|
||||||
|
|
||||||
if err := dialect.Quoter().QuoteTo(&bd, col.Name); err != nil {
|
if err := dialect.Quoter().QuoteTo(&bd, col.Name); err != nil {
|
||||||
@ -321,6 +313,15 @@ func ColumnString(dialect Dialect, col *schemas.Column, includePrimaryKey bool)
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if supportCollation && col.Collation != "" {
|
||||||
|
if _, err := bd.WriteString(" COLLATE "); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if _, err := bd.WriteString(col.Collation); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if includePrimaryKey && col.IsPrimaryKey {
|
if includePrimaryKey && col.IsPrimaryKey {
|
||||||
if _, err := bd.WriteString(" PRIMARY KEY"); err != nil {
|
if _, err := bd.WriteString(" PRIMARY KEY"); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
85
vendor/xorm.io/xorm/dialects/filter.go
generated
vendored
85
vendor/xorm.io/xorm/dialects/filter.go
generated
vendored
@ -5,22 +5,24 @@
|
|||||||
package dialects
|
package dialects
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Filter is an interface to filter SQL
|
// Filter is an interface to filter SQL
|
||||||
type Filter interface {
|
type Filter interface {
|
||||||
Do(sql string) string
|
Do(ctx context.Context, sql string) string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SeqFilter filter SQL replace ?, ? ... to $1, $2 ...
|
// postgresSeqFilter filter SQL replace ?, ? ... to $1, $2 ...
|
||||||
type SeqFilter struct {
|
type postgresSeqFilter struct {
|
||||||
Prefix string
|
Prefix string
|
||||||
Start int
|
Start int
|
||||||
}
|
}
|
||||||
|
|
||||||
func convertQuestionMark(sql, prefix string, start int) string {
|
func postgresSeqFilterConvertQuestionMark(sql, prefix string, start int) string {
|
||||||
var buf strings.Builder
|
var buf strings.Builder
|
||||||
var beginSingleQuote bool
|
var beginSingleQuote bool
|
||||||
var isLineComment bool
|
var isLineComment bool
|
||||||
@ -28,10 +30,77 @@ func convertQuestionMark(sql, prefix string, start int) string {
|
|||||||
var isMaybeLineComment bool
|
var isMaybeLineComment bool
|
||||||
var isMaybeComment bool
|
var isMaybeComment bool
|
||||||
var isMaybeCommentEnd bool
|
var isMaybeCommentEnd bool
|
||||||
var index = start
|
var isMaybeJsonbQuestion bool
|
||||||
|
index := start
|
||||||
|
for i, c := range sql {
|
||||||
|
if !beginSingleQuote && !isLineComment && !isComment && !isMaybeJsonbQuestion && c == '?' {
|
||||||
|
buf.WriteString(fmt.Sprintf("%s%v", prefix, index))
|
||||||
|
index++
|
||||||
|
} else {
|
||||||
|
if isMaybeJsonbQuestion && c == '?' {
|
||||||
|
isMaybeJsonbQuestion = false
|
||||||
|
} else if isMaybeLineComment {
|
||||||
|
if c == '-' {
|
||||||
|
isLineComment = true
|
||||||
|
}
|
||||||
|
isMaybeLineComment = false
|
||||||
|
} else if isMaybeComment {
|
||||||
|
if c == '*' {
|
||||||
|
isComment = true
|
||||||
|
}
|
||||||
|
isMaybeComment = false
|
||||||
|
} else if isMaybeCommentEnd {
|
||||||
|
if c == '/' {
|
||||||
|
isComment = false
|
||||||
|
}
|
||||||
|
isMaybeCommentEnd = false
|
||||||
|
} else if isLineComment {
|
||||||
|
if c == '\n' {
|
||||||
|
isLineComment = false
|
||||||
|
}
|
||||||
|
} else if isComment {
|
||||||
|
if c == '*' {
|
||||||
|
isMaybeCommentEnd = true
|
||||||
|
}
|
||||||
|
} else if !beginSingleQuote && c == '-' {
|
||||||
|
isMaybeLineComment = true
|
||||||
|
} else if !beginSingleQuote && c == '/' {
|
||||||
|
isMaybeComment = true
|
||||||
|
} else if !beginSingleQuote && c == ' ' && i >= 7 && strings.TrimSpace(sql[i-7:i]) == "::jsonb" {
|
||||||
|
isMaybeJsonbQuestion = true
|
||||||
|
} else if c == '\'' {
|
||||||
|
beginSingleQuote = !beginSingleQuote
|
||||||
|
}
|
||||||
|
buf.WriteRune(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return buf.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do implements Filter
|
||||||
|
func (s *postgresSeqFilter) Do(ctx context.Context, sql string) string {
|
||||||
|
return postgresSeqFilterConvertQuestionMark(sql, s.Prefix, s.Start)
|
||||||
|
}
|
||||||
|
|
||||||
|
// oracleSeqFilter filter SQL replace ?, ? ... to :1, :2 ...
|
||||||
|
type oracleSeqFilter struct {
|
||||||
|
Prefix string
|
||||||
|
Start int
|
||||||
|
}
|
||||||
|
|
||||||
|
func oracleSeqFilterConvertQuestionMark(sql, prefix string, start int) string {
|
||||||
|
var buf strings.Builder
|
||||||
|
var beginSingleQuote bool
|
||||||
|
var isLineComment bool
|
||||||
|
var isComment bool
|
||||||
|
var isMaybeLineComment bool
|
||||||
|
var isMaybeComment bool
|
||||||
|
var isMaybeCommentEnd bool
|
||||||
|
index := start
|
||||||
for _, c := range sql {
|
for _, c := range sql {
|
||||||
if !beginSingleQuote && !isLineComment && !isComment && c == '?' {
|
if !beginSingleQuote && !isLineComment && !isComment && c == '?' {
|
||||||
buf.WriteString(fmt.Sprintf("%s%v", prefix, index))
|
buf.WriteString(prefix)
|
||||||
|
buf.WriteString(strconv.Itoa(index))
|
||||||
index++
|
index++
|
||||||
} else {
|
} else {
|
||||||
if isMaybeLineComment {
|
if isMaybeLineComment {
|
||||||
@ -71,6 +140,6 @@ func convertQuestionMark(sql, prefix string, start int) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do implements Filter
|
// Do implements Filter
|
||||||
func (s *SeqFilter) Do(sql string) string {
|
func (s *oracleSeqFilter) Do(ctx context.Context, sql string) string {
|
||||||
return convertQuestionMark(sql, s.Prefix, s.Start)
|
return oracleSeqFilterConvertQuestionMark(sql, s.Prefix, s.Start)
|
||||||
}
|
}
|
||||||
|
22
vendor/xorm.io/xorm/dialects/mssql.go
generated
vendored
22
vendor/xorm.io/xorm/dialects/mssql.go
generated
vendored
@ -320,11 +320,7 @@ func (db *mssql) SQLType(c *schemas.Column) string {
|
|||||||
res += "(MAX)"
|
res += "(MAX)"
|
||||||
}
|
}
|
||||||
case schemas.TimeStamp, schemas.DateTime:
|
case schemas.TimeStamp, schemas.DateTime:
|
||||||
if c.Length > 3 {
|
return "DATETIME2"
|
||||||
res = "DATETIME2"
|
|
||||||
} else {
|
|
||||||
return schemas.DateTime
|
|
||||||
}
|
|
||||||
case schemas.TimeStampz:
|
case schemas.TimeStampz:
|
||||||
res = "DATETIMEOFFSET"
|
res = "DATETIMEOFFSET"
|
||||||
c.Length = 7
|
c.Length = 7
|
||||||
@ -428,7 +424,7 @@ func (db *mssql) DropTableSQL(tableName string) (string, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *mssql) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
func (db *mssql) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
s, _ := ColumnString(db.dialect, col, false)
|
s, _ := ColumnString(db.dialect, col, false, true)
|
||||||
return fmt.Sprintf("ALTER TABLE %s ALTER COLUMN %s", db.quoter.Quote(tableName), s)
|
return fmt.Sprintf("ALTER TABLE %s ALTER COLUMN %s", db.quoter.Quote(tableName), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +450,7 @@ func (db *mssql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
|
|||||||
s := `select a.name as name, b.name as ctype,a.max_length,a.precision,a.scale,a.is_nullable as nullable,
|
s := `select a.name as name, b.name as ctype,a.max_length,a.precision,a.scale,a.is_nullable as nullable,
|
||||||
"default_is_null" = (CASE WHEN c.text is null THEN 1 ELSE 0 END),
|
"default_is_null" = (CASE WHEN c.text is null THEN 1 ELSE 0 END),
|
||||||
replace(replace(isnull(c.text,''),'(',''),')','') as vdefault,
|
replace(replace(isnull(c.text,''),'(',''),')','') as vdefault,
|
||||||
ISNULL(p.is_primary_key, 0), a.is_identity as is_identity
|
ISNULL(p.is_primary_key, 0), a.is_identity as is_identity, a.collation_name
|
||||||
from sys.columns a
|
from sys.columns a
|
||||||
left join sys.types b on a.user_type_id=b.user_type_id
|
left join sys.types b on a.user_type_id=b.user_type_id
|
||||||
left join sys.syscomments c on a.default_object_id=c.id
|
left join sys.syscomments c on a.default_object_id=c.id
|
||||||
@ -475,9 +471,10 @@ func (db *mssql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
|
|||||||
colSeq := make([]string, 0)
|
colSeq := make([]string, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var name, ctype, vdefault string
|
var name, ctype, vdefault string
|
||||||
|
var collation *string
|
||||||
var maxLen, precision, scale int64
|
var maxLen, precision, scale int64
|
||||||
var nullable, isPK, defaultIsNull, isIncrement bool
|
var nullable, isPK, defaultIsNull, isIncrement bool
|
||||||
err = rows.Scan(&name, &ctype, &maxLen, &precision, &scale, &nullable, &defaultIsNull, &vdefault, &isPK, &isIncrement)
|
err = rows.Scan(&name, &ctype, &maxLen, &precision, &scale, &nullable, &defaultIsNull, &vdefault, &isPK, &isIncrement, &collation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -499,6 +496,9 @@ func (db *mssql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
|
|||||||
} else {
|
} else {
|
||||||
col.Length = maxLen
|
col.Length = maxLen
|
||||||
}
|
}
|
||||||
|
if collation != nil {
|
||||||
|
col.Collation = *collation
|
||||||
|
}
|
||||||
switch ct {
|
switch ct {
|
||||||
case "DATETIMEOFFSET":
|
case "DATETIMEOFFSET":
|
||||||
col.SQLType = schemas.SQLType{Name: schemas.TimeStampz, DefaultLength: 0, DefaultLength2: 0}
|
col.SQLType = schemas.SQLType{Name: schemas.TimeStampz, DefaultLength: 0, DefaultLength2: 0}
|
||||||
@ -646,7 +646,7 @@ func (db *mssql) CreateTableSQL(ctx context.Context, queryer core.Queryer, table
|
|||||||
|
|
||||||
for i, colName := range table.ColumnsSeq() {
|
for i, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1)
|
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1, true)
|
||||||
b.WriteString(s)
|
b.WriteString(s)
|
||||||
|
|
||||||
if i != len(table.ColumnsSeq())-1 {
|
if i != len(table.ColumnsSeq())-1 {
|
||||||
@ -665,10 +665,6 @@ func (db *mssql) CreateTableSQL(ctx context.Context, queryer core.Queryer, table
|
|||||||
return b.String(), true, nil
|
return b.String(), true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *mssql) ForUpdateSQL(query string) string {
|
|
||||||
return query
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *mssql) Filters() []Filter {
|
func (db *mssql) Filters() []Filter {
|
||||||
return []Filter{}
|
return []Filter{}
|
||||||
}
|
}
|
||||||
|
46
vendor/xorm.io/xorm/dialects/mysql.go
generated
vendored
46
vendor/xorm.io/xorm/dialects/mysql.go
generated
vendored
@ -38,6 +38,7 @@ var (
|
|||||||
"CALL": true,
|
"CALL": true,
|
||||||
"CASCADE": true,
|
"CASCADE": true,
|
||||||
"CASE": true,
|
"CASE": true,
|
||||||
|
"CHAIN": true,
|
||||||
"CHANGE": true,
|
"CHANGE": true,
|
||||||
"CHAR": true,
|
"CHAR": true,
|
||||||
"CHARACTER": true,
|
"CHARACTER": true,
|
||||||
@ -128,6 +129,7 @@ var (
|
|||||||
"OUT": true, "OUTER": true, "OUTFILE": true,
|
"OUT": true, "OUTER": true, "OUTFILE": true,
|
||||||
"PRECISION": true, "PRIMARY": true, "PROCEDURE": true,
|
"PRECISION": true, "PRIMARY": true, "PROCEDURE": true,
|
||||||
"PURGE": true, "RAID0": true, "RANGE": true,
|
"PURGE": true, "RAID0": true, "RANGE": true,
|
||||||
|
"RANK": true,
|
||||||
"READ": true, "READS": true, "REAL": true,
|
"READ": true, "READS": true, "REAL": true,
|
||||||
"REFERENCES": true, "REGEXP": true, "RELEASE": true,
|
"REFERENCES": true, "REGEXP": true, "RELEASE": true,
|
||||||
"RENAME": true, "REPEAT": true, "REPLACE": true,
|
"RENAME": true, "REPEAT": true, "REPLACE": true,
|
||||||
@ -380,12 +382,27 @@ func (db *mysql) IsTableExist(queryer core.Queryer, ctx context.Context, tableNa
|
|||||||
|
|
||||||
func (db *mysql) AddColumnSQL(tableName string, col *schemas.Column) string {
|
func (db *mysql) AddColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
quoter := db.dialect.Quoter()
|
quoter := db.dialect.Quoter()
|
||||||
s, _ := ColumnString(db, col, true)
|
s, _ := ColumnString(db, col, true, true)
|
||||||
sql := fmt.Sprintf("ALTER TABLE %v ADD %v", quoter.Quote(tableName), s)
|
var b strings.Builder
|
||||||
|
b.WriteString("ALTER TABLE ")
|
||||||
|
quoter.QuoteTo(&b, tableName)
|
||||||
|
b.WriteString(" ADD ")
|
||||||
|
b.WriteString(s)
|
||||||
if len(col.Comment) > 0 {
|
if len(col.Comment) > 0 {
|
||||||
sql += " COMMENT '" + col.Comment + "'"
|
b.WriteString(" COMMENT '")
|
||||||
|
b.WriteString(col.Comment)
|
||||||
|
b.WriteString("'")
|
||||||
}
|
}
|
||||||
return sql
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ModifyColumnSQL returns a SQL to modify SQL
|
||||||
|
func (db *mysql) ModifyColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
|
s, _ := ColumnString(db.dialect, col, false, true)
|
||||||
|
if col.Comment != "" {
|
||||||
|
s += fmt.Sprintf(" COMMENT '%s'", col.Comment)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("ALTER TABLE %s MODIFY COLUMN %s", db.quoter.Quote(tableName), s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) {
|
func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName string) ([]string, map[string]*schemas.Column, error) {
|
||||||
@ -398,7 +415,7 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
|
|||||||
"SUBSTRING_INDEX(SUBSTRING(VERSION(), 6), '-', 1) >= 7)))))"
|
"SUBSTRING_INDEX(SUBSTRING(VERSION(), 6), '-', 1) >= 7)))))"
|
||||||
s := "SELECT `COLUMN_NAME`, `IS_NULLABLE`, `COLUMN_DEFAULT`, `COLUMN_TYPE`," +
|
s := "SELECT `COLUMN_NAME`, `IS_NULLABLE`, `COLUMN_DEFAULT`, `COLUMN_TYPE`," +
|
||||||
" `COLUMN_KEY`, `EXTRA`, `COLUMN_COMMENT`, `CHARACTER_MAXIMUM_LENGTH`, " +
|
" `COLUMN_KEY`, `EXTRA`, `COLUMN_COMMENT`, `CHARACTER_MAXIMUM_LENGTH`, " +
|
||||||
alreadyQuoted + " AS NEEDS_QUOTE " +
|
alreadyQuoted + " AS NEEDS_QUOTE, `COLLATION_NAME` " +
|
||||||
"FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?" +
|
"FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?" +
|
||||||
" ORDER BY `COLUMNS`.ORDINAL_POSITION ASC"
|
" ORDER BY `COLUMNS`.ORDINAL_POSITION ASC"
|
||||||
|
|
||||||
@ -416,8 +433,8 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
|
|||||||
|
|
||||||
var columnName, nullableStr, colType, colKey, extra, comment string
|
var columnName, nullableStr, colType, colKey, extra, comment string
|
||||||
var alreadyQuoted, isUnsigned bool
|
var alreadyQuoted, isUnsigned bool
|
||||||
var colDefault, maxLength *string
|
var colDefault, maxLength, collation *string
|
||||||
err = rows.Scan(&columnName, &nullableStr, &colDefault, &colType, &colKey, &extra, &comment, &maxLength, &alreadyQuoted)
|
err = rows.Scan(&columnName, &nullableStr, &colDefault, &colType, &colKey, &extra, &comment, &maxLength, &alreadyQuoted, &collation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -433,6 +450,9 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
|
|||||||
} else {
|
} else {
|
||||||
col.DefaultIsEmpty = true
|
col.DefaultIsEmpty = true
|
||||||
}
|
}
|
||||||
|
if collation != nil {
|
||||||
|
col.Collation = *collation
|
||||||
|
}
|
||||||
|
|
||||||
fields := strings.Fields(colType)
|
fields := strings.Fields(colType)
|
||||||
if len(fields) == 2 && fields[1] == "unsigned" {
|
if len(fields) == 2 && fields[1] == "unsigned" {
|
||||||
@ -525,7 +545,7 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
|
|||||||
|
|
||||||
func (db *mysql) GetTables(queryer core.Queryer, ctx context.Context) ([]*schemas.Table, error) {
|
func (db *mysql) GetTables(queryer core.Queryer, ctx context.Context) ([]*schemas.Table, error) {
|
||||||
args := []interface{}{db.uri.DBName}
|
args := []interface{}{db.uri.DBName}
|
||||||
s := "SELECT `TABLE_NAME`, `ENGINE`, `AUTO_INCREMENT`, `TABLE_COMMENT` from " +
|
s := "SELECT `TABLE_NAME`, `ENGINE`, `AUTO_INCREMENT`, `TABLE_COMMENT`, `TABLE_COLLATION` from " +
|
||||||
"`INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? AND (`ENGINE`='MyISAM' OR `ENGINE` = 'InnoDB' OR `ENGINE` = 'TokuDB')"
|
"`INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_SCHEMA`=? AND (`ENGINE`='MyISAM' OR `ENGINE` = 'InnoDB' OR `ENGINE` = 'TokuDB')"
|
||||||
|
|
||||||
rows, err := queryer.QueryContext(ctx, s, args...)
|
rows, err := queryer.QueryContext(ctx, s, args...)
|
||||||
@ -537,9 +557,9 @@ func (db *mysql) GetTables(queryer core.Queryer, ctx context.Context) ([]*schema
|
|||||||
tables := make([]*schemas.Table, 0)
|
tables := make([]*schemas.Table, 0)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
table := schemas.NewEmptyTable()
|
table := schemas.NewEmptyTable()
|
||||||
var name, engine string
|
var name, engine, collation string
|
||||||
var autoIncr, comment *string
|
var autoIncr, comment *string
|
||||||
err = rows.Scan(&name, &engine, &autoIncr, &comment)
|
err = rows.Scan(&name, &engine, &autoIncr, &comment, &collation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -549,6 +569,7 @@ func (db *mysql) GetTables(queryer core.Queryer, ctx context.Context) ([]*schema
|
|||||||
table.Comment = *comment
|
table.Comment = *comment
|
||||||
}
|
}
|
||||||
table.StoreEngine = engine
|
table.StoreEngine = engine
|
||||||
|
table.Collation = collation
|
||||||
tables = append(tables, table)
|
tables = append(tables, table)
|
||||||
}
|
}
|
||||||
if rows.Err() != nil {
|
if rows.Err() != nil {
|
||||||
@ -640,7 +661,7 @@ func (db *mysql) CreateTableSQL(ctx context.Context, queryer core.Queryer, table
|
|||||||
|
|
||||||
for i, colName := range table.ColumnsSeq() {
|
for i, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1)
|
s, _ := ColumnString(db.dialect, col, col.IsPrimaryKey && len(table.PrimaryKeys) == 1, true)
|
||||||
b.WriteString(s)
|
b.WriteString(s)
|
||||||
|
|
||||||
if len(col.Comment) > 0 {
|
if len(col.Comment) > 0 {
|
||||||
@ -738,8 +759,9 @@ func (p *mysqlDriver) Parse(driverName, dataSourceName string) (*URI, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *mysqlDriver) GenScanResult(colType string) (interface{}, error) {
|
func (p *mysqlDriver) GenScanResult(colType string) (interface{}, error) {
|
||||||
|
colType = strings.Replace(colType, "UNSIGNED ", "", -1)
|
||||||
switch colType {
|
switch colType {
|
||||||
case "CHAR", "VARCHAR", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT", "ENUM", "SET":
|
case "CHAR", "VARCHAR", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT", "ENUM", "SET", "JSON":
|
||||||
var s sql.NullString
|
var s sql.NullString
|
||||||
return &s, nil
|
return &s, nil
|
||||||
case "BIGINT":
|
case "BIGINT":
|
||||||
|
23
vendor/xorm.io/xorm/dialects/oracle.go
generated
vendored
23
vendor/xorm.io/xorm/dialects/oracle.go
generated
vendored
@ -548,7 +548,14 @@ func (db *oracle) Features() *DialectFeatures {
|
|||||||
func (db *oracle) SQLType(c *schemas.Column) string {
|
func (db *oracle) SQLType(c *schemas.Column) string {
|
||||||
var res string
|
var res string
|
||||||
switch t := c.SQLType.Name; t {
|
switch t := c.SQLType.Name; t {
|
||||||
case schemas.Bit, schemas.TinyInt, schemas.SmallInt, schemas.MediumInt, schemas.Int, schemas.Integer, schemas.BigInt, schemas.Bool, schemas.Serial, schemas.BigSerial:
|
case schemas.Bool:
|
||||||
|
if c.Default == "true" {
|
||||||
|
c.Default = "1"
|
||||||
|
} else if c.Default == "false" {
|
||||||
|
c.Default = "0"
|
||||||
|
}
|
||||||
|
res = "NUMBER(1,0)"
|
||||||
|
case schemas.Bit, schemas.TinyInt, schemas.SmallInt, schemas.MediumInt, schemas.Int, schemas.Integer, schemas.BigInt, schemas.Serial, schemas.BigSerial:
|
||||||
res = "NUMBER"
|
res = "NUMBER"
|
||||||
case schemas.Binary, schemas.VarBinary, schemas.Blob, schemas.TinyBlob, schemas.MediumBlob, schemas.LongBlob, schemas.Bytea:
|
case schemas.Binary, schemas.VarBinary, schemas.Blob, schemas.TinyBlob, schemas.MediumBlob, schemas.LongBlob, schemas.Bytea:
|
||||||
return schemas.Blob
|
return schemas.Blob
|
||||||
@ -602,7 +609,7 @@ func (db *oracle) IsReserved(name string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *oracle) DropTableSQL(tableName string) (string, bool) {
|
func (db *oracle) DropTableSQL(tableName string) (string, bool) {
|
||||||
return fmt.Sprintf("DROP TABLE `%s`", tableName), false
|
return fmt.Sprintf("DROP TABLE \"%s\"", tableName), false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *oracle) CreateTableSQL(ctx context.Context, queryer core.Queryer, table *schemas.Table, tableName string) (string, bool, error) {
|
func (db *oracle) CreateTableSQL(ctx context.Context, queryer core.Queryer, table *schemas.Table, tableName string) (string, bool, error) {
|
||||||
@ -621,7 +628,7 @@ func (db *oracle) CreateTableSQL(ctx context.Context, queryer core.Queryer, tabl
|
|||||||
/*if col.IsPrimaryKey && len(pkList) == 1 {
|
/*if col.IsPrimaryKey && len(pkList) == 1 {
|
||||||
sql += col.String(b.dialect)
|
sql += col.String(b.dialect)
|
||||||
} else {*/
|
} else {*/
|
||||||
s, _ := ColumnString(db, col, false)
|
s, _ := ColumnString(db, col, false, false)
|
||||||
sql += s
|
sql += s
|
||||||
// }
|
// }
|
||||||
sql = strings.TrimSpace(sql)
|
sql = strings.TrimSpace(sql)
|
||||||
@ -638,6 +645,10 @@ func (db *oracle) CreateTableSQL(ctx context.Context, queryer core.Queryer, tabl
|
|||||||
return sql, false, nil
|
return sql, false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (db *oracle) IsSequenceExist(ctx context.Context, queryer core.Queryer, seqName string) (bool, error) {
|
||||||
|
return db.HasRecords(queryer, ctx, `SELECT sequence_name FROM user_sequences WHERE sequence_name = :1`, seqName)
|
||||||
|
}
|
||||||
|
|
||||||
func (db *oracle) SetQuotePolicy(quotePolicy QuotePolicy) {
|
func (db *oracle) SetQuotePolicy(quotePolicy QuotePolicy) {
|
||||||
switch quotePolicy {
|
switch quotePolicy {
|
||||||
case QuotePolicyNone:
|
case QuotePolicyNone:
|
||||||
@ -852,7 +863,7 @@ func (db *oracle) GetIndexes(queryer core.Queryer, ctx context.Context, tableNam
|
|||||||
|
|
||||||
func (db *oracle) Filters() []Filter {
|
func (db *oracle) Filters() []Filter {
|
||||||
return []Filter{
|
return []Filter{
|
||||||
&SeqFilter{Prefix: ":", Start: 1},
|
&oracleSeqFilter{Prefix: ":", Start: 1},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -932,3 +943,7 @@ func (o *oci8Driver) Parse(driverName, dataSourceName string) (*URI, error) {
|
|||||||
}
|
}
|
||||||
return db, nil
|
return db, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type oracleDriver struct {
|
||||||
|
godrorDriver
|
||||||
|
}
|
||||||
|
10
vendor/xorm.io/xorm/dialects/postgres.go
generated
vendored
10
vendor/xorm.io/xorm/dialects/postgres.go
generated
vendored
@ -992,7 +992,7 @@ func (db *postgres) IsTableExist(queryer core.Queryer, ctx context.Context, tabl
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *postgres) AddColumnSQL(tableName string, col *schemas.Column) string {
|
func (db *postgres) AddColumnSQL(tableName string, col *schemas.Column) string {
|
||||||
s, _ := ColumnString(db.dialect, col, true)
|
s, _ := ColumnString(db.dialect, col, true, false)
|
||||||
|
|
||||||
quoter := db.dialect.Quoter()
|
quoter := db.dialect.Quoter()
|
||||||
addColumnSQL := ""
|
addColumnSQL := ""
|
||||||
@ -1078,7 +1078,7 @@ FROM pg_attribute f
|
|||||||
LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey)
|
LEFT JOIN pg_constraint p ON p.conrelid = c.oid AND f.attnum = ANY (p.conkey)
|
||||||
LEFT JOIN pg_class AS g ON p.confrelid = g.oid
|
LEFT JOIN pg_class AS g ON p.confrelid = g.oid
|
||||||
LEFT JOIN INFORMATION_SCHEMA.COLUMNS s ON s.column_name=f.attname AND c.relname=s.table_name
|
LEFT JOIN INFORMATION_SCHEMA.COLUMNS s ON s.column_name=f.attname AND c.relname=s.table_name
|
||||||
WHERE n.nspname= s.table_schema AND c.relkind = 'r'::char AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.attnum;`
|
WHERE n.nspname= s.table_schema AND c.relkind = 'r' AND c.relname = $1%s AND f.attnum > 0 ORDER BY f.attnum;`
|
||||||
|
|
||||||
schema := db.getSchema()
|
schema := db.getSchema()
|
||||||
if schema != "" {
|
if schema != "" {
|
||||||
@ -1343,14 +1343,14 @@ func (db *postgres) CreateTableSQL(ctx context.Context, queryer core.Queryer, ta
|
|||||||
commentSQL := "; "
|
commentSQL := "; "
|
||||||
if table.Comment != "" {
|
if table.Comment != "" {
|
||||||
// support schema.table -> "schema"."table"
|
// support schema.table -> "schema"."table"
|
||||||
commentSQL += fmt.Sprintf("COMMENT ON TABLE %s IS '%s'", quoter.Quote(tableName), table.Comment)
|
commentSQL += fmt.Sprintf("COMMENT ON TABLE %s IS '%s'; ", quoter.Quote(tableName), table.Comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, colName := range table.ColumnsSeq() {
|
for _, colName := range table.ColumnsSeq() {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
|
|
||||||
if len(col.Comment) > 0 {
|
if len(col.Comment) > 0 {
|
||||||
commentSQL += fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s'", quoter.Quote(tableName), quoter.Quote(col.Name), col.Comment)
|
commentSQL += fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s'; ", quoter.Quote(tableName), quoter.Quote(col.Name), col.Comment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1358,7 +1358,7 @@ func (db *postgres) CreateTableSQL(ctx context.Context, queryer core.Queryer, ta
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (db *postgres) Filters() []Filter {
|
func (db *postgres) Filters() []Filter {
|
||||||
return []Filter{&SeqFilter{Prefix: "$", Start: 1}}
|
return []Filter{&postgresSeqFilter{Prefix: "$", Start: 1}}
|
||||||
}
|
}
|
||||||
|
|
||||||
type pqDriver struct {
|
type pqDriver struct {
|
||||||
|
10
vendor/xorm.io/xorm/dialects/sqlite3.go
generated
vendored
10
vendor/xorm.io/xorm/dialects/sqlite3.go
generated
vendored
@ -193,11 +193,11 @@ func (db *sqlite3) Features() *DialectFeatures {
|
|||||||
func (db *sqlite3) SetQuotePolicy(quotePolicy QuotePolicy) {
|
func (db *sqlite3) SetQuotePolicy(quotePolicy QuotePolicy) {
|
||||||
switch quotePolicy {
|
switch quotePolicy {
|
||||||
case QuotePolicyNone:
|
case QuotePolicyNone:
|
||||||
var q = sqlite3Quoter
|
q := sqlite3Quoter
|
||||||
q.IsReserved = schemas.AlwaysNoReserve
|
q.IsReserved = schemas.AlwaysNoReserve
|
||||||
db.quoter = q
|
db.quoter = q
|
||||||
case QuotePolicyReserved:
|
case QuotePolicyReserved:
|
||||||
var q = sqlite3Quoter
|
q := sqlite3Quoter
|
||||||
q.IsReserved = db.IsReserved
|
q.IsReserved = db.IsReserved
|
||||||
db.quoter = q
|
db.quoter = q
|
||||||
case QuotePolicyAlways:
|
case QuotePolicyAlways:
|
||||||
@ -291,10 +291,6 @@ func (db *sqlite3) DropIndexSQL(tableName string, index *schemas.Index) string {
|
|||||||
return fmt.Sprintf("DROP INDEX %v", db.Quoter().Quote(idxName))
|
return fmt.Sprintf("DROP INDEX %v", db.Quoter().Quote(idxName))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (db *sqlite3) ForUpdateSQL(query string) string {
|
|
||||||
return query
|
|
||||||
}
|
|
||||||
|
|
||||||
func (db *sqlite3) IsColumnExist(queryer core.Queryer, ctx context.Context, tableName, colName string) (bool, error) {
|
func (db *sqlite3) IsColumnExist(queryer core.Queryer, ctx context.Context, tableName, colName string) (bool, error) {
|
||||||
query := "SELECT * FROM " + tableName + " LIMIT 0"
|
query := "SELECT * FROM " + tableName + " LIMIT 0"
|
||||||
rows, err := queryer.QueryContext(ctx, query)
|
rows, err := queryer.QueryContext(ctx, query)
|
||||||
@ -320,7 +316,7 @@ func (db *sqlite3) IsColumnExist(queryer core.Queryer, ctx context.Context, tabl
|
|||||||
// splitColStr splits a sqlite col strings as fields
|
// splitColStr splits a sqlite col strings as fields
|
||||||
func splitColStr(colStr string) []string {
|
func splitColStr(colStr string) []string {
|
||||||
colStr = strings.TrimSpace(colStr)
|
colStr = strings.TrimSpace(colStr)
|
||||||
var results = make([]string, 0, 10)
|
results := make([]string, 0, 10)
|
||||||
var lastIdx int
|
var lastIdx int
|
||||||
var hasC, hasQuote bool
|
var hasC, hasQuote bool
|
||||||
for i, c := range colStr {
|
for i, c := range colStr {
|
||||||
|
251
vendor/xorm.io/xorm/doc.go
generated
vendored
251
vendor/xorm.io/xorm/doc.go
generated
vendored
@ -3,247 +3,246 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Package xorm is a simple and powerful ORM for Go.
|
Package xorm is a simple and powerful ORM for Go.
|
||||||
|
|
||||||
Installation
|
# Installation
|
||||||
|
|
||||||
Make sure you have installed Go 1.11+ and then:
|
Make sure you have installed Go 1.11+ and then:
|
||||||
|
|
||||||
go get xorm.io/xorm
|
go get xorm.io/xorm
|
||||||
|
|
||||||
Create Engine
|
# Create Engine
|
||||||
|
|
||||||
Firstly, we should create an engine for a database
|
Firstly, we should create an engine for a database
|
||||||
|
|
||||||
engine, err := xorm.NewEngine(driverName, dataSourceName)
|
engine, err := xorm.NewEngine(driverName, dataSourceName)
|
||||||
|
|
||||||
Method NewEngine's parameters are the same as sql.Open which depend drivers' implementation.
|
Method NewEngine's parameters are the same as sql.Open which depend drivers' implementation.
|
||||||
Generally, one engine for an application is enough. You can define it as a package variable.
|
Generally, one engine for an application is enough. You can define it as a package variable.
|
||||||
|
|
||||||
Raw Methods
|
# Raw Methods
|
||||||
|
|
||||||
XORM supports raw SQL execution:
|
XORM supports raw SQL execution:
|
||||||
|
|
||||||
1. query with a SQL string, the returned results is []map[string][]byte
|
1. query with a SQL string, the returned results is []map[string][]byte
|
||||||
|
|
||||||
results, err := engine.Query("select * from user")
|
results, err := engine.Query("select * from user")
|
||||||
|
|
||||||
2. query with a SQL string, the returned results is []map[string]string
|
2. query with a SQL string, the returned results is []map[string]string
|
||||||
|
|
||||||
results, err := engine.QueryString("select * from user")
|
results, err := engine.QueryString("select * from user")
|
||||||
|
|
||||||
3. query with a SQL string, the returned results is []map[string]interface{}
|
3. query with a SQL string, the returned results is []map[string]interface{}
|
||||||
|
|
||||||
results, err := engine.QueryInterface("select * from user")
|
results, err := engine.QueryInterface("select * from user")
|
||||||
|
|
||||||
4. execute with a SQL string, the returned results
|
4. execute with a SQL string, the returned results
|
||||||
|
|
||||||
affected, err := engine.Exec("update user set .... where ...")
|
affected, err := engine.Exec("update user set .... where ...")
|
||||||
|
|
||||||
ORM Methods
|
# ORM Methods
|
||||||
|
|
||||||
There are 8 major ORM methods and many helpful methods to use to operate database.
|
There are 8 major ORM methods and many helpful methods to use to operate database.
|
||||||
|
|
||||||
1. Insert one or multiple records to database
|
1. Insert one or multiple records to database
|
||||||
|
|
||||||
affected, err := engine.Insert(&struct)
|
affected, err := engine.Insert(&struct)
|
||||||
// INSERT INTO struct () values ()
|
// INSERT INTO struct () values ()
|
||||||
affected, err := engine.Insert(&struct1, &struct2)
|
affected, err := engine.Insert(&struct1, &struct2)
|
||||||
// INSERT INTO struct1 () values ()
|
// INSERT INTO struct1 () values ()
|
||||||
// INSERT INTO struct2 () values ()
|
// INSERT INTO struct2 () values ()
|
||||||
affected, err := engine.Insert(&sliceOfStruct)
|
affected, err := engine.Insert(&sliceOfStruct)
|
||||||
// INSERT INTO struct () values (),(),()
|
// INSERT INTO struct () values (),(),()
|
||||||
affected, err := engine.Insert(&struct1, &sliceOfStruct2)
|
affected, err := engine.Insert(&struct1, &sliceOfStruct2)
|
||||||
// INSERT INTO struct1 () values ()
|
// INSERT INTO struct1 () values ()
|
||||||
// INSERT INTO struct2 () values (),(),()
|
// INSERT INTO struct2 () values (),(),()
|
||||||
|
|
||||||
2. Query one record or one variable from database
|
2. Query one record or one variable from database
|
||||||
|
|
||||||
has, err := engine.Get(&user)
|
has, err := engine.Get(&user)
|
||||||
// SELECT * FROM user LIMIT 1
|
// SELECT * FROM user LIMIT 1
|
||||||
|
|
||||||
var id int64
|
var id int64
|
||||||
has, err := engine.Table("user").Where("name = ?", name).Get(&id)
|
has, err := engine.Table("user").Where("name = ?", name).Get(&id)
|
||||||
// SELECT id FROM user WHERE name = ? LIMIT 1
|
// SELECT id FROM user WHERE name = ? LIMIT 1
|
||||||
|
|
||||||
var id int64
|
var id int64
|
||||||
var name string
|
var name string
|
||||||
has, err := engine.Table(&user).Cols("id", "name").Get(&id, &name)
|
has, err := engine.Table(&user).Cols("id", "name").Get(&id, &name)
|
||||||
// SELECT id, name FROM user LIMIT 1
|
// SELECT id, name FROM user LIMIT 1
|
||||||
|
|
||||||
3. Query multiple records from database
|
3. Query multiple records from database
|
||||||
|
|
||||||
var sliceOfStructs []Struct
|
var sliceOfStructs []Struct
|
||||||
err := engine.Find(&sliceOfStructs)
|
err := engine.Find(&sliceOfStructs)
|
||||||
// SELECT * FROM user
|
// SELECT * FROM user
|
||||||
|
|
||||||
var mapOfStructs = make(map[int64]Struct)
|
var mapOfStructs = make(map[int64]Struct)
|
||||||
err := engine.Find(&mapOfStructs)
|
err := engine.Find(&mapOfStructs)
|
||||||
// SELECT * FROM user
|
// SELECT * FROM user
|
||||||
|
|
||||||
var int64s []int64
|
var int64s []int64
|
||||||
err := engine.Table("user").Cols("id").Find(&int64s)
|
err := engine.Table("user").Cols("id").Find(&int64s)
|
||||||
// SELECT id FROM user
|
// SELECT id FROM user
|
||||||
|
|
||||||
4. Query multiple records and record by record handle, there two methods, one is Iterate,
|
4. Query multiple records and record by record handle, there two methods, one is Iterate,
|
||||||
another is Rows
|
another is Rows
|
||||||
|
|
||||||
err := engine.Iterate(new(User), func(i int, bean interface{}) error {
|
err := engine.Iterate(new(User), func(i int, bean interface{}) error {
|
||||||
// do something
|
// do something
|
||||||
})
|
})
|
||||||
// SELECT * FROM user
|
// SELECT * FROM user
|
||||||
|
|
||||||
rows, err := engine.Rows(...)
|
rows, err := engine.Rows(...)
|
||||||
// SELECT * FROM user
|
// SELECT * FROM user
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
bean := new(Struct)
|
bean := new(Struct)
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
err = rows.Scan(bean)
|
err = rows.Scan(bean)
|
||||||
}
|
}
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
rows, err := engine.Cols("name", "age").Rows(...)
|
rows, err := engine.Cols("name", "age").Rows(...)
|
||||||
// SELECT * FROM user
|
// SELECT * FROM user
|
||||||
defer rows.Close()
|
defer rows.Close()
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var name string
|
var name string
|
||||||
var age int
|
var age int
|
||||||
err = rows.Scan(&name, &age)
|
err = rows.Scan(&name, &age)
|
||||||
}
|
}
|
||||||
|
|
||||||
5. Update one or more records
|
5. Update one or more records
|
||||||
|
|
||||||
affected, err := engine.ID(...).Update(&user)
|
affected, err := engine.ID(...).Update(&user)
|
||||||
// UPDATE user SET ...
|
// UPDATE user SET ...
|
||||||
|
|
||||||
6. Delete one or more records, Delete MUST has condition
|
6. Delete one or more records, Delete MUST has condition
|
||||||
|
|
||||||
affected, err := engine.Where(...).Delete(&user)
|
affected, err := engine.Where(...).Delete(&user)
|
||||||
// DELETE FROM user Where ...
|
// DELETE FROM user Where ...
|
||||||
|
|
||||||
7. Count records
|
7. Count records
|
||||||
|
|
||||||
counts, err := engine.Count(&user)
|
counts, err := engine.Count(&user)
|
||||||
// SELECT count(*) AS total FROM user
|
// SELECT count(*) AS total FROM user
|
||||||
|
|
||||||
counts, err := engine.SQL("select count(*) FROM user").Count()
|
counts, err := engine.SQL("select count(*) FROM user").Count()
|
||||||
// select count(*) FROM user
|
// select count(*) FROM user
|
||||||
|
|
||||||
8. Sum records
|
8. Sum records
|
||||||
|
|
||||||
sumFloat64, err := engine.Sum(&user, "id")
|
sumFloat64, err := engine.Sum(&user, "id")
|
||||||
// SELECT sum(id) from user
|
// SELECT sum(id) from user
|
||||||
|
|
||||||
sumFloat64s, err := engine.Sums(&user, "id1", "id2")
|
sumFloat64s, err := engine.Sums(&user, "id1", "id2")
|
||||||
// SELECT sum(id1), sum(id2) from user
|
// SELECT sum(id1), sum(id2) from user
|
||||||
|
|
||||||
sumInt64s, err := engine.SumsInt(&user, "id1", "id2")
|
sumInt64s, err := engine.SumsInt(&user, "id1", "id2")
|
||||||
// SELECT sum(id1), sum(id2) from user
|
// SELECT sum(id1), sum(id2) from user
|
||||||
|
|
||||||
Conditions
|
# Conditions
|
||||||
|
|
||||||
The above 8 methods could use with condition methods chainable.
|
The above 8 methods could use with condition methods chainable.
|
||||||
Notice: the above 8 methods should be the last chainable method.
|
Notice: the above 8 methods should be the last chainable method.
|
||||||
|
|
||||||
1. ID, In
|
1. ID, In
|
||||||
|
|
||||||
engine.ID(1).Get(&user) // for single primary key
|
engine.ID(1).Get(&user) // for single primary key
|
||||||
// SELECT * FROM user WHERE id = 1
|
// SELECT * FROM user WHERE id = 1
|
||||||
engine.ID(schemas.PK{1, 2}).Get(&user) // for composite primary keys
|
engine.ID(schemas.PK{1, 2}).Get(&user) // for composite primary keys
|
||||||
// SELECT * FROM user WHERE id1 = 1 AND id2 = 2
|
// SELECT * FROM user WHERE id1 = 1 AND id2 = 2
|
||||||
engine.In("id", 1, 2, 3).Find(&users)
|
engine.In("id", 1, 2, 3).Find(&users)
|
||||||
// SELECT * FROM user WHERE id IN (1, 2, 3)
|
// SELECT * FROM user WHERE id IN (1, 2, 3)
|
||||||
engine.In("id", []int{1, 2, 3}).Find(&users)
|
engine.In("id", []int{1, 2, 3}).Find(&users)
|
||||||
// SELECT * FROM user WHERE id IN (1, 2, 3)
|
// SELECT * FROM user WHERE id IN (1, 2, 3)
|
||||||
|
|
||||||
2. Where, And, Or
|
2. Where, And, Or
|
||||||
|
|
||||||
engine.Where().And().Or().Find()
|
engine.Where().And().Or().Find()
|
||||||
// SELECT * FROM user WHERE (.. AND ..) OR ...
|
// SELECT * FROM user WHERE (.. AND ..) OR ...
|
||||||
|
|
||||||
3. OrderBy, Asc, Desc
|
3. OrderBy, Asc, Desc
|
||||||
|
|
||||||
engine.Asc().Desc().Find()
|
engine.Asc().Desc().Find()
|
||||||
// SELECT * FROM user ORDER BY .. ASC, .. DESC
|
// SELECT * FROM user ORDER BY .. ASC, .. DESC
|
||||||
engine.OrderBy().Find()
|
engine.OrderBy().Find()
|
||||||
// SELECT * FROM user ORDER BY ..
|
// SELECT * FROM user ORDER BY ..
|
||||||
|
|
||||||
4. Limit, Top
|
4. Limit, Top
|
||||||
|
|
||||||
engine.Limit().Find()
|
engine.Limit().Find()
|
||||||
// SELECT * FROM user LIMIT .. OFFSET ..
|
// SELECT * FROM user LIMIT .. OFFSET ..
|
||||||
engine.Top(5).Find()
|
engine.Top(5).Find()
|
||||||
// SELECT TOP 5 * FROM user // for mssql
|
// SELECT TOP 5 * FROM user // for mssql
|
||||||
// SELECT * FROM user LIMIT .. OFFSET 0 //for other databases
|
// SELECT * FROM user LIMIT .. OFFSET 0 //for other databases
|
||||||
|
|
||||||
5. SQL, let you custom SQL
|
5. SQL, let you custom SQL
|
||||||
|
|
||||||
var users []User
|
var users []User
|
||||||
engine.SQL("select * from user").Find(&users)
|
engine.SQL("select * from user").Find(&users)
|
||||||
|
|
||||||
6. Cols, Omit, Distinct
|
6. Cols, Omit, Distinct
|
||||||
|
|
||||||
var users []*User
|
var users []*User
|
||||||
engine.Cols("col1, col2").Find(&users)
|
engine.Cols("col1, col2").Find(&users)
|
||||||
// SELECT col1, col2 FROM user
|
// SELECT col1, col2 FROM user
|
||||||
engine.Cols("col1", "col2").Where().Update(user)
|
engine.Cols("col1", "col2").Where().Update(user)
|
||||||
// UPDATE user set col1 = ?, col2 = ? Where ...
|
// UPDATE user set col1 = ?, col2 = ? Where ...
|
||||||
engine.Omit("col1").Find(&users)
|
engine.Omit("col1").Find(&users)
|
||||||
// SELECT col2, col3 FROM user
|
// SELECT col2, col3 FROM user
|
||||||
engine.Omit("col1").Insert(&user)
|
engine.Omit("col1").Insert(&user)
|
||||||
// INSERT INTO table (non-col1) VALUES ()
|
// INSERT INTO table (non-col1) VALUES ()
|
||||||
engine.Distinct("col1").Find(&users)
|
engine.Distinct("col1").Find(&users)
|
||||||
// SELECT DISTINCT col1 FROM user
|
// SELECT DISTINCT col1 FROM user
|
||||||
|
|
||||||
7. Join, GroupBy, Having
|
7. Join, GroupBy, Having
|
||||||
|
|
||||||
engine.GroupBy("name").Having("name='xlw'").Find(&users)
|
engine.GroupBy("name").Having("name='xlw'").Find(&users)
|
||||||
//SELECT * FROM user GROUP BY name HAVING name='xlw'
|
//SELECT * FROM user GROUP BY name HAVING name='xlw'
|
||||||
engine.Join("LEFT", "userdetail", "user.id=userdetail.id").Find(&users)
|
engine.Join("LEFT", "userdetail", "user.id=userdetail.id").Find(&users)
|
||||||
//SELECT * FROM user LEFT JOIN userdetail ON user.id=userdetail.id
|
//SELECT * FROM user LEFT JOIN userdetail ON user.id=userdetail.id
|
||||||
|
|
||||||
Builder
|
# Builder
|
||||||
|
|
||||||
xorm could work with xorm.io/builder directly.
|
xorm could work with xorm.io/builder directly.
|
||||||
|
|
||||||
1. With Where
|
1. With Where
|
||||||
|
|
||||||
var cond = builder.Eq{"a":1, "b":2}
|
var cond = builder.Eq{"a":1, "b":2}
|
||||||
engine.Where(cond).Find(&users)
|
engine.Where(cond).Find(&users)
|
||||||
|
|
||||||
2. With In
|
2. With In
|
||||||
|
|
||||||
var subQuery = builder.Select("name").From("group")
|
var subQuery = builder.Select("name").From("group")
|
||||||
engine.In("group_name", subQuery).Find(&users)
|
engine.In("group_name", subQuery).Find(&users)
|
||||||
|
|
||||||
3. With Join
|
3. With Join
|
||||||
|
|
||||||
var subQuery = builder.Select("name").From("group")
|
var subQuery = builder.Select("name").From("group")
|
||||||
engine.Join("INNER", subQuery, "group.id = user.group_id").Find(&users)
|
engine.Join("INNER", subQuery, "group.id = user.group_id").Find(&users)
|
||||||
|
|
||||||
4. With SetExprs
|
4. With SetExprs
|
||||||
|
|
||||||
var subQuery = builder.Select("name").From("group")
|
var subQuery = builder.Select("name").From("group")
|
||||||
engine.ID(1).SetExprs("name", subQuery).Update(new(User))
|
engine.ID(1).SetExprs("name", subQuery).Update(new(User))
|
||||||
|
|
||||||
5. With SQL
|
5. With SQL
|
||||||
|
|
||||||
var query = builder.Select("name").From("group")
|
var query = builder.Select("name").From("group")
|
||||||
results, err := engine.SQL(query).Find(&groups)
|
results, err := engine.SQL(query).Find(&groups)
|
||||||
|
|
||||||
6. With Query
|
6. With Query
|
||||||
|
|
||||||
var query = builder.Select("name").From("group")
|
var query = builder.Select("name").From("group")
|
||||||
results, err := engine.Query(query)
|
results, err := engine.Query(query)
|
||||||
results, err := engine.QueryString(query)
|
results, err := engine.QueryString(query)
|
||||||
results, err := engine.QueryInterface(query)
|
results, err := engine.QueryInterface(query)
|
||||||
|
|
||||||
7. With Exec
|
7. With Exec
|
||||||
|
|
||||||
var query = builder.Insert("a, b").Into("table1").Select("b, c").From("table2")
|
var query = builder.Insert("a, b").Into("table1").Select("b, c").From("table2")
|
||||||
results, err := engine.Exec(query)
|
results, err := engine.Exec(query)
|
||||||
|
|
||||||
More usage, please visit http://xorm.io/docs
|
More usage, please visit http://xorm.io/docs
|
||||||
*/
|
*/
|
||||||
|
56
vendor/xorm.io/xorm/engine.go
generated
vendored
56
vendor/xorm.io/xorm/engine.go
generated
vendored
@ -254,6 +254,11 @@ func (engine *Engine) SetConnMaxLifetime(d time.Duration) {
|
|||||||
engine.DB().SetConnMaxLifetime(d)
|
engine.DB().SetConnMaxLifetime(d)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetConnMaxIdleTime sets the maximum amount of time a connection may be idle.
|
||||||
|
func (engine *Engine) SetConnMaxIdleTime(d time.Duration) {
|
||||||
|
engine.DB().SetConnMaxIdleTime(d)
|
||||||
|
}
|
||||||
|
|
||||||
// SetMaxOpenConns is only available for go 1.2+
|
// SetMaxOpenConns is only available for go 1.2+
|
||||||
func (engine *Engine) SetMaxOpenConns(conns int) {
|
func (engine *Engine) SetMaxOpenConns(conns int) {
|
||||||
engine.DB().SetMaxOpenConns(conns)
|
engine.DB().SetMaxOpenConns(conns)
|
||||||
@ -330,7 +335,7 @@ func (engine *Engine) Ping() error {
|
|||||||
// SQL method let's you manually write raw SQL and operate
|
// SQL method let's you manually write raw SQL and operate
|
||||||
// For example:
|
// For example:
|
||||||
//
|
//
|
||||||
// engine.SQL("select * from user").Find(&users)
|
// engine.SQL("select * from user").Find(&users)
|
||||||
//
|
//
|
||||||
// This code will execute "select * from user" and set the records to users
|
// This code will execute "select * from user" and set the records to users
|
||||||
func (engine *Engine) SQL(query interface{}, args ...interface{}) *Session {
|
func (engine *Engine) SQL(query interface{}, args ...interface{}) *Session {
|
||||||
@ -355,15 +360,15 @@ func (engine *Engine) NoAutoCondition(no ...bool) *Session {
|
|||||||
return session.NoAutoCondition(no...)
|
return session.NoAutoCondition(no...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (engine *Engine) loadTableInfo(table *schemas.Table) error {
|
func (engine *Engine) loadTableInfo(ctx context.Context, table *schemas.Table) error {
|
||||||
colSeq, cols, err := engine.dialect.GetColumns(engine.db, engine.defaultContext, table.Name)
|
colSeq, cols, err := engine.dialect.GetColumns(engine.db, ctx, table.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, name := range colSeq {
|
for _, name := range colSeq {
|
||||||
table.AddColumn(cols[name])
|
table.AddColumn(cols[name])
|
||||||
}
|
}
|
||||||
indexes, err := engine.dialect.GetIndexes(engine.db, engine.defaultContext, table.Name)
|
indexes, err := engine.dialect.GetIndexes(engine.db, ctx, table.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -399,7 +404,7 @@ func (engine *Engine) DBMetas() ([]*schemas.Table, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, table := range tables {
|
for _, table := range tables {
|
||||||
if err = engine.loadTableInfo(table); err != nil {
|
if err = engine.loadTableInfo(engine.defaultContext, table); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -815,6 +820,9 @@ func (engine *Engine) dumpTables(ctx context.Context, tables []*schemas.Table, w
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// !datbeohbbh! if no error, manually close
|
||||||
|
rows.Close()
|
||||||
|
sess.Close()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -996,9 +1004,8 @@ func (engine *Engine) Desc(colNames ...string) *Session {
|
|||||||
// Asc will generate "ORDER BY column1,column2 Asc"
|
// Asc will generate "ORDER BY column1,column2 Asc"
|
||||||
// This method can chainable use.
|
// This method can chainable use.
|
||||||
//
|
//
|
||||||
// engine.Desc("name").Asc("age").Find(&users)
|
// engine.Desc("name").Asc("age").Find(&users)
|
||||||
// // SELECT * FROM user ORDER BY name DESC, age ASC
|
// // SELECT * FROM user ORDER BY name DESC, age ASC
|
||||||
//
|
|
||||||
func (engine *Engine) Asc(colNames ...string) *Session {
|
func (engine *Engine) Asc(colNames ...string) *Session {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
session.isAutoClose = true
|
session.isAutoClose = true
|
||||||
@ -1020,7 +1027,7 @@ func (engine *Engine) Prepare() *Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Join the join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
// Join the join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
||||||
func (engine *Engine) Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session {
|
func (engine *Engine) Join(joinOperator string, tablename interface{}, condition interface{}, args ...interface{}) *Session {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
session.isAutoClose = true
|
session.isAutoClose = true
|
||||||
return session.Join(joinOperator, tablename, condition, args...)
|
return session.Join(joinOperator, tablename, condition, args...)
|
||||||
@ -1113,21 +1120,6 @@ func (engine *Engine) UnMapType(t reflect.Type) {
|
|||||||
engine.tagParser.ClearCacheTable(t)
|
engine.tagParser.ClearCacheTable(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync the new struct changes to database, this method will automatically add
|
|
||||||
// table, column, index, unique. but will not delete or change anything.
|
|
||||||
// If you change some field, you should change the database manually.
|
|
||||||
func (engine *Engine) Sync(beans ...interface{}) error {
|
|
||||||
session := engine.NewSession()
|
|
||||||
defer session.Close()
|
|
||||||
return session.Sync(beans...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync2 synchronize structs to database tables
|
|
||||||
// Depricated
|
|
||||||
func (engine *Engine) Sync2(beans ...interface{}) error {
|
|
||||||
return engine.Sync(beans...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateTables create tabls according bean
|
// CreateTables create tabls according bean
|
||||||
func (engine *Engine) CreateTables(beans ...interface{}) error {
|
func (engine *Engine) CreateTables(beans ...interface{}) error {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
@ -1220,9 +1212,10 @@ func (engine *Engine) InsertOne(bean interface{}) (int64, error) {
|
|||||||
// Update records, bean's non-empty fields are updated contents,
|
// Update records, bean's non-empty fields are updated contents,
|
||||||
// condiBean' non-empty filds are conditions
|
// condiBean' non-empty filds are conditions
|
||||||
// CAUTION:
|
// CAUTION:
|
||||||
// 1.bool will defaultly be updated content nor conditions
|
//
|
||||||
// You should call UseBool if you have bool to use.
|
// 1.bool will defaultly be updated content nor conditions
|
||||||
// 2.float32 & float64 may be not inexact as conditions
|
// You should call UseBool if you have bool to use.
|
||||||
|
// 2.float32 & float64 may be not inexact as conditions
|
||||||
func (engine *Engine) Update(bean interface{}, condiBeans ...interface{}) (int64, error) {
|
func (engine *Engine) Update(bean interface{}, condiBeans ...interface{}) (int64, error) {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
@ -1230,12 +1223,21 @@ func (engine *Engine) Update(bean interface{}, condiBeans ...interface{}) (int64
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete records, bean's non-empty fields are conditions
|
// Delete records, bean's non-empty fields are conditions
|
||||||
|
// At least one condition must be set.
|
||||||
func (engine *Engine) Delete(beans ...interface{}) (int64, error) {
|
func (engine *Engine) Delete(beans ...interface{}) (int64, error) {
|
||||||
session := engine.NewSession()
|
session := engine.NewSession()
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
return session.Delete(beans...)
|
return session.Delete(beans...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Truncate records, bean's non-empty fields are conditions
|
||||||
|
// In contrast to Delete this method allows deletes without conditions.
|
||||||
|
func (engine *Engine) Truncate(beans ...interface{}) (int64, error) {
|
||||||
|
session := engine.NewSession()
|
||||||
|
defer session.Close()
|
||||||
|
return session.Truncate(beans...)
|
||||||
|
}
|
||||||
|
|
||||||
// Get retrieve one record from table, bean's non-empty fields
|
// Get retrieve one record from table, bean's non-empty fields
|
||||||
// are conditions
|
// are conditions
|
||||||
func (engine *Engine) Get(beans ...interface{}) (bool, error) {
|
func (engine *Engine) Get(beans ...interface{}) (bool, error) {
|
||||||
|
4
vendor/xorm.io/xorm/interface.go
generated
vendored
4
vendor/xorm.io/xorm/interface.go
generated
vendored
@ -31,6 +31,7 @@ type Interface interface {
|
|||||||
Decr(column string, arg ...interface{}) *Session
|
Decr(column string, arg ...interface{}) *Session
|
||||||
Desc(...string) *Session
|
Desc(...string) *Session
|
||||||
Delete(...interface{}) (int64, error)
|
Delete(...interface{}) (int64, error)
|
||||||
|
Truncate(...interface{}) (int64, error)
|
||||||
Distinct(columns ...string) *Session
|
Distinct(columns ...string) *Session
|
||||||
DropIndexes(bean interface{}) error
|
DropIndexes(bean interface{}) error
|
||||||
Exec(sqlOrArgs ...interface{}) (sql.Result, error)
|
Exec(sqlOrArgs ...interface{}) (sql.Result, error)
|
||||||
@ -52,7 +53,7 @@ type Interface interface {
|
|||||||
NoAutoCondition(...bool) *Session
|
NoAutoCondition(...bool) *Session
|
||||||
NotIn(string, ...interface{}) *Session
|
NotIn(string, ...interface{}) *Session
|
||||||
Nullable(...string) *Session
|
Nullable(...string) *Session
|
||||||
Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session
|
Join(joinOperator string, tablename interface{}, condition interface{}, args ...interface{}) *Session
|
||||||
Omit(columns ...string) *Session
|
Omit(columns ...string) *Session
|
||||||
OrderBy(order interface{}, args ...interface{}) *Session
|
OrderBy(order interface{}, args ...interface{}) *Session
|
||||||
Ping() error
|
Ping() error
|
||||||
@ -120,6 +121,7 @@ type EngineInterface interface {
|
|||||||
ShowSQL(show ...bool)
|
ShowSQL(show ...bool)
|
||||||
Sync(...interface{}) error
|
Sync(...interface{}) error
|
||||||
Sync2(...interface{}) error
|
Sync2(...interface{}) error
|
||||||
|
SyncWithOptions(SyncOptions, ...interface{}) (*SyncResult, error)
|
||||||
StoreEngine(storeEngine string) *Session
|
StoreEngine(storeEngine string) *Session
|
||||||
TableInfo(bean interface{}) (*schemas.Table, error)
|
TableInfo(bean interface{}) (*schemas.Table, error)
|
||||||
TableName(interface{}, ...bool) string
|
TableName(interface{}, ...bool) string
|
||||||
|
1
vendor/xorm.io/xorm/internal/json/gojson.go
generated
vendored
1
vendor/xorm.io/xorm/internal/json/gojson.go
generated
vendored
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build gojson
|
||||||
// +build gojson
|
// +build gojson
|
||||||
|
|
||||||
package json
|
package json
|
||||||
|
1
vendor/xorm.io/xorm/internal/json/jsoniter.go
generated
vendored
1
vendor/xorm.io/xorm/internal/json/jsoniter.go
generated
vendored
@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build jsoniter
|
||||||
// +build jsoniter
|
// +build jsoniter
|
||||||
|
|
||||||
package json
|
package json
|
||||||
|
16
vendor/xorm.io/xorm/internal/statements/cache.go
generated
vendored
16
vendor/xorm.io/xorm/internal/statements/cache.go
generated
vendored
@ -6,6 +6,7 @@ package statements
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/internal/utils"
|
||||||
@ -26,14 +27,19 @@ func (statement *Statement) ConvertIDSQL(sqlStr string) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var top string
|
var b strings.Builder
|
||||||
|
b.WriteString("SELECT ")
|
||||||
pLimitN := statement.LimitN
|
pLimitN := statement.LimitN
|
||||||
if pLimitN != nil && statement.dialect.URI().DBType == schemas.MSSQL {
|
if pLimitN != nil && statement.dialect.URI().DBType == schemas.MSSQL {
|
||||||
top = fmt.Sprintf("TOP %d ", *pLimitN)
|
b.WriteString("TOP ")
|
||||||
|
b.WriteString(strconv.Itoa(*pLimitN))
|
||||||
|
b.WriteString(" ")
|
||||||
}
|
}
|
||||||
|
b.WriteString(colstrs)
|
||||||
|
b.WriteString(" FROM ")
|
||||||
|
b.WriteString(sqls[1])
|
||||||
|
|
||||||
newsql := fmt.Sprintf("SELECT %s%s FROM %v", top, colstrs, sqls[1])
|
return b.String()
|
||||||
return newsql
|
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -54,7 +60,7 @@ func (statement *Statement) ConvertUpdateSQL(sqlStr string) (string, string) {
|
|||||||
return "", ""
|
return "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var whereStr = sqls[1]
|
whereStr := sqls[1]
|
||||||
|
|
||||||
// TODO: for postgres only, if any other database?
|
// TODO: for postgres only, if any other database?
|
||||||
var paraStr string
|
var paraStr string
|
||||||
|
125
vendor/xorm.io/xorm/internal/statements/delete.go
generated
vendored
Normal file
125
vendor/xorm.io/xorm/internal/statements/delete.go
generated
vendored
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
// Copyright 2023 The Xorm Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package statements
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"xorm.io/builder"
|
||||||
|
"xorm.io/xorm/internal/utils"
|
||||||
|
"xorm.io/xorm/schemas"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (statement *Statement) writeDeleteOrder(w *builder.BytesWriter) error {
|
||||||
|
if err := statement.writeOrderBys(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if statement.LimitN != nil && *statement.LimitN > 0 {
|
||||||
|
if statement.Start > 0 {
|
||||||
|
return fmt.Errorf("Delete with Limit start is unsupported")
|
||||||
|
}
|
||||||
|
limitNValue := *statement.LimitN
|
||||||
|
if _, err := fmt.Fprintf(w, " LIMIT %d", limitNValue); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrNotImplemented not implemented
|
||||||
|
var ErrNotImplemented = errors.New("Not implemented")
|
||||||
|
|
||||||
|
func (statement *Statement) writeOrderCond(orderCondWriter *builder.BytesWriter, tableName string) error {
|
||||||
|
orderSQLWriter := builder.NewWriter()
|
||||||
|
if err := statement.writeDeleteOrder(orderSQLWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if orderSQLWriter.Len() == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
switch statement.dialect.URI().DBType {
|
||||||
|
case schemas.POSTGRES:
|
||||||
|
if statement.cond.IsValid() {
|
||||||
|
if _, err := fmt.Fprint(orderCondWriter, " AND "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := fmt.Fprint(orderCondWriter, " WHERE "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprintf(orderCondWriter, "ctid IN (SELECT ctid FROM %s%s)", tableName, orderSQLWriter.String()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
orderCondWriter.Append(orderSQLWriter.Args()...)
|
||||||
|
return nil
|
||||||
|
case schemas.SQLITE:
|
||||||
|
if statement.cond.IsValid() {
|
||||||
|
if _, err := fmt.Fprint(orderCondWriter, " AND "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := fmt.Fprint(orderCondWriter, " WHERE "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprintf(orderCondWriter, "rowid IN (SELECT rowid FROM %s%s)", tableName, orderSQLWriter.String()); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
orderCondWriter.Append(orderSQLWriter.Args()...)
|
||||||
|
return nil
|
||||||
|
// TODO: how to handle delete limit on mssql?
|
||||||
|
case schemas.MSSQL:
|
||||||
|
return ErrNotImplemented
|
||||||
|
default:
|
||||||
|
return utils.WriteBuilder(orderCondWriter, orderSQLWriter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) WriteDelete(realSQLWriter, deleteSQLWriter *builder.BytesWriter, nowTime func(*schemas.Column) (interface{}, time.Time, error)) error {
|
||||||
|
tableNameNoQuote := statement.TableName()
|
||||||
|
tableName := statement.dialect.Quoter().Quote(tableNameNoQuote)
|
||||||
|
table := statement.RefTable
|
||||||
|
if _, err := fmt.Fprint(deleteSQLWriter, "DELETE FROM ", tableName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeWhere(deleteSQLWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
orderCondWriter := builder.NewWriter()
|
||||||
|
if err := statement.writeOrderCond(orderCondWriter, tableName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if statement.GetUnscoped() || table == nil || table.DeletedColumn() == nil { // tag "deleted" is disabled
|
||||||
|
return utils.WriteBuilder(realSQLWriter, deleteSQLWriter, orderCondWriter)
|
||||||
|
}
|
||||||
|
|
||||||
|
deletedColumn := table.DeletedColumn()
|
||||||
|
if _, err := fmt.Fprintf(realSQLWriter, "UPDATE %v SET %v = ?",
|
||||||
|
statement.dialect.Quoter().Quote(statement.TableName()),
|
||||||
|
statement.dialect.Quoter().Quote(deletedColumn.Name)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
val, _, err := nowTime(deletedColumn)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
realSQLWriter.Append(val)
|
||||||
|
|
||||||
|
if err := statement.writeWhere(realSQLWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.WriteBuilder(realSQLWriter, orderCondWriter)
|
||||||
|
}
|
106
vendor/xorm.io/xorm/internal/statements/insert.go
generated
vendored
106
vendor/xorm.io/xorm/internal/statements/insert.go
generated
vendored
@ -43,8 +43,8 @@ func (statement *Statement) GenInsertSQL(colNames []string, args []interface{})
|
|||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasInsertColumns = len(colNames) > 0
|
hasInsertColumns := len(colNames) > 0
|
||||||
var needSeq = len(table.AutoIncrement) > 0 && (statement.dialect.URI().DBType == schemas.ORACLE || statement.dialect.URI().DBType == schemas.DAMENG)
|
needSeq := len(table.AutoIncrement) > 0 && (statement.dialect.URI().DBType == schemas.ORACLE || statement.dialect.URI().DBType == schemas.DAMENG)
|
||||||
if needSeq {
|
if needSeq {
|
||||||
for _, col := range colNames {
|
for _, col := range colNames {
|
||||||
if strings.EqualFold(col, table.AutoIncrement) {
|
if strings.EqualFold(col, table.AutoIncrement) {
|
||||||
@ -124,11 +124,7 @@ func (statement *Statement) GenInsertSQL(colNames []string, args []interface{})
|
|||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := buf.WriteString(" WHERE "); err != nil {
|
if err := statement.writeWhere(buf); err != nil {
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := statement.Conds().WriteTo(buf); err != nil {
|
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -297,3 +293,99 @@ func (statement *Statement) GenInsertMultipleMapSQL(columns []string, argss [][]
|
|||||||
|
|
||||||
return buf.String(), buf.Args(), nil
|
return buf.String(), buf.Args(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeColumns(w *builder.BytesWriter, slice []string) error {
|
||||||
|
for i, s := range slice {
|
||||||
|
if i > 0 {
|
||||||
|
if _, err := fmt.Fprint(w, ","); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := statement.dialect.Quoter().QuoteTo(w.Builder, s); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeQuestions(w *builder.BytesWriter, length int) error {
|
||||||
|
for i := 0; i < length; i++ {
|
||||||
|
if i > 0 {
|
||||||
|
if _, err := fmt.Fprint(w, ","); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, "?"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) oracleWriteInsertMultiple(w *builder.BytesWriter, tableName string, colNames []string, colMultiPlaces []string) error {
|
||||||
|
if _, err := fmt.Fprint(w, "INSERT ALL"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, cols := range colMultiPlaces {
|
||||||
|
if _, err := fmt.Fprint(w, " INTO "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.dialect.Quoter().QuoteTo(w.Builder, tableName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, " ("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeColumns(w, colNames); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, ") VALUES ("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprintf(w, cols, ")"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := fmt.Fprint(w, " SELECT 1 FROM DUAL"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) WriteInsertMultiple(w *builder.BytesWriter, tableName string, colNames []string, colMultiPlaces []string) error {
|
||||||
|
if statement.dialect.URI().DBType == schemas.ORACLE {
|
||||||
|
return statement.oracleWriteInsertMultiple(w, tableName, colNames, colMultiPlaces)
|
||||||
|
}
|
||||||
|
return statement.plainWriteInsertMultiple(w, tableName, colNames, colMultiPlaces)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) plainWriteInsertMultiple(w *builder.BytesWriter, tableName string, colNames []string, colMultiPlaces []string) error {
|
||||||
|
if _, err := fmt.Fprint(w, "INSERT INTO "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.dialect.Quoter().QuoteTo(w.Builder, tableName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, " ("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeColumns(w, colNames); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, ") VALUES ("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for i, cols := range colMultiPlaces {
|
||||||
|
if _, err := fmt.Fprint(w, cols, ")"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if i < len(colMultiPlaces)-1 {
|
||||||
|
if _, err := fmt.Fprint(w, ",("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
139
vendor/xorm.io/xorm/internal/statements/join.go
generated
vendored
139
vendor/xorm.io/xorm/internal/statements/join.go
generated
vendored
@ -15,64 +15,97 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
// Join The joinOP should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
||||||
func (statement *Statement) Join(joinOP string, tablename interface{}, condition string, args ...interface{}) *Statement {
|
func (statement *Statement) Join(joinOP string, joinTable interface{}, condition interface{}, args ...interface{}) *Statement {
|
||||||
var buf strings.Builder
|
statement.joins = append(statement.joins, join{
|
||||||
if len(statement.JoinStr) > 0 {
|
op: joinOP,
|
||||||
fmt.Fprintf(&buf, "%v %v JOIN ", statement.JoinStr, joinOP)
|
table: joinTable,
|
||||||
} else {
|
condition: condition,
|
||||||
fmt.Fprintf(&buf, "%v JOIN ", joinOP)
|
args: args,
|
||||||
}
|
})
|
||||||
|
|
||||||
switch tp := tablename.(type) {
|
|
||||||
case builder.Builder:
|
|
||||||
subSQL, subQueryArgs, err := tp.ToSQL()
|
|
||||||
if err != nil {
|
|
||||||
statement.LastError = err
|
|
||||||
return statement
|
|
||||||
}
|
|
||||||
|
|
||||||
fields := strings.Split(tp.TableName(), ".")
|
|
||||||
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
|
|
||||||
aliasName = schemas.CommonQuoter.Trim(aliasName)
|
|
||||||
|
|
||||||
fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), statement.quote(aliasName), statement.ReplaceQuote(condition))
|
|
||||||
statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
|
|
||||||
case *builder.Builder:
|
|
||||||
subSQL, subQueryArgs, err := tp.ToSQL()
|
|
||||||
if err != nil {
|
|
||||||
statement.LastError = err
|
|
||||||
return statement
|
|
||||||
}
|
|
||||||
|
|
||||||
fields := strings.Split(tp.TableName(), ".")
|
|
||||||
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
|
|
||||||
aliasName = schemas.CommonQuoter.Trim(aliasName)
|
|
||||||
|
|
||||||
fmt.Fprintf(&buf, "(%s) %s ON %v", statement.ReplaceQuote(subSQL), statement.quote(aliasName), statement.ReplaceQuote(condition))
|
|
||||||
statement.joinArgs = append(statement.joinArgs, subQueryArgs...)
|
|
||||||
default:
|
|
||||||
tbName := dialects.FullTableName(statement.dialect, statement.tagParser.GetTableMapper(), tablename, true)
|
|
||||||
if !utils.IsSubQuery(tbName) {
|
|
||||||
var buf strings.Builder
|
|
||||||
_ = statement.dialect.Quoter().QuoteTo(&buf, tbName)
|
|
||||||
tbName = buf.String()
|
|
||||||
} else {
|
|
||||||
tbName = statement.ReplaceQuote(tbName)
|
|
||||||
}
|
|
||||||
fmt.Fprintf(&buf, "%s ON %v", tbName, statement.ReplaceQuote(condition))
|
|
||||||
}
|
|
||||||
|
|
||||||
statement.JoinStr = buf.String()
|
|
||||||
statement.joinArgs = append(statement.joinArgs, args...)
|
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) writeJoin(w builder.Writer) error {
|
func (statement *Statement) writeJoins(w *builder.BytesWriter) error {
|
||||||
if statement.JoinStr != "" {
|
for _, join := range statement.joins {
|
||||||
if _, err := fmt.Fprint(w, " ", statement.JoinStr); err != nil {
|
if err := statement.writeJoin(w, join); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w.Append(statement.joinArgs...)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeJoin(buf *builder.BytesWriter, join join) error {
|
||||||
|
// write join operator
|
||||||
|
if _, err := fmt.Fprint(buf, " ", join.op, " JOIN"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// write join table or subquery
|
||||||
|
switch tp := join.table.(type) {
|
||||||
|
case builder.Builder:
|
||||||
|
if _, err := fmt.Fprintf(buf, " ("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := tp.WriteTo(statement.QuoteReplacer(buf)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fields := strings.Split(tp.TableName(), ".")
|
||||||
|
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
|
||||||
|
aliasName = schemas.CommonQuoter.Trim(aliasName)
|
||||||
|
|
||||||
|
if _, err := fmt.Fprintf(buf, ") %s", statement.quote(aliasName)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case *builder.Builder:
|
||||||
|
if _, err := fmt.Fprintf(buf, " ("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := tp.WriteTo(statement.QuoteReplacer(buf)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fields := strings.Split(tp.TableName(), ".")
|
||||||
|
aliasName := statement.dialect.Quoter().Trim(fields[len(fields)-1])
|
||||||
|
aliasName = schemas.CommonQuoter.Trim(aliasName)
|
||||||
|
|
||||||
|
if _, err := fmt.Fprintf(buf, ") %s", statement.quote(aliasName)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
tbName := dialects.FullTableName(statement.dialect, statement.tagParser.GetTableMapper(), join.table, true)
|
||||||
|
if !utils.IsSubQuery(tbName) {
|
||||||
|
var sb strings.Builder
|
||||||
|
if err := statement.dialect.Quoter().QuoteTo(&sb, tbName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tbName = sb.String()
|
||||||
|
} else {
|
||||||
|
tbName = statement.ReplaceQuote(tbName)
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(buf, " ", tbName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// write on condition
|
||||||
|
if _, err := fmt.Fprint(buf, " ON "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch condTp := join.condition.(type) {
|
||||||
|
case string:
|
||||||
|
if _, err := fmt.Fprint(buf, statement.ReplaceQuote(condTp)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case builder.Cond:
|
||||||
|
if err := condTp.WriteTo(statement.QuoteReplacer(buf)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported join condition type: %v", condTp)
|
||||||
|
}
|
||||||
|
buf.Append(join.args...)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
136
vendor/xorm.io/xorm/internal/statements/order_by.go
generated
vendored
136
vendor/xorm.io/xorm/internal/statements/order_by.go
generated
vendored
@ -5,86 +5,138 @@
|
|||||||
package statements
|
package statements
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type orderBy struct {
|
||||||
|
orderStr interface{}
|
||||||
|
orderArgs []interface{}
|
||||||
|
direction string // ASC, DESC or "", "" means raw orderStr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ob orderBy) CheckValid() error {
|
||||||
|
if ob.orderStr == nil {
|
||||||
|
return fmt.Errorf("order by string is nil")
|
||||||
|
}
|
||||||
|
switch t := ob.orderStr.(type) {
|
||||||
|
case string:
|
||||||
|
if t == "" {
|
||||||
|
return fmt.Errorf("order by string is empty")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
case *builder.Expression:
|
||||||
|
if t.Content() == "" {
|
||||||
|
return fmt.Errorf("order by string is empty")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("order by string is not string or builder.Expression")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (statement *Statement) HasOrderBy() bool {
|
func (statement *Statement) HasOrderBy() bool {
|
||||||
return statement.orderStr != ""
|
return len(statement.orderBy) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetOrderBy reset ordery conditions
|
// ResetOrderBy reset ordery conditions
|
||||||
func (statement *Statement) ResetOrderBy() {
|
func (statement *Statement) ResetOrderBy() {
|
||||||
statement.orderStr = ""
|
statement.orderBy = []orderBy{}
|
||||||
statement.orderArgs = nil
|
}
|
||||||
|
|
||||||
|
var ErrNoColumnName = errors.New("no column name")
|
||||||
|
|
||||||
|
func (statement *Statement) writeOrderBy(w *builder.BytesWriter, orderBy orderBy) error {
|
||||||
|
switch t := orderBy.orderStr.(type) {
|
||||||
|
case (*builder.Expression):
|
||||||
|
if _, err := fmt.Fprint(w.Builder, statement.dialect.Quoter().Replace(t.Content())); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.Append(t.Args()...)
|
||||||
|
return nil
|
||||||
|
case string:
|
||||||
|
if orderBy.direction == "" {
|
||||||
|
if _, err := fmt.Fprint(w.Builder, statement.dialect.Quoter().Replace(t)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.Append(orderBy.orderArgs...)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err := statement.dialect.Quoter().QuoteTo(w.Builder, t); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err := fmt.Fprint(w, " ", orderBy.direction)
|
||||||
|
return err
|
||||||
|
default:
|
||||||
|
return ErrUnSupportedSQLType
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteOrderBy write order by to writer
|
// WriteOrderBy write order by to writer
|
||||||
func (statement *Statement) WriteOrderBy(w builder.Writer) error {
|
func (statement *Statement) writeOrderBys(w *builder.BytesWriter) error {
|
||||||
if len(statement.orderStr) > 0 {
|
if len(statement.orderBy) == 0 {
|
||||||
if _, err := fmt.Fprintf(w, " ORDER BY %s", statement.orderStr); err != nil {
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := fmt.Fprint(w, " ORDER BY "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for i, ob := range statement.orderBy {
|
||||||
|
if err := statement.writeOrderBy(w, ob); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w.Append(statement.orderArgs...)
|
if i < len(statement.orderBy)-1 {
|
||||||
|
if _, err := fmt.Fprint(w, ", "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderBy generate "Order By order" statement
|
// OrderBy generate "Order By order" statement
|
||||||
func (statement *Statement) OrderBy(order interface{}, args ...interface{}) *Statement {
|
func (statement *Statement) OrderBy(order interface{}, args ...interface{}) *Statement {
|
||||||
if len(statement.orderStr) > 0 {
|
ob := orderBy{order, args, ""}
|
||||||
statement.orderStr += ", "
|
if err := ob.CheckValid(); err != nil {
|
||||||
}
|
statement.LastError = err
|
||||||
var rawOrder string
|
|
||||||
switch t := order.(type) {
|
|
||||||
case (*builder.Expression):
|
|
||||||
rawOrder = t.Content()
|
|
||||||
args = t.Args()
|
|
||||||
case string:
|
|
||||||
rawOrder = t
|
|
||||||
default:
|
|
||||||
statement.LastError = ErrUnSupportedSQLType
|
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
statement.orderStr += statement.ReplaceQuote(rawOrder)
|
statement.orderBy = append(statement.orderBy, ob)
|
||||||
if len(args) > 0 {
|
|
||||||
statement.orderArgs = append(statement.orderArgs, args...)
|
|
||||||
}
|
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Desc generate `ORDER BY xx DESC`
|
// Desc generate `ORDER BY xx DESC`
|
||||||
func (statement *Statement) Desc(colNames ...string) *Statement {
|
func (statement *Statement) Desc(colNames ...string) *Statement {
|
||||||
var buf strings.Builder
|
if len(colNames) == 0 {
|
||||||
if len(statement.orderStr) > 0 {
|
statement.LastError = ErrNoColumnName
|
||||||
fmt.Fprint(&buf, statement.orderStr, ", ")
|
return statement
|
||||||
}
|
}
|
||||||
for i, col := range colNames {
|
for _, colName := range colNames {
|
||||||
if i > 0 {
|
ob := orderBy{colName, nil, "DESC"}
|
||||||
fmt.Fprint(&buf, ", ")
|
statement.orderBy = append(statement.orderBy, ob)
|
||||||
|
if err := ob.CheckValid(); err != nil {
|
||||||
|
statement.LastError = err
|
||||||
|
return statement
|
||||||
}
|
}
|
||||||
_ = statement.dialect.Quoter().QuoteTo(&buf, col)
|
|
||||||
fmt.Fprint(&buf, " DESC")
|
|
||||||
}
|
}
|
||||||
statement.orderStr = buf.String()
|
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asc provide asc order by query condition, the input parameters are columns.
|
// Asc provide asc order by query condition, the input parameters are columns.
|
||||||
func (statement *Statement) Asc(colNames ...string) *Statement {
|
func (statement *Statement) Asc(colNames ...string) *Statement {
|
||||||
var buf strings.Builder
|
if len(colNames) == 0 {
|
||||||
if len(statement.orderStr) > 0 {
|
statement.LastError = ErrNoColumnName
|
||||||
fmt.Fprint(&buf, statement.orderStr, ", ")
|
return statement
|
||||||
}
|
}
|
||||||
for i, col := range colNames {
|
for _, colName := range colNames {
|
||||||
if i > 0 {
|
ob := orderBy{colName, nil, "ASC"}
|
||||||
fmt.Fprint(&buf, ", ")
|
statement.orderBy = append(statement.orderBy, ob)
|
||||||
|
if err := ob.CheckValid(); err != nil {
|
||||||
|
statement.LastError = err
|
||||||
|
return statement
|
||||||
}
|
}
|
||||||
_ = statement.dialect.Quoter().QuoteTo(&buf, col)
|
|
||||||
fmt.Fprint(&buf, " ASC")
|
|
||||||
}
|
}
|
||||||
statement.orderStr = buf.String()
|
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
446
vendor/xorm.io/xorm/internal/statements/query.go
generated
vendored
446
vendor/xorm.io/xorm/internal/statements/query.go
generated
vendored
@ -7,6 +7,7 @@ package statements
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -29,37 +30,15 @@ func (statement *Statement) GenQuerySQL(sqlOrArgs ...interface{}) (string, []int
|
|||||||
return "", nil, ErrTableNotFound
|
return "", nil, ErrTableNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
columnStr := statement.ColumnStr()
|
|
||||||
if len(statement.SelectStr) > 0 {
|
|
||||||
columnStr = statement.SelectStr
|
|
||||||
} else {
|
|
||||||
if statement.JoinStr == "" {
|
|
||||||
if columnStr == "" {
|
|
||||||
if statement.GroupByStr != "" {
|
|
||||||
columnStr = statement.quoteColumnStr(statement.GroupByStr)
|
|
||||||
} else {
|
|
||||||
columnStr = statement.genColumnStr()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if columnStr == "" {
|
|
||||||
if statement.GroupByStr != "" {
|
|
||||||
columnStr = statement.quoteColumnStr(statement.GroupByStr)
|
|
||||||
} else {
|
|
||||||
columnStr = "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if columnStr == "" {
|
|
||||||
columnStr = "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := statement.ProcessIDParam(); err != nil {
|
if err := statement.ProcessIDParam(); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return statement.genSelectSQL(columnStr, true, true)
|
buf := builder.NewWriter()
|
||||||
|
if err := statement.writeSelect(buf, statement.genSelectColumnStr(), true, true); err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
return buf.String(), buf.Args(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenSumSQL generates sum SQL
|
// GenSumSQL generates sum SQL
|
||||||
@ -81,13 +60,16 @@ func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (stri
|
|||||||
}
|
}
|
||||||
sumStrs = append(sumStrs, fmt.Sprintf("COALESCE(sum(%s),0)", colName))
|
sumStrs = append(sumStrs, fmt.Sprintf("COALESCE(sum(%s),0)", colName))
|
||||||
}
|
}
|
||||||
sumSelect := strings.Join(sumStrs, ", ")
|
|
||||||
|
|
||||||
if err := statement.MergeConds(bean); err != nil {
|
if err := statement.MergeConds(bean); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return statement.genSelectSQL(sumSelect, true, true)
|
buf := builder.NewWriter()
|
||||||
|
if err := statement.writeSelect(buf, strings.Join(sumStrs, ", "), true, true); err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
return buf.String(), buf.Args(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenGetSQL generates Get SQL
|
// GenGetSQL generates Get SQL
|
||||||
@ -108,7 +90,7 @@ func (statement *Statement) GenGetSQL(bean interface{}) (string, []interface{},
|
|||||||
columnStr = statement.SelectStr
|
columnStr = statement.SelectStr
|
||||||
} else {
|
} else {
|
||||||
// TODO: always generate column names, not use * even if join
|
// TODO: always generate column names, not use * even if join
|
||||||
if len(statement.JoinStr) == 0 {
|
if len(statement.joins) == 0 {
|
||||||
if len(columnStr) == 0 {
|
if len(columnStr) == 0 {
|
||||||
if len(statement.GroupByStr) > 0 {
|
if len(statement.GroupByStr) > 0 {
|
||||||
columnStr = statement.quoteColumnStr(statement.GroupByStr)
|
columnStr = statement.quoteColumnStr(statement.GroupByStr)
|
||||||
@ -139,7 +121,11 @@ func (statement *Statement) GenGetSQL(bean interface{}) (string, []interface{},
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return statement.genSelectSQL(columnStr, true, true)
|
buf := builder.NewWriter()
|
||||||
|
if err := statement.writeSelect(buf, columnStr, true, true); err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
return buf.String(), buf.Args(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenCountSQL generates the SQL for counting
|
// GenCountSQL generates the SQL for counting
|
||||||
@ -148,8 +134,6 @@ func (statement *Statement) GenCountSQL(beans ...interface{}) (string, []interfa
|
|||||||
return statement.GenRawSQL(), statement.RawParams, nil
|
return statement.GenRawSQL(), statement.RawParams, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var condArgs []interface{}
|
|
||||||
var err error
|
|
||||||
if len(beans) > 0 {
|
if len(beans) > 0 {
|
||||||
if err := statement.SetRefBean(beans[0]); err != nil {
|
if err := statement.SetRefBean(beans[0]); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
@ -169,6 +153,14 @@ func (statement *Statement) GenCountSQL(beans ...interface{}) (string, []interfa
|
|||||||
selectSQL = "count(*)"
|
selectSQL = "count(*)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf := builder.NewWriter()
|
||||||
|
if statement.GroupByStr != "" {
|
||||||
|
if _, err := fmt.Fprintf(buf, "SELECT %s FROM (", selectSQL); err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var subQuerySelect string
|
var subQuerySelect string
|
||||||
if statement.GroupByStr != "" {
|
if statement.GroupByStr != "" {
|
||||||
subQuerySelect = statement.GroupByStr
|
subQuerySelect = statement.GroupByStr
|
||||||
@ -176,19 +168,20 @@ func (statement *Statement) GenCountSQL(beans ...interface{}) (string, []interfa
|
|||||||
subQuerySelect = selectSQL
|
subQuerySelect = selectSQL
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlStr, condArgs, err := statement.genSelectSQL(subQuerySelect, false, false)
|
if err := statement.writeSelect(buf, subQuerySelect, false, false); err != nil {
|
||||||
if err != nil {
|
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if statement.GroupByStr != "" {
|
if statement.GroupByStr != "" {
|
||||||
sqlStr = fmt.Sprintf("SELECT %s FROM (%s) sub", selectSQL, sqlStr)
|
if _, err := fmt.Fprintf(buf, ") sub"); err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sqlStr, condArgs, nil
|
return buf.String(), buf.Args(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) writeFrom(w builder.Writer) error {
|
func (statement *Statement) writeFrom(w *builder.BytesWriter) error {
|
||||||
if _, err := fmt.Fprint(w, " FROM "); err != nil {
|
if _, err := fmt.Fprint(w, " FROM "); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -198,7 +191,7 @@ func (statement *Statement) writeFrom(w builder.Writer) error {
|
|||||||
if err := statement.writeAlias(w); err != nil {
|
if err := statement.writeAlias(w); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return statement.writeJoin(w)
|
return statement.writeJoins(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) writeLimitOffset(w builder.Writer) error {
|
func (statement *Statement) writeLimitOffset(w builder.Writer) error {
|
||||||
@ -218,153 +211,195 @@ func (statement *Statement) writeLimitOffset(w builder.Writer) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) genSelectSQL(columnStr string, needLimit, needOrderBy bool) (string, []interface{}, error) {
|
func (statement *Statement) writeTop(w builder.Writer) error {
|
||||||
var (
|
if statement.dialect.URI().DBType != schemas.MSSQL {
|
||||||
distinct string
|
return nil
|
||||||
dialect = statement.dialect
|
}
|
||||||
top, whereStr string
|
if statement.LimitN == nil {
|
||||||
mssqlCondi = builder.NewWriter()
|
return nil
|
||||||
)
|
}
|
||||||
|
_, err := fmt.Fprintf(w, " TOP %d", *statement.LimitN)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if statement.IsDistinct && !strings.HasPrefix(columnStr, "count") {
|
func (statement *Statement) writeDistinct(w builder.Writer) error {
|
||||||
distinct = "DISTINCT "
|
if statement.IsDistinct && !strings.HasPrefix(statement.SelectStr, "count(") {
|
||||||
|
_, err := fmt.Fprint(w, " DISTINCT")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeSelectColumns(w *builder.BytesWriter, columnStr string) error {
|
||||||
|
if _, err := fmt.Fprintf(w, "SELECT"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeDistinct(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeTop(w); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err := fmt.Fprint(w, " ", columnStr)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeWhereCond(w *builder.BytesWriter, cond builder.Cond) error {
|
||||||
|
if !cond.IsValid() {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
condWriter := builder.NewWriter()
|
if _, err := fmt.Fprint(w, " WHERE "); err != nil {
|
||||||
if err := statement.cond.WriteTo(statement.QuoteReplacer(condWriter)); err != nil {
|
return err
|
||||||
return "", nil, err
|
}
|
||||||
|
return cond.WriteTo(statement.QuoteReplacer(w))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeWhere(w *builder.BytesWriter) error {
|
||||||
|
return statement.writeWhereCond(w, statement.cond)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeWhereWithMssqlPagination(w *builder.BytesWriter) error {
|
||||||
|
if !statement.cond.IsValid() {
|
||||||
|
return statement.writeMssqlPaginationCond(w)
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, " WHERE "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.cond.WriteTo(statement.QuoteReplacer(w)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return statement.writeMssqlPaginationCond(w)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeForUpdate(w io.Writer) error {
|
||||||
|
if !statement.IsForUpdate {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if condWriter.Len() > 0 {
|
if statement.dialect.URI().DBType != schemas.MYSQL {
|
||||||
whereStr = " WHERE "
|
return errors.New("only support mysql for update")
|
||||||
|
}
|
||||||
|
_, err := fmt.Fprint(w, " FOR UPDATE")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeMssqlPaginationCond(w *builder.BytesWriter) error {
|
||||||
|
if statement.dialect.URI().DBType != schemas.MSSQL || statement.Start <= 0 {
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pLimitN := statement.LimitN
|
if statement.RefTable == nil {
|
||||||
if dialect.URI().DBType == schemas.MSSQL {
|
return errors.New("unsupported query limit without reference table")
|
||||||
if pLimitN != nil {
|
}
|
||||||
LimitNValue := *pLimitN
|
|
||||||
top = fmt.Sprintf("TOP %d ", LimitNValue)
|
var column string
|
||||||
|
if len(statement.RefTable.PKColumns()) == 0 {
|
||||||
|
for _, index := range statement.RefTable.Indexes {
|
||||||
|
if len(index.Cols) == 1 {
|
||||||
|
column = index.Cols[0]
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if statement.Start > 0 {
|
if len(column) == 0 {
|
||||||
if statement.RefTable == nil {
|
column = statement.RefTable.ColumnsSeq()[0]
|
||||||
return "", nil, errors.New("Unsupported query limit without reference table")
|
}
|
||||||
}
|
} else {
|
||||||
var column string
|
column = statement.RefTable.PKColumns()[0].Name
|
||||||
if len(statement.RefTable.PKColumns()) == 0 {
|
}
|
||||||
for _, index := range statement.RefTable.Indexes {
|
if statement.NeedTableName() {
|
||||||
if len(index.Cols) == 1 {
|
if len(statement.TableAlias) > 0 {
|
||||||
column = index.Cols[0]
|
column = fmt.Sprintf("%s.%s", statement.TableAlias, column)
|
||||||
break
|
} else {
|
||||||
}
|
column = fmt.Sprintf("%s.%s", statement.TableName(), column)
|
||||||
}
|
|
||||||
if len(column) == 0 {
|
|
||||||
column = statement.RefTable.ColumnsSeq()[0]
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
column = statement.RefTable.PKColumns()[0].Name
|
|
||||||
}
|
|
||||||
if statement.needTableName() {
|
|
||||||
if len(statement.TableAlias) > 0 {
|
|
||||||
column = fmt.Sprintf("%s.%s", statement.TableAlias, column)
|
|
||||||
} else {
|
|
||||||
column = fmt.Sprintf("%s.%s", statement.TableName(), column)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := fmt.Fprintf(mssqlCondi, "(%s NOT IN (SELECT TOP %d %s",
|
|
||||||
column, statement.Start, column); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
if err := statement.writeFrom(mssqlCondi); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
if whereStr != "" {
|
|
||||||
if _, err := fmt.Fprint(mssqlCondi, whereStr); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
if err := utils.WriteBuilder(mssqlCondi, statement.QuoteReplacer(condWriter)); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if needOrderBy {
|
|
||||||
if err := statement.WriteOrderBy(mssqlCondi); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if err := statement.WriteGroupBy(mssqlCondi); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
if _, err := fmt.Fprint(mssqlCondi, "))"); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := builder.NewWriter()
|
subWriter := builder.NewWriter()
|
||||||
if _, err := fmt.Fprintf(buf, "SELECT %v%v%v", distinct, top, columnStr); err != nil {
|
if _, err := fmt.Fprintf(subWriter, "(%s NOT IN (SELECT TOP %d %s",
|
||||||
return "", nil, err
|
column, statement.Start, column); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeFrom(subWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeWhere(subWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeOrderBys(subWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeGroupBy(subWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(subWriter, "))"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if statement.cond.IsValid() {
|
||||||
|
if _, err := fmt.Fprint(w, " AND "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := fmt.Fprint(w, " WHERE "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.WriteBuilder(w, subWriter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeOracleLimit(w *builder.BytesWriter, columnStr string) error {
|
||||||
|
if statement.LimitN == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
oldString := w.String()
|
||||||
|
w.Reset()
|
||||||
|
rawColStr := columnStr
|
||||||
|
if rawColStr == "*" {
|
||||||
|
rawColStr = "at.*"
|
||||||
|
}
|
||||||
|
_, err := fmt.Fprintf(w, "SELECT %v FROM (SELECT %v,ROWNUM RN FROM (%v) at WHERE ROWNUM <= %d) aat WHERE RN > %d",
|
||||||
|
columnStr, rawColStr, oldString, statement.Start+*statement.LimitN, statement.Start)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeSelect(buf *builder.BytesWriter, columnStr string, needLimit, needOrderBy bool) error {
|
||||||
|
if err := statement.writeSelectColumns(buf, columnStr); err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
if err := statement.writeFrom(buf); err != nil {
|
if err := statement.writeFrom(buf); err != nil {
|
||||||
return "", nil, err
|
return err
|
||||||
}
|
}
|
||||||
if whereStr != "" {
|
if err := statement.writeWhereWithMssqlPagination(buf); err != nil {
|
||||||
if _, err := fmt.Fprint(buf, whereStr); err != nil {
|
return err
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
if err := utils.WriteBuilder(buf, statement.QuoteReplacer(condWriter)); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if mssqlCondi.Len() > 0 {
|
if err := statement.writeGroupBy(buf); err != nil {
|
||||||
if len(whereStr) > 0 {
|
return err
|
||||||
if _, err := fmt.Fprint(buf, " AND "); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if _, err := fmt.Fprint(buf, " WHERE "); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.WriteBuilder(buf, mssqlCondi); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := statement.WriteGroupBy(buf); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
}
|
||||||
if err := statement.writeHaving(buf); err != nil {
|
if err := statement.writeHaving(buf); err != nil {
|
||||||
return "", nil, err
|
return err
|
||||||
}
|
}
|
||||||
if needOrderBy {
|
if needOrderBy {
|
||||||
if err := statement.WriteOrderBy(buf); err != nil {
|
if err := statement.writeOrderBys(buf); err != nil {
|
||||||
return "", nil, err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if needLimit {
|
|
||||||
if dialect.URI().DBType != schemas.MSSQL && dialect.URI().DBType != schemas.ORACLE {
|
|
||||||
if err := statement.writeLimitOffset(buf); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
} else if dialect.URI().DBType == schemas.ORACLE {
|
|
||||||
if pLimitN != nil {
|
|
||||||
oldString := buf.String()
|
|
||||||
buf.Reset()
|
|
||||||
rawColStr := columnStr
|
|
||||||
if rawColStr == "*" {
|
|
||||||
rawColStr = "at.*"
|
|
||||||
}
|
|
||||||
fmt.Fprintf(buf, "SELECT %v FROM (SELECT %v,ROWNUM RN FROM (%v) at WHERE ROWNUM <= %d) aat WHERE RN > %d",
|
|
||||||
columnStr, rawColStr, oldString, statement.Start+*pLimitN, statement.Start)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if statement.IsForUpdate {
|
|
||||||
return dialect.ForUpdateSQL(buf.String()), buf.Args(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return buf.String(), buf.Args(), nil
|
dialect := statement.dialect
|
||||||
|
if needLimit {
|
||||||
|
if dialect.URI().DBType == schemas.ORACLE {
|
||||||
|
if err := statement.writeOracleLimit(buf, columnStr); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else if dialect.URI().DBType != schemas.MSSQL {
|
||||||
|
if err := statement.writeLimitOffset(buf); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return statement.writeForUpdate(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenExistSQL generates Exist SQL
|
// GenExistSQL generates Exist SQL
|
||||||
@ -402,22 +437,17 @@ func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interfac
|
|||||||
if _, err := fmt.Fprintf(buf, "SELECT TOP 1 * FROM %s", tableName); err != nil {
|
if _, err := fmt.Fprintf(buf, "SELECT TOP 1 * FROM %s", tableName); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
if err := statement.writeJoin(buf); err != nil {
|
if err := statement.writeJoins(buf); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
if statement.Conds().IsValid() {
|
if err := statement.writeWhere(buf); err != nil {
|
||||||
if _, err := fmt.Fprintf(buf, " WHERE "); err != nil {
|
return "", nil, err
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
if err := statement.Conds().WriteTo(statement.QuoteReplacer(buf)); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if statement.dialect.URI().DBType == schemas.ORACLE {
|
} else if statement.dialect.URI().DBType == schemas.ORACLE {
|
||||||
if _, err := fmt.Fprintf(buf, "SELECT * FROM %s", tableName); err != nil {
|
if _, err := fmt.Fprintf(buf, "SELECT * FROM %s", tableName); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
if err := statement.writeJoin(buf); err != nil {
|
if err := statement.writeJoins(buf); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
if _, err := fmt.Fprintf(buf, " WHERE "); err != nil {
|
if _, err := fmt.Fprintf(buf, " WHERE "); err != nil {
|
||||||
@ -438,16 +468,11 @@ func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interfac
|
|||||||
if _, err := fmt.Fprintf(buf, "SELECT 1 FROM %s", tableName); err != nil {
|
if _, err := fmt.Fprintf(buf, "SELECT 1 FROM %s", tableName); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
if err := statement.writeJoin(buf); err != nil {
|
if err := statement.writeJoins(buf); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
}
|
}
|
||||||
if statement.Conds().IsValid() {
|
if err := statement.writeWhere(buf); err != nil {
|
||||||
if _, err := fmt.Fprintf(buf, " WHERE "); err != nil {
|
return "", nil, err
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
if err := statement.Conds().WriteTo(statement.QuoteReplacer(buf)); err != nil {
|
|
||||||
return "", nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if _, err := fmt.Fprintf(buf, " LIMIT 1"); err != nil {
|
if _, err := fmt.Fprintf(buf, " LIMIT 1"); err != nil {
|
||||||
return "", nil, err
|
return "", nil, err
|
||||||
@ -457,6 +482,33 @@ func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interfac
|
|||||||
return buf.String(), buf.Args(), nil
|
return buf.String(), buf.Args(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) genSelectColumnStr() string {
|
||||||
|
// manually select columns
|
||||||
|
if len(statement.SelectStr) > 0 {
|
||||||
|
return statement.SelectStr
|
||||||
|
}
|
||||||
|
|
||||||
|
columnStr := statement.ColumnStr()
|
||||||
|
if columnStr != "" {
|
||||||
|
return columnStr
|
||||||
|
}
|
||||||
|
|
||||||
|
// autodetect columns
|
||||||
|
if statement.GroupByStr != "" {
|
||||||
|
return statement.quoteColumnStr(statement.GroupByStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(statement.joins) != 0 {
|
||||||
|
return "*"
|
||||||
|
}
|
||||||
|
|
||||||
|
columnStr = statement.genColumnStr()
|
||||||
|
if columnStr == "" {
|
||||||
|
columnStr = "*"
|
||||||
|
}
|
||||||
|
return columnStr
|
||||||
|
}
|
||||||
|
|
||||||
// GenFindSQL generates Find SQL
|
// GenFindSQL generates Find SQL
|
||||||
func (statement *Statement) GenFindSQL(autoCond builder.Cond) (string, []interface{}, error) {
|
func (statement *Statement) GenFindSQL(autoCond builder.Cond) (string, []interface{}, error) {
|
||||||
if statement.RawSQL != "" {
|
if statement.RawSQL != "" {
|
||||||
@ -467,33 +519,11 @@ func (statement *Statement) GenFindSQL(autoCond builder.Cond) (string, []interfa
|
|||||||
return "", nil, ErrTableNotFound
|
return "", nil, ErrTableNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
columnStr := statement.ColumnStr()
|
|
||||||
if len(statement.SelectStr) > 0 {
|
|
||||||
columnStr = statement.SelectStr
|
|
||||||
} else {
|
|
||||||
if statement.JoinStr == "" {
|
|
||||||
if columnStr == "" {
|
|
||||||
if statement.GroupByStr != "" {
|
|
||||||
columnStr = statement.quoteColumnStr(statement.GroupByStr)
|
|
||||||
} else {
|
|
||||||
columnStr = statement.genColumnStr()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if columnStr == "" {
|
|
||||||
if statement.GroupByStr != "" {
|
|
||||||
columnStr = statement.quoteColumnStr(statement.GroupByStr)
|
|
||||||
} else {
|
|
||||||
columnStr = "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if columnStr == "" {
|
|
||||||
columnStr = "*"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
statement.cond = statement.cond.And(autoCond)
|
statement.cond = statement.cond.And(autoCond)
|
||||||
|
|
||||||
return statement.genSelectSQL(columnStr, true, true)
|
buf := builder.NewWriter()
|
||||||
|
if err := statement.writeSelect(buf, statement.genSelectColumnStr(), true, true); err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
return buf.String(), buf.Args(), nil
|
||||||
}
|
}
|
||||||
|
4
vendor/xorm.io/xorm/internal/statements/select.go
generated
vendored
4
vendor/xorm.io/xorm/internal/statements/select.go
generated
vendored
@ -102,7 +102,7 @@ func (statement *Statement) genColumnStr() string {
|
|||||||
buf.WriteString(", ")
|
buf.WriteString(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
if statement.JoinStr != "" {
|
if len(statement.joins) > 0 {
|
||||||
if statement.TableAlias != "" {
|
if statement.TableAlias != "" {
|
||||||
buf.WriteString(statement.TableAlias)
|
buf.WriteString(statement.TableAlias)
|
||||||
} else {
|
} else {
|
||||||
@ -119,7 +119,7 @@ func (statement *Statement) genColumnStr() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) colName(col *schemas.Column, tableName string) string {
|
func (statement *Statement) colName(col *schemas.Column, tableName string) string {
|
||||||
if statement.needTableName() {
|
if statement.NeedTableName() {
|
||||||
nm := tableName
|
nm := tableName
|
||||||
if len(statement.TableAlias) > 0 {
|
if len(statement.TableAlias) > 0 {
|
||||||
nm = statement.TableAlias
|
nm = statement.TableAlias
|
||||||
|
60
vendor/xorm.io/xorm/internal/statements/statement.go
generated
vendored
60
vendor/xorm.io/xorm/internal/statements/statement.go
generated
vendored
@ -34,6 +34,13 @@ var (
|
|||||||
ErrTableNotFound = errors.New("Table not found")
|
ErrTableNotFound = errors.New("Table not found")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type join struct {
|
||||||
|
op string
|
||||||
|
table interface{}
|
||||||
|
condition interface{}
|
||||||
|
args []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
// Statement save all the sql info for executing SQL
|
// Statement save all the sql info for executing SQL
|
||||||
type Statement struct {
|
type Statement struct {
|
||||||
RefTable *schemas.Table
|
RefTable *schemas.Table
|
||||||
@ -43,10 +50,8 @@ type Statement struct {
|
|||||||
Start int
|
Start int
|
||||||
LimitN *int
|
LimitN *int
|
||||||
idParam schemas.PK
|
idParam schemas.PK
|
||||||
orderStr string
|
orderBy []orderBy
|
||||||
orderArgs []interface{}
|
joins []join
|
||||||
JoinStr string
|
|
||||||
joinArgs []interface{}
|
|
||||||
GroupByStr string
|
GroupByStr string
|
||||||
HavingStr string
|
HavingStr string
|
||||||
SelectStr string
|
SelectStr string
|
||||||
@ -123,8 +128,7 @@ func (statement *Statement) Reset() {
|
|||||||
statement.LimitN = nil
|
statement.LimitN = nil
|
||||||
statement.ResetOrderBy()
|
statement.ResetOrderBy()
|
||||||
statement.UseCascade = true
|
statement.UseCascade = true
|
||||||
statement.JoinStr = ""
|
statement.joins = nil
|
||||||
statement.joinArgs = make([]interface{}, 0)
|
|
||||||
statement.GroupByStr = ""
|
statement.GroupByStr = ""
|
||||||
statement.HavingStr = ""
|
statement.HavingStr = ""
|
||||||
statement.ColumnMap = columnMap{}
|
statement.ColumnMap = columnMap{}
|
||||||
@ -158,15 +162,15 @@ func (statement *Statement) Reset() {
|
|||||||
|
|
||||||
// SQL adds raw sql statement
|
// SQL adds raw sql statement
|
||||||
func (statement *Statement) SQL(query interface{}, args ...interface{}) *Statement {
|
func (statement *Statement) SQL(query interface{}, args ...interface{}) *Statement {
|
||||||
switch query.(type) {
|
switch t := query.(type) {
|
||||||
case (*builder.Builder):
|
case (*builder.Builder):
|
||||||
var err error
|
var err error
|
||||||
statement.RawSQL, statement.RawParams, err = query.(*builder.Builder).ToSQL()
|
statement.RawSQL, statement.RawParams, err = t.ToSQL()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
statement.LastError = err
|
statement.LastError = err
|
||||||
}
|
}
|
||||||
case string:
|
case string:
|
||||||
statement.RawSQL = query.(string)
|
statement.RawSQL = t
|
||||||
statement.RawParams = args
|
statement.RawParams = args
|
||||||
default:
|
default:
|
||||||
statement.LastError = ErrUnSupportedSQLType
|
statement.LastError = ErrUnSupportedSQLType
|
||||||
@ -205,8 +209,8 @@ func (statement *Statement) SetRefBean(bean interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) needTableName() bool {
|
func (statement *Statement) NeedTableName() bool {
|
||||||
return len(statement.JoinStr) > 0
|
return len(statement.joins) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incr Generate "Update ... Set column = column + arg" statement
|
// Incr Generate "Update ... Set column = column + arg" statement
|
||||||
@ -290,17 +294,17 @@ func (statement *Statement) GroupBy(keys string) *Statement {
|
|||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
func (statement *Statement) WriteGroupBy(w builder.Writer) error {
|
func (statement *Statement) writeGroupBy(w builder.Writer) error {
|
||||||
if statement.GroupByStr == "" {
|
if statement.GroupByStr == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
_, err := fmt.Fprintf(w, " GROUP BY %s", statement.GroupByStr)
|
_, err := fmt.Fprint(w, " GROUP BY ", statement.GroupByStr)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Having generate "Having conditions" statement
|
// Having generate "Having conditions" statement
|
||||||
func (statement *Statement) Having(conditions string) *Statement {
|
func (statement *Statement) Having(conditions string) *Statement {
|
||||||
statement.HavingStr = fmt.Sprintf("HAVING %v", statement.ReplaceQuote(conditions))
|
statement.HavingStr = conditions
|
||||||
return statement
|
return statement
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +312,7 @@ func (statement *Statement) writeHaving(w builder.Writer) error {
|
|||||||
if statement.HavingStr == "" {
|
if statement.HavingStr == "" {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
_, err := fmt.Fprint(w, " ", statement.HavingStr)
|
_, err := fmt.Fprint(w, " HAVING ", statement.ReplaceQuote(statement.HavingStr))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,7 +609,7 @@ func (statement *Statement) BuildConds(table *schemas.Table, bean interface{}, i
|
|||||||
// MergeConds merge conditions from bean and id
|
// MergeConds merge conditions from bean and id
|
||||||
func (statement *Statement) MergeConds(bean interface{}) error {
|
func (statement *Statement) MergeConds(bean interface{}) error {
|
||||||
if !statement.NoAutoCondition && statement.RefTable != nil {
|
if !statement.NoAutoCondition && statement.RefTable != nil {
|
||||||
addedTableName := (len(statement.JoinStr) > 0)
|
addedTableName := (len(statement.joins) > 0)
|
||||||
autoCond, err := statement.BuildConds(statement.RefTable, bean, true, true, false, true, addedTableName)
|
autoCond, err := statement.BuildConds(statement.RefTable, bean, true, true, false, true, addedTableName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -640,6 +644,23 @@ func (statement *Statement) convertSQLOrArgs(sqlOrArgs ...interface{}) (string,
|
|||||||
newArgs = append(newArgs, v.In(statement.defaultTimeZone).Format("2006-01-02 15:04:05"))
|
newArgs = append(newArgs, v.In(statement.defaultTimeZone).Format("2006-01-02 15:04:05"))
|
||||||
} else if v, ok := arg.(*time.Time); ok && v != nil {
|
} else if v, ok := arg.(*time.Time); ok && v != nil {
|
||||||
newArgs = append(newArgs, v.In(statement.defaultTimeZone).Format("2006-01-02 15:04:05"))
|
newArgs = append(newArgs, v.In(statement.defaultTimeZone).Format("2006-01-02 15:04:05"))
|
||||||
|
} else if v, ok := arg.(convert.ConversionTo); ok {
|
||||||
|
r, err := v.ToDB()
|
||||||
|
if err != nil {
|
||||||
|
return "", nil, err
|
||||||
|
}
|
||||||
|
if r != nil {
|
||||||
|
// for nvarchar column on mssql, bytes have to be converted as ucs-2 external of driver
|
||||||
|
// for binary column, a string will be converted as bytes directly. So we have to
|
||||||
|
// convert bytes as string
|
||||||
|
if statement.dialect.URI().DBType == schemas.MSSQL {
|
||||||
|
newArgs = append(newArgs, string(r))
|
||||||
|
} else {
|
||||||
|
newArgs = append(newArgs, r)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newArgs = append(newArgs, nil)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
newArgs = append(newArgs, arg)
|
newArgs = append(newArgs, arg)
|
||||||
}
|
}
|
||||||
@ -673,7 +694,7 @@ func (statement *Statement) joinColumns(cols []*schemas.Column, includeTableName
|
|||||||
// CondDeleted returns the conditions whether a record is soft deleted.
|
// CondDeleted returns the conditions whether a record is soft deleted.
|
||||||
func (statement *Statement) CondDeleted(col *schemas.Column) builder.Cond {
|
func (statement *Statement) CondDeleted(col *schemas.Column) builder.Cond {
|
||||||
colName := statement.quote(col.Name)
|
colName := statement.quote(col.Name)
|
||||||
if statement.JoinStr != "" {
|
if len(statement.joins) > 0 {
|
||||||
var prefix string
|
var prefix string
|
||||||
if statement.TableAlias != "" {
|
if statement.TableAlias != "" {
|
||||||
prefix = statement.TableAlias
|
prefix = statement.TableAlias
|
||||||
@ -686,10 +707,7 @@ func (statement *Statement) CondDeleted(col *schemas.Column) builder.Cond {
|
|||||||
if col.SQLType.IsNumeric() {
|
if col.SQLType.IsNumeric() {
|
||||||
cond = builder.Eq{colName: 0}
|
cond = builder.Eq{colName: 0}
|
||||||
} else {
|
} else {
|
||||||
// FIXME: mssql: The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.
|
cond = builder.Eq{colName: utils.ZeroTime1}
|
||||||
if statement.dialect.URI().DBType != schemas.MSSQL {
|
|
||||||
cond = builder.Eq{colName: utils.ZeroTime1}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if col.Nullable {
|
if col.Nullable {
|
||||||
|
337
vendor/xorm.io/xorm/internal/statements/update.go
generated
vendored
337
vendor/xorm.io/xorm/internal/statements/update.go
generated
vendored
@ -11,6 +11,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/dialects"
|
||||||
"xorm.io/xorm/internal/json"
|
"xorm.io/xorm/internal/json"
|
||||||
@ -19,7 +20,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (statement *Statement) ifAddColUpdate(col *schemas.Column, includeVersion, includeUpdated, includeNil,
|
func (statement *Statement) ifAddColUpdate(col *schemas.Column, includeVersion, includeUpdated, includeNil,
|
||||||
includeAutoIncr, update bool) (bool, error) {
|
includeAutoIncr, update bool,
|
||||||
|
) (bool, error) {
|
||||||
columnMap := statement.ColumnMap
|
columnMap := statement.ColumnMap
|
||||||
omitColumnMap := statement.OmitColumnMap
|
omitColumnMap := statement.OmitColumnMap
|
||||||
unscoped := statement.unscoped
|
unscoped := statement.unscoped
|
||||||
@ -64,15 +66,16 @@ func (statement *Statement) ifAddColUpdate(col *schemas.Column, includeVersion,
|
|||||||
// BuildUpdates auto generating update columnes and values according a struct
|
// BuildUpdates auto generating update columnes and values according a struct
|
||||||
func (statement *Statement) BuildUpdates(tableValue reflect.Value,
|
func (statement *Statement) BuildUpdates(tableValue reflect.Value,
|
||||||
includeVersion, includeUpdated, includeNil,
|
includeVersion, includeUpdated, includeNil,
|
||||||
includeAutoIncr, update bool) ([]string, []interface{}, error) {
|
includeAutoIncr, update bool,
|
||||||
|
) ([]string, []interface{}, error) {
|
||||||
table := statement.RefTable
|
table := statement.RefTable
|
||||||
allUseBool := statement.allUseBool
|
allUseBool := statement.allUseBool
|
||||||
useAllCols := statement.useAllCols
|
useAllCols := statement.useAllCols
|
||||||
mustColumnMap := statement.MustColumnMap
|
mustColumnMap := statement.MustColumnMap
|
||||||
nullableMap := statement.NullableMap
|
nullableMap := statement.NullableMap
|
||||||
|
|
||||||
var colNames = make([]string, 0)
|
colNames := make([]string, 0)
|
||||||
var args = make([]interface{}, 0)
|
args := make([]interface{}, 0)
|
||||||
|
|
||||||
for _, col := range table.Columns() {
|
for _, col := range table.Columns() {
|
||||||
ok, err := statement.ifAddColUpdate(col, includeVersion, includeUpdated, includeNil,
|
ok, err := statement.ifAddColUpdate(col, includeVersion, includeUpdated, includeNil,
|
||||||
@ -306,3 +309,329 @@ func (statement *Statement) BuildUpdates(tableValue reflect.Value,
|
|||||||
|
|
||||||
return colNames, args, nil
|
return colNames, args, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeUpdateTop(updateWriter *builder.BytesWriter) error {
|
||||||
|
if statement.dialect.URI().DBType != schemas.MSSQL || statement.LimitN == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
table := statement.RefTable
|
||||||
|
if statement.HasOrderBy() && table != nil && len(table.PrimaryKeys) == 1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := fmt.Fprintf(updateWriter, " TOP (%d)", *statement.LimitN)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeUpdateTableName(updateWriter *builder.BytesWriter) error {
|
||||||
|
tableName := statement.quote(statement.TableName())
|
||||||
|
if statement.TableAlias == "" {
|
||||||
|
_, err := fmt.Fprint(updateWriter, " ", tableName)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch statement.dialect.URI().DBType {
|
||||||
|
case schemas.MSSQL:
|
||||||
|
_, err := fmt.Fprint(updateWriter, " ", statement.TableAlias)
|
||||||
|
return err
|
||||||
|
default:
|
||||||
|
_, err := fmt.Fprint(updateWriter, " ", tableName, " AS ", statement.TableAlias)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeUpdateFrom(updateWriter *builder.BytesWriter) error {
|
||||||
|
if statement.dialect.URI().DBType != schemas.MSSQL || statement.TableAlias == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := fmt.Fprint(updateWriter, " FROM ", statement.quote(statement.TableName()), " ", statement.TableAlias)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeUpdateLimit(updateWriter *builder.BytesWriter, cond builder.Cond) error {
|
||||||
|
if statement.LimitN == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
table := statement.RefTable
|
||||||
|
tableName := statement.TableName()
|
||||||
|
|
||||||
|
limitValue := *statement.LimitN
|
||||||
|
switch statement.dialect.URI().DBType {
|
||||||
|
case schemas.MYSQL:
|
||||||
|
_, err := fmt.Fprintf(updateWriter, " LIMIT %d", limitValue)
|
||||||
|
return err
|
||||||
|
case schemas.SQLITE:
|
||||||
|
if cond.IsValid() {
|
||||||
|
if _, err := fmt.Fprint(updateWriter, " AND "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := fmt.Fprint(updateWriter, " WHERE "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(updateWriter, "rowid IN (SELECT rowid FROM ", statement.quote(tableName)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeWhereCond(updateWriter, cond); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeOrderBys(updateWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err := fmt.Fprintf(updateWriter, " LIMIT %d)", limitValue)
|
||||||
|
return err
|
||||||
|
case schemas.POSTGRES:
|
||||||
|
if cond.IsValid() {
|
||||||
|
if _, err := fmt.Fprint(updateWriter, " AND "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if _, err := fmt.Fprint(updateWriter, " WHERE "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(updateWriter, "CTID IN (SELECT CTID FROM ", statement.quote(tableName)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeWhereCond(updateWriter, cond); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeOrderBys(updateWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err := fmt.Fprintf(updateWriter, " LIMIT %d)", limitValue)
|
||||||
|
return err
|
||||||
|
case schemas.MSSQL:
|
||||||
|
if statement.HasOrderBy() && table != nil && len(table.PrimaryKeys) == 1 {
|
||||||
|
if _, err := fmt.Fprintf(updateWriter, " WHERE %s IN (SELECT TOP (%d) %s FROM %v",
|
||||||
|
table.PrimaryKeys[0], limitValue, table.PrimaryKeys[0],
|
||||||
|
statement.quote(tableName)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeWhereCond(updateWriter, cond); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := statement.writeOrderBys(updateWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
_, err := fmt.Fprint(updateWriter, ")")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
default: // TODO: Oracle support needed
|
||||||
|
return fmt.Errorf("not implemented")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) GenConditionsFromMap(m interface{}) ([]builder.Cond, error) {
|
||||||
|
switch t := m.(type) {
|
||||||
|
case map[string]interface{}:
|
||||||
|
conds := []builder.Cond{}
|
||||||
|
for k, v := range t {
|
||||||
|
conds = append(conds, builder.Eq{k: v})
|
||||||
|
}
|
||||||
|
return conds, nil
|
||||||
|
case map[string]string:
|
||||||
|
conds := []builder.Cond{}
|
||||||
|
for k, v := range t {
|
||||||
|
conds = append(conds, builder.Eq{k: v})
|
||||||
|
}
|
||||||
|
return conds, nil
|
||||||
|
default:
|
||||||
|
return nil, fmt.Errorf("unsupported condition map type %v", t)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeVersionIncrSet(w builder.Writer, v reflect.Value, hasPreviousSet bool) error {
|
||||||
|
if v.Type().Kind() != reflect.Struct {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
table := statement.RefTable
|
||||||
|
if !(statement.RefTable != nil && table.Version != "" && statement.CheckVersion) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
verValue, err := table.VersionColumn().ValueOfV(&v)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if verValue == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if hasPreviousSet {
|
||||||
|
if _, err := fmt.Fprint(w, ", "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := fmt.Fprint(w, statement.quote(table.Version), " = ", statement.quote(table.Version), " + 1"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeIncrSets(w builder.Writer, hasPreviousSet bool) error {
|
||||||
|
for i, expr := range statement.IncrColumns {
|
||||||
|
if i > 0 || hasPreviousSet {
|
||||||
|
if _, err := fmt.Fprint(w, ", "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, statement.quote(expr.ColName), " = ", statement.quote(expr.ColName), " + ?"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.Append(expr.Arg)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeDecrSets(w builder.Writer, hasPreviousSet bool) error {
|
||||||
|
// for update action to like "column = column - ?"
|
||||||
|
for i, expr := range statement.DecrColumns {
|
||||||
|
if i > 0 || hasPreviousSet {
|
||||||
|
if _, err := fmt.Fprint(w, ", "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, statement.quote(expr.ColName), " = ", statement.quote(expr.ColName), " - ?"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.Append(expr.Arg)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeExprSets(w *builder.BytesWriter, hasPreviousSet bool) error {
|
||||||
|
// for update action to like "column = expression"
|
||||||
|
for i, expr := range statement.ExprColumns {
|
||||||
|
if i > 0 || hasPreviousSet {
|
||||||
|
if _, err := fmt.Fprint(w, ", "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch tp := expr.Arg.(type) {
|
||||||
|
case string:
|
||||||
|
if len(tp) == 0 {
|
||||||
|
tp = "''"
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, statement.quote(expr.ColName), " = ", tp); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case *builder.Builder:
|
||||||
|
if _, err := fmt.Fprint(w, statement.quote(expr.ColName), " = ("); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := tp.WriteTo(statement.QuoteReplacer(w)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, ")"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
if _, err := fmt.Fprint(w, statement.quote(expr.ColName), " = ?"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.Append(expr.Arg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (statement *Statement) writeUpdateSets(w *builder.BytesWriter, v reflect.Value, colNames []string, args []interface{}) error {
|
||||||
|
previousLen := w.Len()
|
||||||
|
for i, colName := range colNames {
|
||||||
|
if i > 0 {
|
||||||
|
if _, err := fmt.Fprint(w, ", "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if _, err := fmt.Fprint(w, colName); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
w.Append(args...)
|
||||||
|
|
||||||
|
if err := statement.writeIncrSets(w, w.Len() > previousLen); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := statement.writeDecrSets(w, w.Len() > previousLen); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := statement.writeExprSets(w, w.Len() > previousLen); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := statement.writeVersionIncrSet(w, v, w.Len() > previousLen); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var ErrNoColumnsTobeUpdated = errors.New("no columns found to be updated")
|
||||||
|
|
||||||
|
func (statement *Statement) WriteUpdate(updateWriter *builder.BytesWriter, cond builder.Cond, v reflect.Value, colNames []string, args []interface{}) error {
|
||||||
|
if _, err := fmt.Fprintf(updateWriter, "UPDATE"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := statement.writeUpdateTop(updateWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := statement.writeUpdateTableName(updateWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// write set
|
||||||
|
if _, err := fmt.Fprint(updateWriter, " SET "); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
previousLen := updateWriter.Len()
|
||||||
|
|
||||||
|
if err := statement.writeUpdateSets(updateWriter, v, colNames, args); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// if no columns to be updated, return error
|
||||||
|
if previousLen == updateWriter.Len() {
|
||||||
|
return ErrNoColumnsTobeUpdated
|
||||||
|
}
|
||||||
|
|
||||||
|
// write from
|
||||||
|
if err := statement.writeUpdateFrom(updateWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if statement.dialect.URI().DBType == schemas.MSSQL {
|
||||||
|
table := statement.RefTable
|
||||||
|
if statement.HasOrderBy() && table != nil && len(table.PrimaryKeys) == 1 {
|
||||||
|
} else {
|
||||||
|
// write where
|
||||||
|
if err := statement.writeWhereCond(updateWriter, cond); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// write where
|
||||||
|
if err := statement.writeWhereCond(updateWriter, cond); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if statement.dialect.URI().DBType == schemas.MYSQL {
|
||||||
|
if err := statement.writeOrderBys(updateWriter); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return statement.writeUpdateLimit(updateWriter, cond)
|
||||||
|
}
|
||||||
|
16
vendor/xorm.io/xorm/rows.go
generated
vendored
16
vendor/xorm.io/xorm/rows.go
generated
vendored
@ -46,8 +46,8 @@ func newRows(session *Session, bean interface{}) (*Rows, error) {
|
|||||||
|
|
||||||
if rows.session.statement.RawSQL == "" {
|
if rows.session.statement.RawSQL == "" {
|
||||||
var autoCond builder.Cond
|
var autoCond builder.Cond
|
||||||
var addedTableName = (len(session.statement.JoinStr) > 0)
|
addedTableName := session.statement.NeedTableName()
|
||||||
var table = rows.session.statement.RefTable
|
table := rows.session.statement.RefTable
|
||||||
|
|
||||||
if !session.statement.NoAutoCondition {
|
if !session.statement.NoAutoCondition {
|
||||||
var err error
|
var err error
|
||||||
@ -103,12 +103,12 @@ func (rows *Rows) Scan(beans ...interface{}) error {
|
|||||||
return rows.Err()
|
return rows.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
var bean = beans[0]
|
bean := beans[0]
|
||||||
var tp = reflect.TypeOf(bean)
|
tp := reflect.TypeOf(bean)
|
||||||
if tp.Kind() == reflect.Ptr {
|
if tp.Kind() == reflect.Ptr {
|
||||||
tp = tp.Elem()
|
tp = tp.Elem()
|
||||||
}
|
}
|
||||||
var beanKind = tp.Kind()
|
beanKind := tp.Kind()
|
||||||
|
|
||||||
if len(beans) == 1 {
|
if len(beans) == 1 {
|
||||||
if reflect.Indirect(reflect.ValueOf(bean)).Type() != rows.beanType {
|
if reflect.Indirect(reflect.ValueOf(bean)).Type() != rows.beanType {
|
||||||
@ -129,7 +129,9 @@ func (rows *Rows) Scan(beans ...interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := rows.session.scan(rows.rows, rows.session.statement.RefTable, beanKind, beans, types, fields); err != nil {
|
columnsSchema := ParseColumnsSchema(fields, types, rows.session.statement.RefTable)
|
||||||
|
|
||||||
|
if err := rows.session.scan(rows.rows, rows.session.statement.RefTable, beanKind, beans, columnsSchema, types, fields); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,6 +144,8 @@ func (rows *Rows) Close() error {
|
|||||||
defer rows.session.Close()
|
defer rows.session.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer rows.session.resetStatement()
|
||||||
|
|
||||||
if rows.rows != nil {
|
if rows.rows != nil {
|
||||||
return rows.rows.Close()
|
return rows.rows.Close()
|
||||||
}
|
}
|
||||||
|
10
vendor/xorm.io/xorm/schemas/collation.go
generated
vendored
Normal file
10
vendor/xorm.io/xorm/schemas/collation.go
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
// Copyright 2023 The Xorm Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package schemas
|
||||||
|
|
||||||
|
type Collation struct {
|
||||||
|
Name string
|
||||||
|
Column string // blank means it's a table collation
|
||||||
|
}
|
3
vendor/xorm.io/xorm/schemas/column.go
generated
vendored
3
vendor/xorm.io/xorm/schemas/column.go
generated
vendored
@ -45,6 +45,7 @@ type Column struct {
|
|||||||
DisableTimeZone bool
|
DisableTimeZone bool
|
||||||
TimeZone *time.Location // column specified time zone
|
TimeZone *time.Location // column specified time zone
|
||||||
Comment string
|
Comment string
|
||||||
|
Collation string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewColumn creates a new column
|
// NewColumn creates a new column
|
||||||
@ -89,6 +90,8 @@ func (col *Column) ValueOfV(dataStruct *reflect.Value) (*reflect.Value, error) {
|
|||||||
v.Set(reflect.New(v.Type().Elem()))
|
v.Set(reflect.New(v.Type().Elem()))
|
||||||
}
|
}
|
||||||
v = v.Elem()
|
v = v.Elem()
|
||||||
|
} else if v.Kind() == reflect.Interface {
|
||||||
|
v = reflect.Indirect(v.Elem())
|
||||||
}
|
}
|
||||||
v = v.FieldByIndex([]int{i})
|
v = v.FieldByIndex([]int{i})
|
||||||
}
|
}
|
||||||
|
23
vendor/xorm.io/xorm/schemas/quote.go
generated
vendored
23
vendor/xorm.io/xorm/schemas/quote.go
generated
vendored
@ -163,17 +163,18 @@ func (q Quoter) quoteWordTo(buf *strings.Builder, word string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// QuoteTo quotes the table or column names. i.e. if the quotes are [ and ]
|
// QuoteTo quotes the table or column names. i.e. if the quotes are [ and ]
|
||||||
// name -> [name]
|
//
|
||||||
// `name` -> [name]
|
// name -> [name]
|
||||||
// [name] -> [name]
|
// `name` -> [name]
|
||||||
// schema.name -> [schema].[name]
|
// [name] -> [name]
|
||||||
// `schema`.`name` -> [schema].[name]
|
// schema.name -> [schema].[name]
|
||||||
// `schema`.name -> [schema].[name]
|
// `schema`.`name` -> [schema].[name]
|
||||||
// schema.`name` -> [schema].[name]
|
// `schema`.name -> [schema].[name]
|
||||||
// [schema].name -> [schema].[name]
|
// schema.`name` -> [schema].[name]
|
||||||
// schema.[name] -> [schema].[name]
|
// [schema].name -> [schema].[name]
|
||||||
// name AS a -> [name] AS a
|
// schema.[name] -> [schema].[name]
|
||||||
// schema.name AS a -> [schema].[name] AS a
|
// name AS a -> [name] AS a
|
||||||
|
// schema.name AS a -> [schema].[name] AS a
|
||||||
func (q Quoter) QuoteTo(buf *strings.Builder, value string) error {
|
func (q Quoter) QuoteTo(buf *strings.Builder, value string) error {
|
||||||
var i int
|
var i int
|
||||||
for i < len(value) {
|
for i < len(value) {
|
||||||
|
4
vendor/xorm.io/xorm/schemas/table.go
generated
vendored
4
vendor/xorm.io/xorm/schemas/table.go
generated
vendored
@ -27,6 +27,7 @@ type Table struct {
|
|||||||
StoreEngine string
|
StoreEngine string
|
||||||
Charset string
|
Charset string
|
||||||
Comment string
|
Comment string
|
||||||
|
Collation string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEmptyTable creates an empty table
|
// NewEmptyTable creates an empty table
|
||||||
@ -36,7 +37,8 @@ func NewEmptyTable() *Table {
|
|||||||
|
|
||||||
// NewTable creates a new Table object
|
// NewTable creates a new Table object
|
||||||
func NewTable(name string, t reflect.Type) *Table {
|
func NewTable(name string, t reflect.Type) *Table {
|
||||||
return &Table{Name: name, Type: t,
|
return &Table{
|
||||||
|
Name: name, Type: t,
|
||||||
columnsSeq: make([]string, 0),
|
columnsSeq: make([]string, 0),
|
||||||
columns: make([]*Column, 0),
|
columns: make([]*Column, 0),
|
||||||
columnsMap: make(map[string][]*Column),
|
columnsMap: make(map[string][]*Column),
|
||||||
|
48
vendor/xorm.io/xorm/session.go
generated
vendored
48
vendor/xorm.io/xorm/session.go
generated
vendored
@ -16,8 +16,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"xorm.io/xorm/contexts"
|
"xorm.io/xorm/contexts"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/convert"
|
||||||
"xorm.io/xorm/core"
|
"xorm.io/xorm/core"
|
||||||
@ -330,7 +328,7 @@ func (session *Session) NoCache() *Session {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Join join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
// Join join_operator should be one of INNER, LEFT OUTER, CROSS etc - this will be prepended to JOIN
|
||||||
func (session *Session) Join(joinOperator string, tablename interface{}, condition string, args ...interface{}) *Session {
|
func (session *Session) Join(joinOperator string, tablename interface{}, condition interface{}, args ...interface{}) *Session {
|
||||||
session.statement.Join(joinOperator, tablename, condition, args...)
|
session.statement.Join(joinOperator, tablename, condition, args...)
|
||||||
return session
|
return session
|
||||||
}
|
}
|
||||||
@ -354,7 +352,7 @@ func (session *Session) DB() *core.DB {
|
|||||||
|
|
||||||
func (session *Session) canCache() bool {
|
func (session *Session) canCache() bool {
|
||||||
if session.statement.RefTable == nil ||
|
if session.statement.RefTable == nil ||
|
||||||
session.statement.JoinStr != "" ||
|
session.statement.NeedTableName() ||
|
||||||
session.statement.RawSQL != "" ||
|
session.statement.RawSQL != "" ||
|
||||||
!session.statement.UseCache ||
|
!session.statement.UseCache ||
|
||||||
session.statement.IsForUpdate ||
|
session.statement.IsForUpdate ||
|
||||||
@ -395,10 +393,10 @@ func (session *Session) doPrepareTx(sqlStr string) (stmt *core.Stmt, err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func getField(dataStruct *reflect.Value, table *schemas.Table, colName string, idx int) (*schemas.Column, *reflect.Value, error) {
|
func getField(dataStruct *reflect.Value, table *schemas.Table, field *QueryedField) (*schemas.Column, *reflect.Value, error) {
|
||||||
col := table.GetColumnIdx(colName, idx)
|
col := field.ColumnSchema
|
||||||
if col == nil {
|
if col == nil {
|
||||||
return nil, nil, ErrFieldIsNotExist{colName, table.Name}
|
return nil, nil, ErrFieldIsNotExist{field.FieldName, table.Name}
|
||||||
}
|
}
|
||||||
|
|
||||||
fieldValue, err := col.ValueOfV(dataStruct)
|
fieldValue, err := col.ValueOfV(dataStruct)
|
||||||
@ -406,10 +404,10 @@ func getField(dataStruct *reflect.Value, table *schemas.Table, colName string, i
|
|||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if fieldValue == nil {
|
if fieldValue == nil {
|
||||||
return nil, nil, ErrFieldIsNotValid{colName, table.Name}
|
return nil, nil, ErrFieldIsNotValid{field.FieldName, table.Name}
|
||||||
}
|
}
|
||||||
if !fieldValue.IsValid() || !fieldValue.CanSet() {
|
if !fieldValue.IsValid() || !fieldValue.CanSet() {
|
||||||
return nil, nil, ErrFieldIsNotValid{colName, table.Name}
|
return nil, nil, ErrFieldIsNotValid{field.FieldName, table.Name}
|
||||||
}
|
}
|
||||||
|
|
||||||
return col, fieldValue, nil
|
return col, fieldValue, nil
|
||||||
@ -418,7 +416,7 @@ func getField(dataStruct *reflect.Value, table *schemas.Table, colName string, i
|
|||||||
// Cell cell is a result of one column field
|
// Cell cell is a result of one column field
|
||||||
type Cell *interface{}
|
type Cell *interface{}
|
||||||
|
|
||||||
func (session *Session) rows2Beans(rows *core.Rows, fields []string, types []*sql.ColumnType,
|
func (session *Session) rows2Beans(rows *core.Rows, columnsSchema *ColumnsSchema, fields []string, types []*sql.ColumnType,
|
||||||
table *schemas.Table, newElemFunc func([]string) reflect.Value,
|
table *schemas.Table, newElemFunc func([]string) reflect.Value,
|
||||||
sliceValueSetFunc func(*reflect.Value, schemas.PK) error,
|
sliceValueSetFunc func(*reflect.Value, schemas.PK) error,
|
||||||
) error {
|
) error {
|
||||||
@ -432,7 +430,7 @@ func (session *Session) rows2Beans(rows *core.Rows, fields []string, types []*sq
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
pk, err := session.slice2Bean(scanResults, fields, bean, &dataStruct, table)
|
pk, err := session.slice2Bean(scanResults, columnsSchema, fields, bean, &dataStruct, table)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -705,28 +703,16 @@ func (session *Session) convertBeanField(col *schemas.Column, fieldValue *reflec
|
|||||||
return convert.AssignValue(fieldValue.Addr(), scanResult)
|
return convert.AssignValue(fieldValue.Addr(), scanResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) slice2Bean(scanResults []interface{}, fields []string, bean interface{}, dataStruct *reflect.Value, table *schemas.Table) (schemas.PK, error) {
|
func (session *Session) slice2Bean(scanResults []interface{}, columnsSchema *ColumnsSchema, fields []string, bean interface{}, dataStruct *reflect.Value, table *schemas.Table) (schemas.PK, error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
executeAfterSet(bean, fields, scanResults)
|
executeAfterSet(bean, fields, scanResults)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
buildAfterProcessors(session, bean)
|
buildAfterProcessors(session, bean)
|
||||||
|
|
||||||
tempMap := make(map[string]int)
|
|
||||||
var pk schemas.PK
|
var pk schemas.PK
|
||||||
for i, colName := range fields {
|
for i, field := range columnsSchema.Fields {
|
||||||
var idx int
|
col, fieldValue, err := getField(dataStruct, table, field)
|
||||||
lKey := strings.ToLower(colName)
|
|
||||||
var ok bool
|
|
||||||
|
|
||||||
if idx, ok = tempMap[lKey]; !ok {
|
|
||||||
idx = 0
|
|
||||||
} else {
|
|
||||||
idx++
|
|
||||||
}
|
|
||||||
tempMap[lKey] = idx
|
|
||||||
|
|
||||||
col, fieldValue, err := getField(dataStruct, table, colName, idx)
|
|
||||||
if _, ok := err.(ErrFieldIsNotExist); ok {
|
if _, ok := err.(ErrFieldIsNotExist); ok {
|
||||||
continue
|
continue
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
@ -794,3 +780,13 @@ func (session *Session) PingContext(ctx context.Context) error {
|
|||||||
session.engine.logger.Infof("PING DATABASE %v", session.engine.DriverName())
|
session.engine.logger.Infof("PING DATABASE %v", session.engine.DriverName())
|
||||||
return session.DB().PingContext(ctx)
|
return session.DB().PingContext(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// disable version check
|
||||||
|
func (session *Session) NoVersionCheck() *Session {
|
||||||
|
session.statement.CheckVersion = false
|
||||||
|
return session
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetDefaultJSONHandler(jsonHandler json.Interface) {
|
||||||
|
json.DefaultJSONHandler = jsonHandler
|
||||||
|
}
|
||||||
|
106
vendor/xorm.io/xorm/session_delete.go
generated
vendored
106
vendor/xorm.io/xorm/session_delete.go
generated
vendored
@ -6,22 +6,15 @@ package xorm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/caches"
|
||||||
"xorm.io/xorm/internal/utils"
|
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
// ErrNeedDeletedCond delete needs less one condition error
|
||||||
// ErrNeedDeletedCond delete needs less one condition error
|
var ErrNeedDeletedCond = errors.New("Delete action needs at least one condition")
|
||||||
ErrNeedDeletedCond = errors.New("Delete action needs at least one condition")
|
|
||||||
|
|
||||||
// ErrNotImplemented not implemented
|
|
||||||
ErrNotImplemented = errors.New("Not implemented")
|
|
||||||
)
|
|
||||||
|
|
||||||
func (session *Session) cacheDelete(table *schemas.Table, tableName, sqlStr string, args ...interface{}) error {
|
func (session *Session) cacheDelete(table *schemas.Table, tableName, sqlStr string, args ...interface{}) error {
|
||||||
if table == nil ||
|
if table == nil ||
|
||||||
@ -30,7 +23,7 @@ func (session *Session) cacheDelete(table *schemas.Table, tableName, sqlStr stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, filter := range session.engine.dialect.Filters() {
|
for _, filter := range session.engine.dialect.Filters() {
|
||||||
sqlStr = filter.Do(sqlStr)
|
sqlStr = filter.Do(session.ctx, sqlStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
newsql := session.statement.ConvertIDSQL(sqlStr)
|
newsql := session.statement.ConvertIDSQL(sqlStr)
|
||||||
@ -91,7 +84,18 @@ func (session *Session) cacheDelete(table *schemas.Table, tableName, sqlStr stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete records, bean's non-empty fields are conditions
|
// Delete records, bean's non-empty fields are conditions
|
||||||
|
// At least one condition must be set.
|
||||||
func (session *Session) Delete(beans ...interface{}) (int64, error) {
|
func (session *Session) Delete(beans ...interface{}) (int64, error) {
|
||||||
|
return session.delete(beans, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate records, bean's non-empty fields are conditions
|
||||||
|
// In contrast to Delete this method allows deletes without conditions.
|
||||||
|
func (session *Session) Truncate(beans ...interface{}) (int64, error) {
|
||||||
|
return session.delete(beans, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (session *Session) delete(beans []interface{}, mustHaveConditions bool) (int64, error) {
|
||||||
if session.isAutoClose {
|
if session.isAutoClose {
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
}
|
}
|
||||||
@ -101,9 +105,8 @@ func (session *Session) Delete(beans ...interface{}) (int64, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
condWriter = builder.NewWriter()
|
err error
|
||||||
err error
|
bean interface{}
|
||||||
bean interface{}
|
|
||||||
)
|
)
|
||||||
if len(beans) > 0 {
|
if len(beans) > 0 {
|
||||||
bean = beans[0]
|
bean = beans[0]
|
||||||
@ -122,90 +125,27 @@ func (session *Session) Delete(beans ...interface{}) (int64, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = session.statement.Conds().WriteTo(session.statement.QuoteReplacer(condWriter)); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
pLimitN := session.statement.LimitN
|
pLimitN := session.statement.LimitN
|
||||||
if condWriter.Len() == 0 && (pLimitN == nil || *pLimitN == 0) {
|
if mustHaveConditions && !session.statement.Conds().IsValid() && (pLimitN == nil || *pLimitN == 0) {
|
||||||
return 0, ErrNeedDeletedCond
|
return 0, ErrNeedDeletedCond
|
||||||
}
|
}
|
||||||
|
|
||||||
tableNameNoQuote := session.statement.TableName()
|
tableNameNoQuote := session.statement.TableName()
|
||||||
tableName := session.engine.Quote(tableNameNoQuote)
|
|
||||||
table := session.statement.RefTable
|
table := session.statement.RefTable
|
||||||
deleteSQLWriter := builder.NewWriter()
|
|
||||||
fmt.Fprintf(deleteSQLWriter, "DELETE FROM %v", tableName)
|
|
||||||
if condWriter.Len() > 0 {
|
|
||||||
fmt.Fprintf(deleteSQLWriter, " WHERE %v", condWriter.String())
|
|
||||||
deleteSQLWriter.Append(condWriter.Args()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
orderSQLWriter := builder.NewWriter()
|
realSQLWriter := builder.NewWriter()
|
||||||
if err := session.statement.WriteOrderBy(orderSQLWriter); err != nil {
|
deleteSQLWriter := builder.NewWriter()
|
||||||
|
if err := session.statement.WriteDelete(realSQLWriter, deleteSQLWriter, session.engine.nowTime); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if pLimitN != nil && *pLimitN > 0 {
|
|
||||||
limitNValue := *pLimitN
|
|
||||||
if _, err := fmt.Fprintf(orderSQLWriter, " LIMIT %d", limitNValue); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
orderCondWriter := builder.NewWriter()
|
|
||||||
if orderSQLWriter.Len() > 0 {
|
|
||||||
switch session.engine.dialect.URI().DBType {
|
|
||||||
case schemas.POSTGRES:
|
|
||||||
if condWriter.Len() > 0 {
|
|
||||||
fmt.Fprintf(orderCondWriter, " AND ")
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(orderCondWriter, " WHERE ")
|
|
||||||
}
|
|
||||||
fmt.Fprintf(orderCondWriter, "ctid IN (SELECT ctid FROM %s%s)", tableName, orderSQLWriter.String())
|
|
||||||
orderCondWriter.Append(orderSQLWriter.Args()...)
|
|
||||||
case schemas.SQLITE:
|
|
||||||
if condWriter.Len() > 0 {
|
|
||||||
fmt.Fprintf(orderCondWriter, " AND ")
|
|
||||||
} else {
|
|
||||||
fmt.Fprintf(orderCondWriter, " WHERE ")
|
|
||||||
}
|
|
||||||
fmt.Fprintf(orderCondWriter, "rowid IN (SELECT rowid FROM %s%s)", tableName, orderSQLWriter.String())
|
|
||||||
// TODO: how to handle delete limit on mssql?
|
|
||||||
case schemas.MSSQL:
|
|
||||||
return 0, ErrNotImplemented
|
|
||||||
default:
|
|
||||||
fmt.Fprint(orderCondWriter, orderSQLWriter.String())
|
|
||||||
orderCondWriter.Append(orderSQLWriter.Args()...)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
realSQLWriter := builder.NewWriter()
|
|
||||||
argsForCache := make([]interface{}, 0, len(deleteSQLWriter.Args())*2)
|
|
||||||
copy(argsForCache, deleteSQLWriter.Args())
|
|
||||||
argsForCache = append(deleteSQLWriter.Args(), argsForCache...)
|
|
||||||
if session.statement.GetUnscoped() || table == nil || table.DeletedColumn() == nil { // tag "deleted" is disabled
|
if session.statement.GetUnscoped() || table == nil || table.DeletedColumn() == nil { // tag "deleted" is disabled
|
||||||
if err := utils.WriteBuilder(realSQLWriter, deleteSQLWriter, orderCondWriter); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
deletedColumn := table.DeletedColumn()
|
deletedColumn := table.DeletedColumn()
|
||||||
if _, err := fmt.Fprintf(realSQLWriter, "UPDATE %v SET %v = ? WHERE %v",
|
_, t, err := session.engine.nowTime(deletedColumn)
|
||||||
session.engine.Quote(session.statement.TableName()),
|
|
||||||
session.engine.Quote(deletedColumn.Name),
|
|
||||||
condWriter.String()); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
val, t, err := session.engine.nowTime(deletedColumn)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
realSQLWriter.Append(val)
|
|
||||||
realSQLWriter.Append(condWriter.Args()...)
|
|
||||||
|
|
||||||
if err := utils.WriteBuilder(realSQLWriter, orderCondWriter); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
colName := deletedColumn.Name
|
colName := deletedColumn.Name
|
||||||
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
||||||
@ -214,6 +154,10 @@ func (session *Session) Delete(beans ...interface{}) (int64, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
argsForCache := make([]interface{}, 0, len(deleteSQLWriter.Args())*2)
|
||||||
|
copy(argsForCache, deleteSQLWriter.Args())
|
||||||
|
argsForCache = append(deleteSQLWriter.Args(), argsForCache...)
|
||||||
|
|
||||||
if cacher := session.engine.GetCacher(tableNameNoQuote); cacher != nil && session.statement.UseCache {
|
if cacher := session.engine.GetCacher(tableNameNoQuote); cacher != nil && session.statement.UseCache {
|
||||||
_ = session.cacheDelete(table, tableNameNoQuote, deleteSQLWriter.String(), argsForCache...)
|
_ = session.cacheDelete(table, tableNameNoQuote, deleteSQLWriter.String(), argsForCache...)
|
||||||
}
|
}
|
||||||
|
69
vendor/xorm.io/xorm/session_find.go
generated
vendored
69
vendor/xorm.io/xorm/session_find.go
generated
vendored
@ -5,8 +5,10 @@
|
|||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/caches"
|
||||||
@ -114,7 +116,7 @@ func (session *Session) find(rowsSlicePtr interface{}, condiBean ...interface{})
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
table = session.statement.RefTable
|
table = session.statement.RefTable
|
||||||
addedTableName = (len(session.statement.JoinStr) > 0)
|
addedTableName = session.statement.NeedTableName()
|
||||||
autoCond builder.Cond
|
autoCond builder.Cond
|
||||||
)
|
)
|
||||||
if tp == tpStruct {
|
if tp == tpStruct {
|
||||||
@ -161,6 +163,64 @@ func (session *Session) find(rowsSlicePtr interface{}, condiBean ...interface{})
|
|||||||
return session.noCacheFind(table, sliceValue, sqlStr, args...)
|
return session.noCacheFind(table, sliceValue, sqlStr, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QueryedField struct {
|
||||||
|
FieldName string
|
||||||
|
LowerFieldName string
|
||||||
|
ColumnType *sql.ColumnType
|
||||||
|
TempIndex int
|
||||||
|
ColumnSchema *schemas.Column
|
||||||
|
}
|
||||||
|
|
||||||
|
type ColumnsSchema struct {
|
||||||
|
Fields []*QueryedField
|
||||||
|
FieldNames []string
|
||||||
|
Types []*sql.ColumnType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (columnsSchema *ColumnsSchema) ParseTableSchema(table *schemas.Table) {
|
||||||
|
for _, field := range columnsSchema.Fields {
|
||||||
|
field.ColumnSchema = table.GetColumnIdx(field.FieldName, field.TempIndex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func ParseColumnsSchema(fieldNames []string, types []*sql.ColumnType, table *schemas.Table) *ColumnsSchema {
|
||||||
|
var columnsSchema ColumnsSchema
|
||||||
|
|
||||||
|
fields := make([]*QueryedField, 0, len(fieldNames))
|
||||||
|
|
||||||
|
for i, fieldName := range fieldNames {
|
||||||
|
field := &QueryedField{
|
||||||
|
FieldName: fieldName,
|
||||||
|
LowerFieldName: strings.ToLower(fieldName),
|
||||||
|
ColumnType: types[i],
|
||||||
|
}
|
||||||
|
fields = append(fields, field)
|
||||||
|
}
|
||||||
|
|
||||||
|
columnsSchema.Fields = fields
|
||||||
|
|
||||||
|
tempMap := make(map[string]int)
|
||||||
|
for _, field := range fields {
|
||||||
|
var idx int
|
||||||
|
var ok bool
|
||||||
|
|
||||||
|
if idx, ok = tempMap[field.LowerFieldName]; !ok {
|
||||||
|
idx = 0
|
||||||
|
} else {
|
||||||
|
idx++
|
||||||
|
}
|
||||||
|
|
||||||
|
tempMap[field.LowerFieldName] = idx
|
||||||
|
field.TempIndex = idx
|
||||||
|
}
|
||||||
|
|
||||||
|
if table != nil {
|
||||||
|
columnsSchema.ParseTableSchema(table)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &columnsSchema
|
||||||
|
}
|
||||||
|
|
||||||
func (session *Session) noCacheFind(table *schemas.Table, containerValue reflect.Value, sqlStr string, args ...interface{}) error {
|
func (session *Session) noCacheFind(table *schemas.Table, containerValue reflect.Value, sqlStr string, args ...interface{}) error {
|
||||||
elemType := containerValue.Type().Elem()
|
elemType := containerValue.Type().Elem()
|
||||||
var isPointer bool
|
var isPointer bool
|
||||||
@ -238,7 +298,10 @@ func (session *Session) noCacheFind(table *schemas.Table, containerValue reflect
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = session.rows2Beans(rows, fields, types, tb, newElemFunc, containerValueSetFunc)
|
|
||||||
|
columnsSchema := ParseColumnsSchema(fields, types, tb)
|
||||||
|
|
||||||
|
err = session.rows2Beans(rows, columnsSchema, fields, types, tb, newElemFunc, containerValueSetFunc)
|
||||||
rows.Close()
|
rows.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -283,7 +346,7 @@ func (session *Session) cacheFind(t reflect.Type, sqlStr string, rowsSlicePtr in
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, filter := range session.engine.dialect.Filters() {
|
for _, filter := range session.engine.dialect.Filters() {
|
||||||
sqlStr = filter.Do(sqlStr)
|
sqlStr = filter.Do(session.ctx, sqlStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
newsql := session.statement.ConvertIDSQL(sqlStr)
|
newsql := session.statement.ConvertIDSQL(sqlStr)
|
||||||
|
10
vendor/xorm.io/xorm/session_get.go
generated
vendored
10
vendor/xorm.io/xorm/session_get.go
generated
vendored
@ -164,7 +164,9 @@ func (session *Session) nocacheGet(beanKind reflect.Kind, table *schemas.Table,
|
|||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := session.scan(rows, table, beanKind, beans, types, fields); err != nil {
|
columnsSchema := ParseColumnsSchema(fields, types, table)
|
||||||
|
|
||||||
|
if err := session.scan(rows, table, beanKind, beans, columnsSchema, types, fields); err != nil {
|
||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
rows.Close()
|
rows.Close()
|
||||||
@ -172,7 +174,7 @@ func (session *Session) nocacheGet(beanKind reflect.Kind, table *schemas.Table,
|
|||||||
return true, session.executeProcessors()
|
return true, session.executeProcessors()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *Session) scan(rows *core.Rows, table *schemas.Table, firstBeanKind reflect.Kind, beans []interface{}, types []*sql.ColumnType, fields []string) error {
|
func (session *Session) scan(rows *core.Rows, table *schemas.Table, firstBeanKind reflect.Kind, beans []interface{}, columnsSchema *ColumnsSchema, types []*sql.ColumnType, fields []string) error {
|
||||||
if len(beans) == 1 {
|
if len(beans) == 1 {
|
||||||
bean := beans[0]
|
bean := beans[0]
|
||||||
switch firstBeanKind {
|
switch firstBeanKind {
|
||||||
@ -186,7 +188,7 @@ func (session *Session) scan(rows *core.Rows, table *schemas.Table, firstBeanKin
|
|||||||
}
|
}
|
||||||
|
|
||||||
dataStruct := utils.ReflectValue(bean)
|
dataStruct := utils.ReflectValue(bean)
|
||||||
_, err = session.slice2Bean(scanResults, fields, bean, &dataStruct, table)
|
_, err = session.slice2Bean(scanResults, columnsSchema, fields, bean, &dataStruct, table)
|
||||||
return err
|
return err
|
||||||
case reflect.Slice:
|
case reflect.Slice:
|
||||||
return session.getSlice(rows, types, fields, bean)
|
return session.getSlice(rows, types, fields, bean)
|
||||||
@ -278,7 +280,7 @@ func (session *Session) cacheGet(bean interface{}, sqlStr string, args ...interf
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, filter := range session.engine.dialect.Filters() {
|
for _, filter := range session.engine.dialect.Filters() {
|
||||||
sqlStr = filter.Do(sqlStr)
|
sqlStr = filter.Do(session.ctx, sqlStr)
|
||||||
}
|
}
|
||||||
newsql := session.statement.ConvertIDSQL(sqlStr)
|
newsql := session.statement.ConvertIDSQL(sqlStr)
|
||||||
if newsql == "" {
|
if newsql == "" {
|
||||||
|
68
vendor/xorm.io/xorm/session_insert.go
generated
vendored
68
vendor/xorm.io/xorm/session_insert.go
generated
vendored
@ -12,6 +12,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/convert"
|
"xorm.io/xorm/convert"
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/dialects"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/internal/utils"
|
||||||
@ -156,14 +157,14 @@ func (session *Session) insertMultipleStruct(rowsSlicePtr interface{}) (int64, e
|
|||||||
}
|
}
|
||||||
args = append(args, val)
|
args = append(args, val)
|
||||||
|
|
||||||
var colName = col.Name
|
colName := col.Name
|
||||||
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
setColumnTime(bean, col, t)
|
setColumnTime(bean, col, t)
|
||||||
})
|
})
|
||||||
} else if col.IsVersion && session.statement.CheckVersion {
|
} else if col.IsVersion && session.statement.CheckVersion {
|
||||||
args = append(args, 1)
|
args = append(args, 1)
|
||||||
var colName = col.Name
|
colName := col.Name
|
||||||
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
setColumnInt(bean, col, 1)
|
setColumnInt(bean, col, 1)
|
||||||
@ -186,24 +187,12 @@ func (session *Session) insertMultipleStruct(rowsSlicePtr interface{}) (int64, e
|
|||||||
}
|
}
|
||||||
cleanupProcessorsClosures(&session.beforeClosures)
|
cleanupProcessorsClosures(&session.beforeClosures)
|
||||||
|
|
||||||
quoter := session.engine.dialect.Quoter()
|
w := builder.NewWriter()
|
||||||
var sql string
|
if err := session.statement.WriteInsertMultiple(w, tableName, colNames, colMultiPlaces); err != nil {
|
||||||
colStr := quoter.Join(colNames, ",")
|
return 0, err
|
||||||
if session.engine.dialect.URI().DBType == schemas.ORACLE {
|
|
||||||
temp := fmt.Sprintf(") INTO %s (%v) VALUES (",
|
|
||||||
quoter.Quote(tableName),
|
|
||||||
colStr)
|
|
||||||
sql = fmt.Sprintf("INSERT ALL INTO %s (%v) VALUES (%v) SELECT 1 FROM DUAL",
|
|
||||||
quoter.Quote(tableName),
|
|
||||||
colStr,
|
|
||||||
strings.Join(colMultiPlaces, temp))
|
|
||||||
} else {
|
|
||||||
sql = fmt.Sprintf("INSERT INTO %s (%v) VALUES (%v)",
|
|
||||||
quoter.Quote(tableName),
|
|
||||||
colStr,
|
|
||||||
strings.Join(colMultiPlaces, "),("))
|
|
||||||
}
|
}
|
||||||
res, err := session.exec(sql, args...)
|
|
||||||
|
res, err := session.exec(w.String(), args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
@ -276,7 +265,7 @@ func (session *Session) insertStruct(bean interface{}) (int64, error) {
|
|||||||
processor.BeforeInsert()
|
processor.BeforeInsert()
|
||||||
}
|
}
|
||||||
|
|
||||||
var tableName = session.statement.TableName()
|
tableName := session.statement.TableName()
|
||||||
table := session.statement.RefTable
|
table := session.statement.RefTable
|
||||||
|
|
||||||
colNames, args, err := session.genInsertColumns(bean)
|
colNames, args, err := session.genInsertColumns(bean)
|
||||||
@ -353,15 +342,15 @@ func (session *Session) insertStruct(bean interface{}) (int64, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if needCommit {
|
}
|
||||||
if err := session.Commit(); err != nil {
|
if needCommit {
|
||||||
return 0, err
|
if err := session.Commit(); err != nil {
|
||||||
}
|
return 0, err
|
||||||
}
|
|
||||||
if id == 0 {
|
|
||||||
return 0, errors.New("insert successfully but not returned id")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if id == 0 {
|
||||||
|
return 0, errors.New("insert successfully but not returned id")
|
||||||
|
}
|
||||||
|
|
||||||
defer handleAfterInsertProcessorFunc(bean)
|
defer handleAfterInsertProcessorFunc(bean)
|
||||||
|
|
||||||
@ -482,7 +471,8 @@ func (session *Session) genInsertColumns(bean interface{}) ([]string, []interfac
|
|||||||
}
|
}
|
||||||
|
|
||||||
if col.IsDeleted {
|
if col.IsDeleted {
|
||||||
arg, err := dialects.FormatColumnTime(session.engine.dialect, session.engine.DatabaseTZ, col, time.Time{})
|
zeroTime := time.Date(1, 1, 1, 0, 0, 0, 0, session.engine.DatabaseTZ)
|
||||||
|
arg, err := dialects.FormatColumnTime(session.engine.dialect, session.engine.DatabaseTZ, col, zeroTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -517,7 +507,7 @@ func (session *Session) genInsertColumns(bean interface{}) ([]string, []interfac
|
|||||||
}
|
}
|
||||||
args = append(args, val)
|
args = append(args, val)
|
||||||
|
|
||||||
var colName = col.Name
|
colName := col.Name
|
||||||
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
session.afterClosures = append(session.afterClosures, func(bean interface{}) {
|
||||||
col := table.GetColumn(colName)
|
col := table.GetColumn(colName)
|
||||||
setColumnTime(bean, col, t)
|
setColumnTime(bean, col, t)
|
||||||
@ -547,7 +537,7 @@ func (session *Session) insertMapInterface(m map[string]interface{}) (int64, err
|
|||||||
return 0, ErrTableNotFound
|
return 0, ErrTableNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
var columns = make([]string, 0, len(m))
|
columns := make([]string, 0, len(m))
|
||||||
exprs := session.statement.ExprColumns
|
exprs := session.statement.ExprColumns
|
||||||
for k := range m {
|
for k := range m {
|
||||||
if !exprs.IsColExist(k) {
|
if !exprs.IsColExist(k) {
|
||||||
@ -556,7 +546,7 @@ func (session *Session) insertMapInterface(m map[string]interface{}) (int64, err
|
|||||||
}
|
}
|
||||||
sort.Strings(columns)
|
sort.Strings(columns)
|
||||||
|
|
||||||
var args = make([]interface{}, 0, len(m))
|
args := make([]interface{}, 0, len(m))
|
||||||
for _, colName := range columns {
|
for _, colName := range columns {
|
||||||
args = append(args, m[colName])
|
args = append(args, m[colName])
|
||||||
}
|
}
|
||||||
@ -574,7 +564,7 @@ func (session *Session) insertMultipleMapInterface(maps []map[string]interface{}
|
|||||||
return 0, ErrTableNotFound
|
return 0, ErrTableNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
var columns = make([]string, 0, len(maps[0]))
|
columns := make([]string, 0, len(maps[0]))
|
||||||
exprs := session.statement.ExprColumns
|
exprs := session.statement.ExprColumns
|
||||||
for k := range maps[0] {
|
for k := range maps[0] {
|
||||||
if !exprs.IsColExist(k) {
|
if !exprs.IsColExist(k) {
|
||||||
@ -583,9 +573,9 @@ func (session *Session) insertMultipleMapInterface(maps []map[string]interface{}
|
|||||||
}
|
}
|
||||||
sort.Strings(columns)
|
sort.Strings(columns)
|
||||||
|
|
||||||
var argss = make([][]interface{}, 0, len(maps))
|
argss := make([][]interface{}, 0, len(maps))
|
||||||
for _, m := range maps {
|
for _, m := range maps {
|
||||||
var args = make([]interface{}, 0, len(m))
|
args := make([]interface{}, 0, len(m))
|
||||||
for _, colName := range columns {
|
for _, colName := range columns {
|
||||||
args = append(args, m[colName])
|
args = append(args, m[colName])
|
||||||
}
|
}
|
||||||
@ -605,7 +595,7 @@ func (session *Session) insertMapString(m map[string]string) (int64, error) {
|
|||||||
return 0, ErrTableNotFound
|
return 0, ErrTableNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
var columns = make([]string, 0, len(m))
|
columns := make([]string, 0, len(m))
|
||||||
exprs := session.statement.ExprColumns
|
exprs := session.statement.ExprColumns
|
||||||
for k := range m {
|
for k := range m {
|
||||||
if !exprs.IsColExist(k) {
|
if !exprs.IsColExist(k) {
|
||||||
@ -615,7 +605,7 @@ func (session *Session) insertMapString(m map[string]string) (int64, error) {
|
|||||||
|
|
||||||
sort.Strings(columns)
|
sort.Strings(columns)
|
||||||
|
|
||||||
var args = make([]interface{}, 0, len(m))
|
args := make([]interface{}, 0, len(m))
|
||||||
for _, colName := range columns {
|
for _, colName := range columns {
|
||||||
args = append(args, m[colName])
|
args = append(args, m[colName])
|
||||||
}
|
}
|
||||||
@ -633,7 +623,7 @@ func (session *Session) insertMultipleMapString(maps []map[string]string) (int64
|
|||||||
return 0, ErrTableNotFound
|
return 0, ErrTableNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
var columns = make([]string, 0, len(maps[0]))
|
columns := make([]string, 0, len(maps[0]))
|
||||||
exprs := session.statement.ExprColumns
|
exprs := session.statement.ExprColumns
|
||||||
for k := range maps[0] {
|
for k := range maps[0] {
|
||||||
if !exprs.IsColExist(k) {
|
if !exprs.IsColExist(k) {
|
||||||
@ -642,9 +632,9 @@ func (session *Session) insertMultipleMapString(maps []map[string]string) (int64
|
|||||||
}
|
}
|
||||||
sort.Strings(columns)
|
sort.Strings(columns)
|
||||||
|
|
||||||
var argss = make([][]interface{}, 0, len(maps))
|
argss := make([][]interface{}, 0, len(maps))
|
||||||
for _, m := range maps {
|
for _, m := range maps {
|
||||||
var args = make([]interface{}, 0, len(m))
|
args := make([]interface{}, 0, len(m))
|
||||||
for _, colName := range columns {
|
for _, colName := range columns {
|
||||||
args = append(args, m[colName])
|
args = append(args, m[colName])
|
||||||
}
|
}
|
||||||
|
2
vendor/xorm.io/xorm/session_raw.go
generated
vendored
2
vendor/xorm.io/xorm/session_raw.go
generated
vendored
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
func (session *Session) queryPreprocess(sqlStr *string, paramStr ...interface{}) {
|
func (session *Session) queryPreprocess(sqlStr *string, paramStr ...interface{}) {
|
||||||
for _, filter := range session.engine.dialect.Filters() {
|
for _, filter := range session.engine.dialect.Filters() {
|
||||||
*sqlStr = filter.Do(*sqlStr)
|
*sqlStr = filter.Do(session.ctx, *sqlStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
session.lastSQL = *sqlStr
|
session.lastSQL = *sqlStr
|
||||||
|
227
vendor/xorm.io/xorm/session_schema.go
generated
vendored
227
vendor/xorm.io/xorm/session_schema.go
generated
vendored
@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
"xorm.io/xorm/dialects"
|
"xorm.io/xorm/dialects"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Ping test if database is ok
|
// Ping test if database is ok
|
||||||
@ -169,7 +168,7 @@ func (session *Session) dropTable(beanOrTableName interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var seqName = utils.SeqName(tableName)
|
seqName := utils.SeqName(tableName)
|
||||||
exist, err := session.engine.dialect.IsSequenceExist(session.ctx, session.getQueryer(), seqName)
|
exist, err := session.engine.dialect.IsSequenceExist(session.ctx, session.getQueryer(), seqName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -244,228 +243,6 @@ func (session *Session) addUnique(tableName, uqeName string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync2 synchronize structs to database tables
|
|
||||||
// Depricated
|
|
||||||
func (session *Session) Sync2(beans ...interface{}) error {
|
|
||||||
return session.Sync(beans...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sync synchronize structs to database tables
|
|
||||||
func (session *Session) Sync(beans ...interface{}) error {
|
|
||||||
engine := session.engine
|
|
||||||
|
|
||||||
if session.isAutoClose {
|
|
||||||
session.isAutoClose = false
|
|
||||||
defer session.Close()
|
|
||||||
}
|
|
||||||
|
|
||||||
tables, err := engine.dialect.GetTables(session.getQueryer(), session.ctx)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
session.autoResetStatement = false
|
|
||||||
defer func() {
|
|
||||||
session.autoResetStatement = true
|
|
||||||
session.resetStatement()
|
|
||||||
}()
|
|
||||||
|
|
||||||
for _, bean := range beans {
|
|
||||||
v := utils.ReflectValue(bean)
|
|
||||||
table, err := engine.tagParser.ParseWithCache(v)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
var tbName string
|
|
||||||
if len(session.statement.AltTableName) > 0 {
|
|
||||||
tbName = session.statement.AltTableName
|
|
||||||
} else {
|
|
||||||
tbName = engine.TableName(bean)
|
|
||||||
}
|
|
||||||
tbNameWithSchema := engine.tbNameWithSchema(tbName)
|
|
||||||
|
|
||||||
var oriTable *schemas.Table
|
|
||||||
for _, tb := range tables {
|
|
||||||
if strings.EqualFold(engine.tbNameWithSchema(tb.Name), engine.tbNameWithSchema(tbName)) {
|
|
||||||
oriTable = tb
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// this is a new table
|
|
||||||
if oriTable == nil {
|
|
||||||
err = session.StoreEngine(session.statement.StoreEngine).createTable(bean)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = session.createUniques(bean)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = session.createIndexes(bean)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// this will modify an old table
|
|
||||||
if err = engine.loadTableInfo(oriTable); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// check columns
|
|
||||||
for _, col := range table.Columns() {
|
|
||||||
var oriCol *schemas.Column
|
|
||||||
for _, col2 := range oriTable.Columns() {
|
|
||||||
if strings.EqualFold(col.Name, col2.Name) {
|
|
||||||
oriCol = col2
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// column is not exist on table
|
|
||||||
if oriCol == nil {
|
|
||||||
session.statement.RefTable = table
|
|
||||||
session.statement.SetTableName(tbNameWithSchema)
|
|
||||||
if err = session.addColumn(col.Name); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
err = nil
|
|
||||||
expectedType := engine.dialect.SQLType(col)
|
|
||||||
curType := engine.dialect.SQLType(oriCol)
|
|
||||||
if expectedType != curType {
|
|
||||||
if expectedType == schemas.Text &&
|
|
||||||
strings.HasPrefix(curType, schemas.Varchar) {
|
|
||||||
// currently only support mysql & postgres
|
|
||||||
if engine.dialect.URI().DBType == schemas.MYSQL ||
|
|
||||||
engine.dialect.URI().DBType == schemas.POSTGRES {
|
|
||||||
engine.logger.Infof("Table %s column %s change type from %s to %s\n",
|
|
||||||
tbNameWithSchema, col.Name, curType, expectedType)
|
|
||||||
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
|
||||||
} else {
|
|
||||||
engine.logger.Warnf("Table %s column %s db type is %s, struct type is %s\n",
|
|
||||||
tbNameWithSchema, col.Name, curType, expectedType)
|
|
||||||
}
|
|
||||||
} else if strings.HasPrefix(curType, schemas.Varchar) && strings.HasPrefix(expectedType, schemas.Varchar) {
|
|
||||||
if engine.dialect.URI().DBType == schemas.MYSQL {
|
|
||||||
if oriCol.Length < col.Length {
|
|
||||||
engine.logger.Infof("Table %s column %s change type from varchar(%d) to varchar(%d)\n",
|
|
||||||
tbNameWithSchema, col.Name, oriCol.Length, col.Length)
|
|
||||||
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if !(strings.HasPrefix(curType, expectedType) && curType[len(expectedType)] == '(') {
|
|
||||||
if !strings.EqualFold(schemas.SQLTypeName(curType), engine.dialect.Alias(schemas.SQLTypeName(expectedType))) {
|
|
||||||
engine.logger.Warnf("Table %s column %s db type is %s, struct type is %s",
|
|
||||||
tbNameWithSchema, col.Name, curType, expectedType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if expectedType == schemas.Varchar {
|
|
||||||
if engine.dialect.URI().DBType == schemas.MYSQL {
|
|
||||||
if oriCol.Length < col.Length {
|
|
||||||
engine.logger.Infof("Table %s column %s change type from varchar(%d) to varchar(%d)\n",
|
|
||||||
tbNameWithSchema, col.Name, oriCol.Length, col.Length)
|
|
||||||
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if col.Comment != oriCol.Comment {
|
|
||||||
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
|
||||||
}
|
|
||||||
|
|
||||||
if col.Default != oriCol.Default {
|
|
||||||
switch {
|
|
||||||
case col.IsAutoIncrement: // For autoincrement column, don't check default
|
|
||||||
case (col.SQLType.Name == schemas.Bool || col.SQLType.Name == schemas.Boolean) &&
|
|
||||||
((strings.EqualFold(col.Default, "true") && oriCol.Default == "1") ||
|
|
||||||
(strings.EqualFold(col.Default, "false") && oriCol.Default == "0")):
|
|
||||||
default:
|
|
||||||
engine.logger.Warnf("Table %s Column %s db default is %s, struct default is %s",
|
|
||||||
tbName, col.Name, oriCol.Default, col.Default)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if col.Nullable != oriCol.Nullable {
|
|
||||||
engine.logger.Warnf("Table %s Column %s db nullable is %v, struct nullable is %v",
|
|
||||||
tbName, col.Name, oriCol.Nullable, col.Nullable)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var foundIndexNames = make(map[string]bool)
|
|
||||||
var addedNames = make(map[string]*schemas.Index)
|
|
||||||
|
|
||||||
for name, index := range table.Indexes {
|
|
||||||
var oriIndex *schemas.Index
|
|
||||||
for name2, index2 := range oriTable.Indexes {
|
|
||||||
if index.Equal(index2) {
|
|
||||||
oriIndex = index2
|
|
||||||
foundIndexNames[name2] = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if oriIndex != nil {
|
|
||||||
if oriIndex.Type != index.Type {
|
|
||||||
sql := engine.dialect.DropIndexSQL(tbNameWithSchema, oriIndex)
|
|
||||||
_, err = session.exec(sql)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
oriIndex = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if oriIndex == nil {
|
|
||||||
addedNames[name] = index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for name2, index2 := range oriTable.Indexes {
|
|
||||||
if _, ok := foundIndexNames[name2]; !ok {
|
|
||||||
sql := engine.dialect.DropIndexSQL(tbNameWithSchema, index2)
|
|
||||||
_, err = session.exec(sql)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for name, index := range addedNames {
|
|
||||||
if index.Type == schemas.UniqueType {
|
|
||||||
session.statement.RefTable = table
|
|
||||||
session.statement.SetTableName(tbNameWithSchema)
|
|
||||||
err = session.addUnique(tbNameWithSchema, name)
|
|
||||||
} else if index.Type == schemas.IndexType {
|
|
||||||
session.statement.RefTable = table
|
|
||||||
session.statement.SetTableName(tbNameWithSchema)
|
|
||||||
err = session.addIndex(tbNameWithSchema, name)
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// check all the columns which removed from struct fields but left on database tables.
|
|
||||||
for _, colName := range oriTable.ColumnsSeq() {
|
|
||||||
if table.GetColumn(colName) == nil {
|
|
||||||
engine.logger.Warnf("Table %s has column %s but struct has not related field", engine.TableName(oriTable.Name, true), colName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ImportFile SQL DDL file
|
// ImportFile SQL DDL file
|
||||||
func (session *Session) ImportFile(ddlPath string) ([]sql.Result, error) {
|
func (session *Session) ImportFile(ddlPath string) ([]sql.Result, error) {
|
||||||
file, err := os.Open(ddlPath)
|
file, err := os.Open(ddlPath)
|
||||||
@ -490,7 +267,7 @@ func (session *Session) Import(r io.Reader) ([]sql.Result, error) {
|
|||||||
if atEOF && len(data) == 0 {
|
if atEOF && len(data) == 0 {
|
||||||
return 0, nil, nil
|
return 0, nil, nil
|
||||||
}
|
}
|
||||||
var oriInSingleQuote = inSingleQuote
|
oriInSingleQuote := inSingleQuote
|
||||||
for i, b := range data {
|
for i, b := range data {
|
||||||
if startComment {
|
if startComment {
|
||||||
if b == '\n' {
|
if b == '\n' {
|
||||||
|
6
vendor/xorm.io/xorm/session_stats.go
generated
vendored
6
vendor/xorm.io/xorm/session_stats.go
generated
vendored
@ -24,7 +24,7 @@ func (session *Session) Count(bean ...interface{}) (int64, error) {
|
|||||||
|
|
||||||
var total int64
|
var total int64
|
||||||
err = session.queryRow(sqlStr, args...).Scan(&total)
|
err = session.queryRow(sqlStr, args...).Scan(&total)
|
||||||
if err == sql.ErrNoRows || err == nil {
|
if err == nil {
|
||||||
return total, nil
|
return total, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,12 +70,12 @@ func (session *Session) SumInt(bean interface{}, columnName string) (res int64,
|
|||||||
|
|
||||||
// Sums call sum some columns. bean's non-empty fields are conditions.
|
// Sums call sum some columns. bean's non-empty fields are conditions.
|
||||||
func (session *Session) Sums(bean interface{}, columnNames ...string) ([]float64, error) {
|
func (session *Session) Sums(bean interface{}, columnNames ...string) ([]float64, error) {
|
||||||
var res = make([]float64, len(columnNames))
|
res := make([]float64, len(columnNames))
|
||||||
return res, session.sum(&res, bean, columnNames...)
|
return res, session.sum(&res, bean, columnNames...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SumsInt sum specify columns and return as []int64 instead of []float64
|
// SumsInt sum specify columns and return as []int64 instead of []float64
|
||||||
func (session *Session) SumsInt(bean interface{}, columnNames ...string) ([]int64, error) {
|
func (session *Session) SumsInt(bean interface{}, columnNames ...string) ([]int64, error) {
|
||||||
var res = make([]int64, len(columnNames))
|
res := make([]int64, len(columnNames))
|
||||||
return res, session.sum(&res, bean, columnNames...)
|
return res, session.sum(&res, bean, columnNames...)
|
||||||
}
|
}
|
||||||
|
338
vendor/xorm.io/xorm/session_update.go
generated
vendored
338
vendor/xorm.io/xorm/session_update.go
generated
vendored
@ -5,149 +5,61 @@
|
|||||||
package xorm
|
package xorm
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
"xorm.io/xorm/caches"
|
"xorm.io/xorm/internal/statements"
|
||||||
"xorm.io/xorm/internal/utils"
|
"xorm.io/xorm/internal/utils"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/schemas"
|
||||||
)
|
)
|
||||||
|
|
||||||
// enumerated all errors
|
// enumerated all errors
|
||||||
var (
|
var (
|
||||||
ErrNoColumnsTobeUpdated = errors.New("no columns found to be updated")
|
ErrNoColumnsTobeUpdated = statements.ErrNoColumnsTobeUpdated
|
||||||
)
|
)
|
||||||
|
|
||||||
//revive:disable
|
func (session *Session) genAutoCond(condiBean interface{}) (builder.Cond, error) {
|
||||||
func (session *Session) cacheUpdate(table *schemas.Table, tableName, sqlStr string, args ...interface{}) error {
|
if session.statement.NoAutoCondition {
|
||||||
if table == nil ||
|
return builder.NewCond(), nil
|
||||||
session.tx != nil {
|
|
||||||
return ErrCacheFailed
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oldhead, newsql := session.statement.ConvertUpdateSQL(sqlStr)
|
if c, ok := condiBean.(map[string]interface{}); ok {
|
||||||
if newsql == "" {
|
eq := make(builder.Eq)
|
||||||
return ErrCacheFailed
|
for k, v := range c {
|
||||||
}
|
eq[session.engine.Quote(k)] = v
|
||||||
for _, filter := range session.engine.dialect.Filters() {
|
|
||||||
newsql = filter.Do(newsql)
|
|
||||||
}
|
|
||||||
session.engine.logger.Debugf("[cache] new sql: %v, %v", oldhead, newsql)
|
|
||||||
|
|
||||||
var nStart int
|
|
||||||
if len(args) > 0 {
|
|
||||||
if strings.Contains(sqlStr, "?") {
|
|
||||||
nStart = strings.Count(oldhead, "?")
|
|
||||||
} else {
|
|
||||||
// only for pq, TODO: if any other databse?
|
|
||||||
nStart = strings.Count(oldhead, "$")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if session.statement.RefTable != nil {
|
||||||
|
if col := session.statement.RefTable.DeletedColumn(); col != nil && !session.statement.GetUnscoped() { // tag "deleted" is enabled
|
||||||
|
return eq.And(session.statement.CondDeleted(col)), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return eq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
cacher := session.engine.GetCacher(tableName)
|
ct := reflect.TypeOf(condiBean)
|
||||||
session.engine.logger.Debugf("[cache] get cache sql: %v, %v", newsql, args[nStart:])
|
k := ct.Kind()
|
||||||
ids, err := caches.GetCacheSql(cacher, tableName, newsql, args[nStart:])
|
if k == reflect.Ptr {
|
||||||
|
k = ct.Elem().Kind()
|
||||||
|
}
|
||||||
|
if k != reflect.Struct {
|
||||||
|
return nil, ErrConditionType
|
||||||
|
}
|
||||||
|
|
||||||
|
condTable, err := session.engine.TableInfo(condiBean)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rows, err := session.NoCache().queryRows(newsql, args[nStart:]...)
|
return nil, err
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer rows.Close()
|
|
||||||
|
|
||||||
ids = make([]schemas.PK, 0)
|
|
||||||
for rows.Next() {
|
|
||||||
res := make([]string, len(table.PrimaryKeys))
|
|
||||||
err = rows.ScanSlice(&res)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
var pk schemas.PK = make([]interface{}, len(table.PrimaryKeys))
|
|
||||||
for i, col := range table.PKColumns() {
|
|
||||||
if col.SQLType.IsNumeric() {
|
|
||||||
n, err := strconv.ParseInt(res[i], 10, 64)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
pk[i] = n
|
|
||||||
} else if col.SQLType.IsText() {
|
|
||||||
pk[i] = res[i]
|
|
||||||
} else {
|
|
||||||
return errors.New("not supported")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ids = append(ids, pk)
|
|
||||||
}
|
|
||||||
if rows.Err() != nil {
|
|
||||||
return rows.Err()
|
|
||||||
}
|
|
||||||
session.engine.logger.Debugf("[cache] find updated id: %v", ids)
|
|
||||||
} /*else {
|
|
||||||
session.engine.LogDebug("[xorm:cacheUpdate] del cached sql:", tableName, newsql, args)
|
|
||||||
cacher.DelIds(tableName, genSqlKey(newsql, args))
|
|
||||||
}*/
|
|
||||||
|
|
||||||
for _, id := range ids {
|
|
||||||
sid, err := id.ToString()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if bean := cacher.GetBean(tableName, sid); bean != nil {
|
|
||||||
sqls := utils.SplitNNoCase(sqlStr, "where", 2)
|
|
||||||
if len(sqls) == 0 || len(sqls) > 2 {
|
|
||||||
return ErrCacheFailed
|
|
||||||
}
|
|
||||||
|
|
||||||
sqls = utils.SplitNNoCase(sqls[0], "set", 2)
|
|
||||||
if len(sqls) != 2 {
|
|
||||||
return ErrCacheFailed
|
|
||||||
}
|
|
||||||
kvs := strings.Split(strings.TrimSpace(sqls[1]), ",")
|
|
||||||
|
|
||||||
for idx, kv := range kvs {
|
|
||||||
sps := strings.SplitN(kv, "=", 2)
|
|
||||||
sps2 := strings.Split(sps[0], ".")
|
|
||||||
colName := sps2[len(sps2)-1]
|
|
||||||
colName = session.engine.dialect.Quoter().Trim(colName)
|
|
||||||
colName = schemas.CommonQuoter.Trim(colName)
|
|
||||||
|
|
||||||
if col := table.GetColumn(colName); col != nil {
|
|
||||||
fieldValue, err := col.ValueOf(bean)
|
|
||||||
if err != nil {
|
|
||||||
session.engine.logger.Errorf("%v", err)
|
|
||||||
} else {
|
|
||||||
session.engine.logger.Debugf("[cache] set bean field: %v, %v, %v", bean, colName, fieldValue.Interface())
|
|
||||||
if col.IsVersion && session.statement.CheckVersion {
|
|
||||||
session.incrVersionFieldValue(fieldValue)
|
|
||||||
} else {
|
|
||||||
fieldValue.Set(reflect.ValueOf(args[idx]))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
session.engine.logger.Errorf("[cache] ERROR: column %v is not table %v's",
|
|
||||||
colName, table.Name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
session.engine.logger.Debugf("[cache] update cache: %v, %v, %v", tableName, id, bean)
|
|
||||||
cacher.PutBean(tableName, sid, bean)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
session.engine.logger.Debugf("[cache] clear cached table sql: %v", tableName)
|
return session.statement.BuildConds(condTable, condiBean, true, true, false, true, false)
|
||||||
cacher.ClearIds(tableName)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update records, bean's non-empty fields are updated contents,
|
// Update records, bean's non-empty fields are updated contents,
|
||||||
// condiBean' non-empty filds are conditions
|
// condiBean' non-empty filds are conditions
|
||||||
// CAUTION:
|
// CAUTION:
|
||||||
// 1.bool will defaultly be updated content nor conditions
|
//
|
||||||
// You should call UseBool if you have bool to use.
|
// 1.bool will defaultly be updated content nor conditions
|
||||||
// 2.float32 & float64 may be not inexact as conditions
|
// You should call UseBool if you have bool to use.
|
||||||
|
// 2.float32 & float64 may be not inexact as conditions
|
||||||
func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int64, error) {
|
func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int64, error) {
|
||||||
if session.isAutoClose {
|
if session.isAutoClose {
|
||||||
defer session.Close()
|
defer session.Close()
|
||||||
@ -162,9 +74,6 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
|||||||
v := utils.ReflectValue(bean)
|
v := utils.ReflectValue(bean)
|
||||||
t := v.Type()
|
t := v.Type()
|
||||||
|
|
||||||
var colNames []string
|
|
||||||
var args []interface{}
|
|
||||||
|
|
||||||
// handle before update processors
|
// handle before update processors
|
||||||
for _, closure := range session.beforeClosures {
|
for _, closure := range session.beforeClosures {
|
||||||
closure(bean)
|
closure(bean)
|
||||||
@ -175,6 +84,8 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
|||||||
}
|
}
|
||||||
// --
|
// --
|
||||||
|
|
||||||
|
var colNames []string
|
||||||
|
var args []interface{}
|
||||||
var err error
|
var err error
|
||||||
isMap := t.Kind() == reflect.Map
|
isMap := t.Kind() == reflect.Map
|
||||||
isStruct := t.Kind() == reflect.Struct
|
isStruct := t.Kind() == reflect.Struct
|
||||||
@ -236,197 +147,53 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for update action to like "column = column + ?"
|
|
||||||
incColumns := session.statement.IncrColumns
|
|
||||||
for _, expr := range incColumns {
|
|
||||||
colNames = append(colNames, session.engine.Quote(expr.ColName)+" = "+session.engine.Quote(expr.ColName)+" + ?")
|
|
||||||
args = append(args, expr.Arg)
|
|
||||||
}
|
|
||||||
// for update action to like "column = column - ?"
|
|
||||||
decColumns := session.statement.DecrColumns
|
|
||||||
for _, expr := range decColumns {
|
|
||||||
colNames = append(colNames, session.engine.Quote(expr.ColName)+" = "+session.engine.Quote(expr.ColName)+" - ?")
|
|
||||||
args = append(args, expr.Arg)
|
|
||||||
}
|
|
||||||
// for update action to like "column = expression"
|
|
||||||
exprColumns := session.statement.ExprColumns
|
|
||||||
for _, expr := range exprColumns {
|
|
||||||
switch tp := expr.Arg.(type) {
|
|
||||||
case string:
|
|
||||||
if len(tp) == 0 {
|
|
||||||
tp = "''"
|
|
||||||
}
|
|
||||||
colNames = append(colNames, session.engine.Quote(expr.ColName)+"="+tp)
|
|
||||||
case *builder.Builder:
|
|
||||||
subQuery, subArgs, err := builder.ToSQL(tp)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
subQuery = session.statement.ReplaceQuote(subQuery)
|
|
||||||
colNames = append(colNames, session.engine.Quote(expr.ColName)+"=("+subQuery+")")
|
|
||||||
args = append(args, subArgs...)
|
|
||||||
default:
|
|
||||||
colNames = append(colNames, session.engine.Quote(expr.ColName)+"=?")
|
|
||||||
args = append(args, expr.Arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = session.statement.ProcessIDParam(); err != nil {
|
if err = session.statement.ProcessIDParam(); err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var autoCond builder.Cond
|
var autoCond builder.Cond
|
||||||
if !session.statement.NoAutoCondition {
|
if len(condiBean) > 0 {
|
||||||
condBeanIsStruct := false
|
autoCond, err = session.genAutoCond(condiBean[0])
|
||||||
if len(condiBean) > 0 {
|
if err != nil {
|
||||||
if c, ok := condiBean[0].(map[string]interface{}); ok {
|
return 0, err
|
||||||
eq := make(builder.Eq)
|
|
||||||
for k, v := range c {
|
|
||||||
eq[session.engine.Quote(k)] = v
|
|
||||||
}
|
|
||||||
autoCond = builder.Eq(eq)
|
|
||||||
} else {
|
|
||||||
ct := reflect.TypeOf(condiBean[0])
|
|
||||||
k := ct.Kind()
|
|
||||||
if k == reflect.Ptr {
|
|
||||||
k = ct.Elem().Kind()
|
|
||||||
}
|
|
||||||
if k == reflect.Struct {
|
|
||||||
condTable, err := session.engine.TableInfo(condiBean[0])
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
autoCond, err = session.statement.BuildConds(condTable, condiBean[0], true, true, false, true, false)
|
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
condBeanIsStruct = true
|
|
||||||
} else {
|
|
||||||
return 0, ErrConditionType
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else if table != nil {
|
||||||
|
if col := table.DeletedColumn(); col != nil && !session.statement.GetUnscoped() { // tag "deleted" is enabled
|
||||||
|
autoCond1 := session.statement.CondDeleted(col)
|
||||||
|
|
||||||
if !condBeanIsStruct && table != nil {
|
if autoCond == nil {
|
||||||
if col := table.DeletedColumn(); col != nil && !session.statement.GetUnscoped() { // tag "deleted" is enabled
|
autoCond = autoCond1
|
||||||
autoCond1 := session.statement.CondDeleted(col)
|
} else {
|
||||||
|
autoCond = autoCond.And(autoCond1)
|
||||||
if autoCond == nil {
|
|
||||||
autoCond = autoCond1
|
|
||||||
} else {
|
|
||||||
autoCond = autoCond.And(autoCond1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
st := session.statement
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cond = session.statement.Conds().And(autoCond)
|
cond = session.statement.Conds().And(autoCond)
|
||||||
doIncVer = isStruct && (table != nil && table.Version != "" && session.statement.CheckVersion)
|
doIncVer = isStruct && (table != nil && table.Version != "" && session.statement.CheckVersion)
|
||||||
verValue *reflect.Value
|
verValue *reflect.Value
|
||||||
)
|
)
|
||||||
if doIncVer {
|
if doIncVer {
|
||||||
verValue, err = table.VersionColumn().ValueOf(bean)
|
verValue, err = table.VersionColumn().ValueOfV(&v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if verValue != nil {
|
if verValue != nil {
|
||||||
cond = cond.And(builder.Eq{session.engine.Quote(table.Version): verValue.Interface()})
|
cond = cond.And(builder.Eq{session.engine.Quote(table.Version): verValue.Interface()})
|
||||||
colNames = append(colNames, session.engine.Quote(table.Version)+" = "+session.engine.Quote(table.Version)+" + 1")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(colNames) == 0 {
|
|
||||||
return 0, ErrNoColumnsTobeUpdated
|
|
||||||
}
|
|
||||||
|
|
||||||
whereWriter := builder.NewWriter()
|
|
||||||
if cond.IsValid() {
|
|
||||||
fmt.Fprint(whereWriter, "WHERE ")
|
|
||||||
}
|
|
||||||
if err := cond.WriteTo(st.QuoteReplacer(whereWriter)); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
if err := st.WriteOrderBy(whereWriter); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
|
|
||||||
tableName := session.statement.TableName()
|
|
||||||
// TODO: Oracle support needed
|
|
||||||
var top string
|
|
||||||
if st.LimitN != nil {
|
|
||||||
limitValue := *st.LimitN
|
|
||||||
switch session.engine.dialect.URI().DBType {
|
|
||||||
case schemas.MYSQL:
|
|
||||||
fmt.Fprintf(whereWriter, " LIMIT %d", limitValue)
|
|
||||||
case schemas.SQLITE:
|
|
||||||
fmt.Fprintf(whereWriter, " LIMIT %d", limitValue)
|
|
||||||
|
|
||||||
cond = cond.And(builder.Expr(fmt.Sprintf("rowid IN (SELECT rowid FROM %v %v)",
|
|
||||||
session.engine.Quote(tableName), whereWriter.String()), whereWriter.Args()...))
|
|
||||||
|
|
||||||
whereWriter = builder.NewWriter()
|
|
||||||
fmt.Fprint(whereWriter, "WHERE ")
|
|
||||||
if err := cond.WriteTo(st.QuoteReplacer(whereWriter)); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
case schemas.POSTGRES:
|
|
||||||
fmt.Fprintf(whereWriter, " LIMIT %d", limitValue)
|
|
||||||
|
|
||||||
cond = cond.And(builder.Expr(fmt.Sprintf("CTID IN (SELECT CTID FROM %v %v)",
|
|
||||||
session.engine.Quote(tableName), whereWriter.String()), whereWriter.Args()...))
|
|
||||||
|
|
||||||
whereWriter = builder.NewWriter()
|
|
||||||
fmt.Fprint(whereWriter, "WHERE ")
|
|
||||||
if err := cond.WriteTo(st.QuoteReplacer(whereWriter)); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
case schemas.MSSQL:
|
|
||||||
if st.HasOrderBy() && table != nil && len(table.PrimaryKeys) == 1 {
|
|
||||||
cond = builder.Expr(fmt.Sprintf("%s IN (SELECT TOP (%d) %s FROM %v%v)",
|
|
||||||
table.PrimaryKeys[0], limitValue, table.PrimaryKeys[0],
|
|
||||||
session.engine.Quote(tableName), whereWriter.String()), whereWriter.Args()...)
|
|
||||||
|
|
||||||
whereWriter = builder.NewWriter()
|
|
||||||
fmt.Fprint(whereWriter, "WHERE ")
|
|
||||||
if err := cond.WriteTo(whereWriter); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
top = fmt.Sprintf("TOP (%d) ", limitValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tableAlias := session.engine.Quote(tableName)
|
|
||||||
var fromSQL string
|
|
||||||
if session.statement.TableAlias != "" {
|
|
||||||
switch session.engine.dialect.URI().DBType {
|
|
||||||
case schemas.MSSQL:
|
|
||||||
fromSQL = fmt.Sprintf("FROM %s %s ", tableAlias, session.statement.TableAlias)
|
|
||||||
tableAlias = session.statement.TableAlias
|
|
||||||
default:
|
|
||||||
tableAlias = fmt.Sprintf("%s AS %s", tableAlias, session.statement.TableAlias)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateWriter := builder.NewWriter()
|
updateWriter := builder.NewWriter()
|
||||||
if _, err := fmt.Fprintf(updateWriter, "UPDATE %v%v SET %v %v",
|
if err := session.statement.WriteUpdate(updateWriter, cond, v, colNames, args); err != nil {
|
||||||
top,
|
|
||||||
tableAlias,
|
|
||||||
strings.Join(colNames, ", "),
|
|
||||||
fromSQL); err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
if err := utils.WriteBuilder(updateWriter, whereWriter); err != nil {
|
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
res, err := session.exec(updateWriter.String(), append(args, updateWriter.Args()...)...)
|
tableName := session.statement.TableName() // table name must been get before exec because statement will be reset
|
||||||
|
useCache := session.statement.UseCache
|
||||||
|
|
||||||
|
res, err := session.exec(updateWriter.String(), updateWriter.Args()...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
} else if doIncVer {
|
} else if doIncVer {
|
||||||
@ -435,8 +202,7 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if cacher := session.engine.GetCacher(tableName); cacher != nil && session.statement.UseCache {
|
if cacher := session.engine.GetCacher(tableName); cacher != nil && useCache {
|
||||||
// session.cacheUpdate(table, tableName, sqlStr, args...)
|
|
||||||
session.engine.logger.Debugf("[cache] clear table: %v", tableName)
|
session.engine.logger.Debugf("[cache] clear table: %v", tableName)
|
||||||
cacher.ClearIds(tableName)
|
cacher.ClearIds(tableName)
|
||||||
cacher.ClearBeans(tableName)
|
cacher.ClearBeans(tableName)
|
||||||
|
298
vendor/xorm.io/xorm/sync.go
generated
vendored
Normal file
298
vendor/xorm.io/xorm/sync.go
generated
vendored
Normal file
@ -0,0 +1,298 @@
|
|||||||
|
// Copyright 2023 The Xorm Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package xorm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"xorm.io/xorm/internal/utils"
|
||||||
|
"xorm.io/xorm/schemas"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SyncOptions struct {
|
||||||
|
WarnIfDatabaseColumnMissed bool
|
||||||
|
// IgnoreConstrains will not add, delete or update unique constrains
|
||||||
|
IgnoreConstrains bool
|
||||||
|
// IgnoreIndices will not add or delete indices
|
||||||
|
IgnoreIndices bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type SyncResult struct{}
|
||||||
|
|
||||||
|
// Sync the new struct changes to database, this method will automatically add
|
||||||
|
// table, column, index, unique. but will not delete or change anything.
|
||||||
|
// If you change some field, you should change the database manually.
|
||||||
|
func (engine *Engine) Sync(beans ...interface{}) error {
|
||||||
|
session := engine.NewSession()
|
||||||
|
defer session.Close()
|
||||||
|
return session.Sync(beans...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SyncWithOptions sync the database schemas according options and table structs
|
||||||
|
func (engine *Engine) SyncWithOptions(opts SyncOptions, beans ...interface{}) (*SyncResult, error) {
|
||||||
|
session := engine.NewSession()
|
||||||
|
defer session.Close()
|
||||||
|
return session.SyncWithOptions(opts, beans...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync2 synchronize structs to database tables
|
||||||
|
// Depricated
|
||||||
|
func (engine *Engine) Sync2(beans ...interface{}) error {
|
||||||
|
return engine.Sync(beans...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync2 synchronize structs to database tables
|
||||||
|
// Depricated
|
||||||
|
func (session *Session) Sync2(beans ...interface{}) error {
|
||||||
|
return session.Sync(beans...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sync synchronize structs to database tables
|
||||||
|
func (session *Session) Sync(beans ...interface{}) error {
|
||||||
|
_, err := session.SyncWithOptions(SyncOptions{
|
||||||
|
WarnIfDatabaseColumnMissed: false,
|
||||||
|
IgnoreConstrains: false,
|
||||||
|
IgnoreIndices: false,
|
||||||
|
}, beans...)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (session *Session) SyncWithOptions(opts SyncOptions, beans ...interface{}) (*SyncResult, error) {
|
||||||
|
engine := session.engine
|
||||||
|
|
||||||
|
if session.isAutoClose {
|
||||||
|
session.isAutoClose = false
|
||||||
|
defer session.Close()
|
||||||
|
}
|
||||||
|
|
||||||
|
tables, err := engine.dialect.GetTables(session.getQueryer(), session.ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
session.autoResetStatement = false
|
||||||
|
defer func() {
|
||||||
|
session.autoResetStatement = true
|
||||||
|
session.resetStatement()
|
||||||
|
}()
|
||||||
|
|
||||||
|
var syncResult SyncResult
|
||||||
|
|
||||||
|
for _, bean := range beans {
|
||||||
|
v := utils.ReflectValue(bean)
|
||||||
|
table, err := engine.tagParser.ParseWithCache(v)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var tbName string
|
||||||
|
if len(session.statement.AltTableName) > 0 {
|
||||||
|
tbName = session.statement.AltTableName
|
||||||
|
} else {
|
||||||
|
tbName = engine.TableName(bean)
|
||||||
|
}
|
||||||
|
tbNameWithSchema := engine.tbNameWithSchema(tbName)
|
||||||
|
|
||||||
|
var oriTable *schemas.Table
|
||||||
|
for _, tb := range tables {
|
||||||
|
if strings.EqualFold(engine.tbNameWithSchema(tb.Name), engine.tbNameWithSchema(tbName)) {
|
||||||
|
oriTable = tb
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is a new table
|
||||||
|
if oriTable == nil {
|
||||||
|
err = session.StoreEngine(session.statement.StoreEngine).createTable(bean)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !opts.IgnoreConstrains {
|
||||||
|
err = session.createUniques(bean)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !opts.IgnoreIndices {
|
||||||
|
err = session.createIndexes(bean)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// this will modify an old table
|
||||||
|
if err = engine.loadTableInfo(session.ctx, oriTable); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// check columns
|
||||||
|
for _, col := range table.Columns() {
|
||||||
|
var oriCol *schemas.Column
|
||||||
|
for _, col2 := range oriTable.Columns() {
|
||||||
|
if strings.EqualFold(col.Name, col2.Name) {
|
||||||
|
oriCol = col2
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// column is not exist on table
|
||||||
|
if oriCol == nil {
|
||||||
|
session.statement.RefTable = table
|
||||||
|
session.statement.SetTableName(tbNameWithSchema)
|
||||||
|
if err = session.addColumn(col.Name); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
err = nil
|
||||||
|
expectedType := engine.dialect.SQLType(col)
|
||||||
|
curType := engine.dialect.SQLType(oriCol)
|
||||||
|
if expectedType != curType {
|
||||||
|
if expectedType == schemas.Text &&
|
||||||
|
strings.HasPrefix(curType, schemas.Varchar) {
|
||||||
|
// currently only support mysql & postgres
|
||||||
|
if engine.dialect.URI().DBType == schemas.MYSQL ||
|
||||||
|
engine.dialect.URI().DBType == schemas.POSTGRES {
|
||||||
|
engine.logger.Infof("Table %s column %s change type from %s to %s\n",
|
||||||
|
tbNameWithSchema, col.Name, curType, expectedType)
|
||||||
|
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
||||||
|
} else {
|
||||||
|
engine.logger.Warnf("Table %s column %s db type is %s, struct type is %s\n",
|
||||||
|
tbNameWithSchema, col.Name, curType, expectedType)
|
||||||
|
}
|
||||||
|
} else if strings.HasPrefix(curType, schemas.Varchar) && strings.HasPrefix(expectedType, schemas.Varchar) {
|
||||||
|
if engine.dialect.URI().DBType == schemas.MYSQL {
|
||||||
|
if oriCol.Length < col.Length {
|
||||||
|
engine.logger.Infof("Table %s column %s change type from varchar(%d) to varchar(%d)\n",
|
||||||
|
tbNameWithSchema, col.Name, oriCol.Length, col.Length)
|
||||||
|
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if !(strings.HasPrefix(curType, expectedType) && curType[len(expectedType)] == '(') {
|
||||||
|
if !strings.EqualFold(schemas.SQLTypeName(curType), engine.dialect.Alias(schemas.SQLTypeName(expectedType))) {
|
||||||
|
engine.logger.Warnf("Table %s column %s db type is %s, struct type is %s",
|
||||||
|
tbNameWithSchema, col.Name, curType, expectedType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if expectedType == schemas.Varchar {
|
||||||
|
if engine.dialect.URI().DBType == schemas.MYSQL {
|
||||||
|
if oriCol.Length < col.Length {
|
||||||
|
engine.logger.Infof("Table %s column %s change type from varchar(%d) to varchar(%d)\n",
|
||||||
|
tbNameWithSchema, col.Name, oriCol.Length, col.Length)
|
||||||
|
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if col.Comment != oriCol.Comment {
|
||||||
|
if engine.dialect.URI().DBType == schemas.POSTGRES ||
|
||||||
|
engine.dialect.URI().DBType == schemas.MYSQL {
|
||||||
|
_, err = session.exec(engine.dialect.ModifyColumnSQL(tbNameWithSchema, col))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if col.Default != oriCol.Default {
|
||||||
|
switch {
|
||||||
|
case col.IsAutoIncrement: // For autoincrement column, don't check default
|
||||||
|
case (col.SQLType.Name == schemas.Bool || col.SQLType.Name == schemas.Boolean) &&
|
||||||
|
((strings.EqualFold(col.Default, "true") && oriCol.Default == "1") ||
|
||||||
|
(strings.EqualFold(col.Default, "false") && oriCol.Default == "0")):
|
||||||
|
default:
|
||||||
|
engine.logger.Warnf("Table %s Column %s db default is %s, struct default is %s",
|
||||||
|
tbName, col.Name, oriCol.Default, col.Default)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if col.Nullable != oriCol.Nullable {
|
||||||
|
engine.logger.Warnf("Table %s Column %s db nullable is %v, struct nullable is %v",
|
||||||
|
tbName, col.Name, oriCol.Nullable, col.Nullable)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// indices found in orig table
|
||||||
|
foundIndexNames := make(map[string]bool)
|
||||||
|
// indices to be added
|
||||||
|
addedNames := make(map[string]*schemas.Index)
|
||||||
|
|
||||||
|
// drop indices that exist in orig and new table schema but are not equal
|
||||||
|
for name, index := range table.Indexes {
|
||||||
|
var oriIndex *schemas.Index
|
||||||
|
for name2, index2 := range oriTable.Indexes {
|
||||||
|
if index.Equal(index2) {
|
||||||
|
oriIndex = index2
|
||||||
|
foundIndexNames[name2] = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if oriIndex != nil && oriIndex.Type != index.Type {
|
||||||
|
sql := engine.dialect.DropIndexSQL(tbNameWithSchema, oriIndex)
|
||||||
|
_, err = session.exec(sql)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
oriIndex = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if oriIndex == nil {
|
||||||
|
addedNames[name] = index
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// drop all indices that do not exist in new schema or have changed
|
||||||
|
for name2, index2 := range oriTable.Indexes {
|
||||||
|
if _, ok := foundIndexNames[name2]; !ok {
|
||||||
|
// ignore based on there type
|
||||||
|
if (index2.Type == schemas.IndexType && opts.IgnoreIndices) ||
|
||||||
|
(index2.Type == schemas.UniqueType && opts.IgnoreConstrains) {
|
||||||
|
// make sure we do not add a index with same name later
|
||||||
|
delete(addedNames, name2)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
sql := engine.dialect.DropIndexSQL(tbNameWithSchema, index2)
|
||||||
|
_, err = session.exec(sql)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new indices because either they did not exist before or were dropped to update them
|
||||||
|
for name, index := range addedNames {
|
||||||
|
if index.Type == schemas.UniqueType && !opts.IgnoreConstrains {
|
||||||
|
session.statement.RefTable = table
|
||||||
|
session.statement.SetTableName(tbNameWithSchema)
|
||||||
|
err = session.addUnique(tbNameWithSchema, name)
|
||||||
|
} else if index.Type == schemas.IndexType && !opts.IgnoreIndices {
|
||||||
|
session.statement.RefTable = table
|
||||||
|
session.statement.SetTableName(tbNameWithSchema)
|
||||||
|
err = session.addIndex(tbNameWithSchema, name)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if opts.WarnIfDatabaseColumnMissed {
|
||||||
|
// check all the columns which removed from struct fields but left on database tables.
|
||||||
|
for _, colName := range oriTable.ColumnsSeq() {
|
||||||
|
if table.GetColumn(colName) == nil {
|
||||||
|
engine.logger.Warnf("Table %s has column %s but struct has not related field", engine.TableName(oriTable.Name, true), colName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &syncResult, nil
|
||||||
|
}
|
41
vendor/xorm.io/xorm/tags/parser.go
generated
vendored
41
vendor/xorm.io/xorm/tags/parser.go
generated
vendored
@ -31,6 +31,12 @@ type TableIndices interface {
|
|||||||
|
|
||||||
var tpTableIndices = reflect.TypeOf((*TableIndices)(nil)).Elem()
|
var tpTableIndices = reflect.TypeOf((*TableIndices)(nil)).Elem()
|
||||||
|
|
||||||
|
type TableCollations interface {
|
||||||
|
TableCollations() []*schemas.Collation
|
||||||
|
}
|
||||||
|
|
||||||
|
var tpTableCollations = reflect.TypeOf((*TableCollations)(nil)).Elem()
|
||||||
|
|
||||||
// Parser represents a parser for xorm tag
|
// Parser represents a parser for xorm tag
|
||||||
type Parser struct {
|
type Parser struct {
|
||||||
identifier string
|
identifier string
|
||||||
@ -356,6 +362,22 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
collations := tableCollations(v)
|
||||||
|
for _, collation := range collations {
|
||||||
|
if collation.Name == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if collation.Column == "" {
|
||||||
|
table.Collation = collation.Name
|
||||||
|
} else {
|
||||||
|
col := table.GetColumn(collation.Column)
|
||||||
|
if col == nil {
|
||||||
|
return nil, ErrUnsupportedType
|
||||||
|
}
|
||||||
|
col.Collation = collation.Name // this may override definition in struct tag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return table, nil
|
return table, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,3 +399,22 @@ func tableIndices(v reflect.Value) []*schemas.Index {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tableCollations(v reflect.Value) []*schemas.Collation {
|
||||||
|
if v.Type().Implements(tpTableCollations) {
|
||||||
|
return v.Interface().(TableCollations).TableCollations()
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.Kind() == reflect.Ptr {
|
||||||
|
v = v.Elem()
|
||||||
|
if v.Type().Implements(tpTableCollations) {
|
||||||
|
return v.Interface().(TableCollations).TableCollations()
|
||||||
|
}
|
||||||
|
} else if v.CanAddr() {
|
||||||
|
v1 := v.Addr()
|
||||||
|
if v1.Type().Implements(tpTableCollations) {
|
||||||
|
return v1.Interface().(TableCollations).TableCollations()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
13
vendor/xorm.io/xorm/tags/tag.go
generated
vendored
13
vendor/xorm.io/xorm/tags/tag.go
generated
vendored
@ -123,6 +123,7 @@ var defaultTagHandlers = map[string]Handler{
|
|||||||
"COMMENT": CommentTagHandler,
|
"COMMENT": CommentTagHandler,
|
||||||
"EXTENDS": ExtendsTagHandler,
|
"EXTENDS": ExtendsTagHandler,
|
||||||
"UNSIGNED": UnsignedTagHandler,
|
"UNSIGNED": UnsignedTagHandler,
|
||||||
|
"COLLATE": CollateTagHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -282,10 +283,20 @@ func CommentTagHandler(ctx *Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CollateTagHandler(ctx *Context) error {
|
||||||
|
if len(ctx.params) > 0 {
|
||||||
|
ctx.col.Collation = ctx.params[0]
|
||||||
|
} else {
|
||||||
|
ctx.col.Collation = ctx.nextTag
|
||||||
|
ctx.ignoreNext = true
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// SQLTypeTagHandler describes SQL Type tag handler
|
// SQLTypeTagHandler describes SQL Type tag handler
|
||||||
func SQLTypeTagHandler(ctx *Context) error {
|
func SQLTypeTagHandler(ctx *Context) error {
|
||||||
ctx.col.SQLType = schemas.SQLType{Name: ctx.tagUname}
|
ctx.col.SQLType = schemas.SQLType{Name: ctx.tagUname}
|
||||||
if ctx.tagUname == "JSON" {
|
if ctx.tagUname == "JSON" || ctx.tagUname == "JSONB" {
|
||||||
ctx.col.IsJSON = true
|
ctx.col.IsJSON = true
|
||||||
}
|
}
|
||||||
if len(ctx.params) == 0 {
|
if len(ctx.params) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user