Browse Source

Upgrade xorm to v1.1.0

main
Lunny Xiao 4 years ago
parent
commit
95f6e51a4f
No known key found for this signature in database GPG Key ID: C3B7C91B632F738A
  1. 9
      go.mod
  2. 54
      go.sum
  3. 37
      vendor/github.com/denisenkom/go-mssqldb/appveyor.yml
  4. 2
      vendor/github.com/denisenkom/go-mssqldb/mssql.go
  5. 6
      vendor/github.com/denisenkom/go-mssqldb/tds.go
  6. 12
      vendor/github.com/denisenkom/go-mssqldb/token.go
  7. 4
      vendor/github.com/mattn/go-sqlite3/.codecov.yml
  8. 35
      vendor/github.com/mattn/go-sqlite3/.travis.yml
  9. 12
      vendor/github.com/mattn/go-sqlite3/README.md
  10. 50
      vendor/github.com/mattn/go-sqlite3/callback.go
  11. 35
      vendor/github.com/mattn/go-sqlite3/doc.go
  12. 7
      vendor/github.com/mattn/go-sqlite3/go.mod
  13. 13
      vendor/github.com/mattn/go-sqlite3/go.sum
  14. 22072
      vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c
  15. 1451
      vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h
  16. 76
      vendor/github.com/mattn/go-sqlite3/sqlite3.go
  17. 1
      vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go
  18. 2
      vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go
  19. 115
      vendor/github.com/mattn/go-sqlite3/sqlite3_opt_vtable.go
  20. 4
      vendor/github.com/mattn/go-sqlite3/sqlite3_type.go
  21. 4
      vendor/github.com/mattn/go-sqlite3/sqlite3_usleep_windows.go
  22. 4
      vendor/github.com/mattn/go-sqlite3/sqlite3ext.h
  23. 10
      vendor/modules.txt
  24. 2
      vendor/xorm.io/builder/cond_in.go
  25. 2
      vendor/xorm.io/builder/cond_notin.go
  26. 3
      vendor/xorm.io/builder/sql.go
  27. 756
      vendor/xorm.io/xorm/.drone.yml
  28. 1
      vendor/xorm.io/xorm/.gitignore
  29. 4
      vendor/xorm.io/xorm/.revive.toml
  30. 36
      vendor/xorm.io/xorm/CHANGELOG.md
  31. 31
      vendor/xorm.io/xorm/Makefile
  32. 9
      vendor/xorm.io/xorm/caches/encode.go
  33. 5
      vendor/xorm.io/xorm/caches/leveldb.go
  34. 4
      vendor/xorm.io/xorm/caches/manager.go
  35. 6
      vendor/xorm.io/xorm/contexts/hook.go
  36. 15
      vendor/xorm.io/xorm/core/db.go
  37. 20
      vendor/xorm.io/xorm/core/rows.go
  38. 4
      vendor/xorm.io/xorm/core/scan.go
  39. 19
      vendor/xorm.io/xorm/core/stmt.go
  40. 35
      vendor/xorm.io/xorm/core/tx.go
  41. 38
      vendor/xorm.io/xorm/dialects/dialect.go
  42. 8
      vendor/xorm.io/xorm/dialects/driver.go
  43. 1
      vendor/xorm.io/xorm/dialects/filter.go
  44. 13
      vendor/xorm.io/xorm/dialects/mssql.go
  45. 31
      vendor/xorm.io/xorm/dialects/mysql.go
  46. 13
      vendor/xorm.io/xorm/dialects/postgres.go
  47. 5
      vendor/xorm.io/xorm/dialects/sqlite3.go
  48. 7
      vendor/xorm.io/xorm/dialects/time.go
  49. 182
      vendor/xorm.io/xorm/engine.go
  50. 11
      vendor/xorm.io/xorm/engine_group.go
  51. 9
      vendor/xorm.io/xorm/go.mod
  52. 94
      vendor/xorm.io/xorm/go.sum
  53. 1
      vendor/xorm.io/xorm/interface.go
  54. 6
      vendor/xorm.io/xorm/internal/json/json.go
  55. 2
      vendor/xorm.io/xorm/internal/statements/cache.go
  56. 1
      vendor/xorm.io/xorm/internal/statements/expr_param.go
  57. 5
      vendor/xorm.io/xorm/internal/statements/query.go
  58. 39
      vendor/xorm.io/xorm/internal/statements/statement.go
  59. 2
      vendor/xorm.io/xorm/internal/statements/statement_args.go
  60. 2
      vendor/xorm.io/xorm/internal/statements/update.go
  61. 2
      vendor/xorm.io/xorm/internal/statements/values.go
  62. 1
      vendor/xorm.io/xorm/internal/utils/name.go
  63. 1
      vendor/xorm.io/xorm/internal/utils/reflect.go
  64. 1
      vendor/xorm.io/xorm/internal/utils/sql.go
  65. 3
      vendor/xorm.io/xorm/internal/utils/strings.go
  66. 40
      vendor/xorm.io/xorm/internal/utils/zero.go
  67. 18
      vendor/xorm.io/xorm/names/mapper.go
  68. 1
      vendor/xorm.io/xorm/names/table_name.go
  69. 2
      vendor/xorm.io/xorm/schemas/column.go
  70. 6
      vendor/xorm.io/xorm/schemas/index.go
  71. 5
      vendor/xorm.io/xorm/schemas/pk.go
  72. 8
      vendor/xorm.io/xorm/schemas/quote.go
  73. 12
      vendor/xorm.io/xorm/schemas/table.go
  74. 149
      vendor/xorm.io/xorm/schemas/type.go
  75. 7
      vendor/xorm.io/xorm/session.go
  76. 3
      vendor/xorm.io/xorm/session_find.go
  77. 7
      vendor/xorm.io/xorm/session_get.go
  78. 36
      vendor/xorm.io/xorm/session_schema.go
  79. 5
      vendor/xorm.io/xorm/session_tx.go
  80. 9
      vendor/xorm.io/xorm/session_update.go
  81. 18
      vendor/xorm.io/xorm/tags/parser.go
  82. 3
      vendor/xorm.io/xorm/tags/tag.go

9
go.mod

@ -4,17 +4,16 @@ go 1.13
require ( require (
gitea.com/lunny/log v0.0.0-20190322053110-01b5df579c4e gitea.com/lunny/log v0.0.0-20190322053110-01b5df579c4e
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc
github.com/PuerkitoBio/goquery v1.5.1 // indirect
github.com/denisenkom/go-mssqldb v0.9.0
github.com/go-sql-driver/mysql v1.5.0 github.com/go-sql-driver/mysql v1.5.0
github.com/gobwas/glob v0.2.3 github.com/gobwas/glob v0.2.3
github.com/kr/pretty v0.2.1 // indirect github.com/kr/pretty v0.2.1 // indirect
github.com/lib/pq v1.7.0 github.com/lib/pq v1.7.0
github.com/mattn/go-sqlite3 v1.14.0
github.com/mattn/go-sqlite3 v1.14.6
github.com/spf13/cobra v0.0.5 github.com/spf13/cobra v0.0.5
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 // indirect
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 v2.2.2
xorm.io/xorm v1.0.5
xorm.io/xorm v1.1.0
) )

54
go.sum

@ -15,6 +15,9 @@ 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.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzqk8QCaRC4os14xoKDdbHqqlJtJA0oc1ZAjg= github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzqk8QCaRC4os14xoKDdbHqqlJtJA0oc1ZAjg=
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk=
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
@ -27,11 +30,13 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
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/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@ -40,10 +45,12 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY= github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY=
github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/mattn/go-sqlite3 v1.10.0 h1:jbhqpg7tQe4SupckyijYiy0mJJ/pRyHvXf7JdWK860o=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA= github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@ -54,6 +61,7 @@ github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1Cpa
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
@ -72,29 +80,50 @@ github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFd
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ=
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
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=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2 h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@ -105,7 +134,26 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
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 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
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=
modernc.org/cc/v3 v3.31.5-0.20210308123301-7a3e9dab9009/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878=
modernc.org/ccgo/v3 v3.9.0/go.mod h1:nQbgkn8mwzPdp4mm6BT6+p85ugQ7FrGgIcYaE7nSrpY=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.8.0/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84/go.mod h1:PGzq6qlhyYjL6uVbSgS6WoF7ZopTW/sI7+7p+mb4ZVU=
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/tcl v1.5.0/go.mod h1:gb57hj4pO8fRrK54zveIfFXBaMHK3SKJNWcmRw1cRzc=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI= xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI=
xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE= xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
xorm.io/builder v0.3.8 h1:P/wPgRqa9kX5uE0aA1/ukJ23u9KH0aSRpHLwDKXigSE=
xorm.io/builder v0.3.8/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
xorm.io/xorm v1.0.5 h1:LRr5PfOUb4ODPR63YwbowkNDwcolT2LnkwP/TUaMaB0= xorm.io/xorm v1.0.5 h1:LRr5PfOUb4ODPR63YwbowkNDwcolT2LnkwP/TUaMaB0=
xorm.io/xorm v1.0.5/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4= xorm.io/xorm v1.0.5/go.mod h1:uF9EtbhODq5kNWxMbnBEj8hRRZnlcNSz2t2N7HW/+A4=
xorm.io/xorm v1.1.0 h1:mkEsQXLauZajiOld2cB2PkFcUZKePepPgs1bC1dw8RA=
xorm.io/xorm v1.1.0/go.mod h1:EDzNHMuCVZNszkIRSLL2nI0zX+nQE8RstAVranlSfqI=

37
vendor/github.com/denisenkom/go-mssqldb/appveyor.yml

@ -1,6 +1,7 @@
version: 1.0.{build} version: 1.0.{build}
os: Windows Server 2012 R2
image:
- Visual Studio 2015
clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb
@ -9,21 +10,36 @@ environment:
HOST: localhost HOST: localhost
SQLUSER: sa SQLUSER: sa
SQLPASSWORD: Password12! SQLPASSWORD: Password12!
DATABASE: test
GOVERSION: 111
DATABASE: test
GOVERSION: 113
matrix: matrix:
- GOVERSION: 18 - GOVERSION: 18
SQLINSTANCE: SQL2016
SQLINSTANCE: SQL2017
- GOVERSION: 19 - GOVERSION: 19
SQLINSTANCE: SQL2016
SQLINSTANCE: SQL2017
- GOVERSION: 110 - GOVERSION: 110
SQLINSTANCE: SQL2016
SQLINSTANCE: SQL2017
- GOVERSION: 111 - GOVERSION: 111
SQLINSTANCE: SQL2016
SQLINSTANCE: SQL2017
- GOVERSION: 112
SQLINSTANCE: SQL2017
- SQLINSTANCE: SQL2017
- SQLINSTANCE: SQL2016
- SQLINSTANCE: SQL2014 - SQLINSTANCE: SQL2014
- SQLINSTANCE: SQL2012SP1 - SQLINSTANCE: SQL2012SP1
- SQLINSTANCE: SQL2008R2SP2 - SQLINSTANCE: SQL2008R2SP2
# Go 1.14+ and SQL2019 are available on the Visual Studio 2019 image only
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GOVERSION: 114
SQLINSTANCE: SQL2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GOVERSION: 115
SQLINSTANCE: SQL2019
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
GOVERSION: 115
SQLINSTANCE: SQL2017
install: install:
- set GOROOT=c:\go%GOVERSION% - set GOROOT=c:\go%GOVERSION%
- set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH% - set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH%
@ -35,15 +51,14 @@ build_script:
- go build - go build
before_test: before_test:
# setup SQL Server
- ps: |
# setup SQL Server
- ps: |
$instanceName = $env:SQLINSTANCE $instanceName = $env:SQLINSTANCE
Start-Service "MSSQL`$$instanceName" Start-Service "MSSQL`$$instanceName"
Start-Service "SQLBrowser" Start-Service "SQLBrowser"
- sqlcmd -S "(local)\%SQLINSTANCE%" -Q "Use [master]; CREATE DATABASE test;" - sqlcmd -S "(local)\%SQLINSTANCE%" -Q "Use [master]; CREATE DATABASE test;"
- sqlcmd -S "(local)\%SQLINSTANCE%" -h -1 -Q "set nocount on; Select @@version" - sqlcmd -S "(local)\%SQLINSTANCE%" -h -1 -Q "set nocount on; Select @@version"
- pip install codecov - pip install codecov
test_script: test_script:
- go test -race -cpu 4 -coverprofile=coverage.txt -covermode=atomic - go test -race -cpu 4 -coverprofile=coverage.txt -covermode=atomic

2
vendor/github.com/denisenkom/go-mssqldb/mssql.go

@ -285,7 +285,7 @@ func (c *Conn) begin(ctx context.Context, tdsIsolation isoLevel) (tx driver.Tx,
} }
tx, err = c.processBeginResponse(ctx) tx, err = c.processBeginResponse(ctx)
if err != nil { if err != nil {
return nil, c.checkBadConn(err)
return nil, err
} }
return return
} }

6
vendor/github.com/denisenkom/go-mssqldb/tds.go

@ -838,6 +838,12 @@ func connect(ctx context.Context, c *Connector, log optionalLogger, p connectPar
defer cancel() defer cancel()
} }
// if instance is specified use instance resolution service // if instance is specified use instance resolution service
if p.instance != "" && p.port != 0 {
// both instance name and port specified
// when port is specified instance name is not used
// you should not provide instance name when you provide port
log.Println("WARN: You specified both instance name and port in the connection string, port will be used and instance name will be ignored");
}
if p.instance != "" && p.port == 0 { if p.instance != "" && p.port == 0 {
p.instance = strings.ToUpper(p.instance) p.instance = strings.ToUpper(p.instance)
d := c.getDialer(&p) d := c.getDialer(&p)

12
vendor/github.com/denisenkom/go-mssqldb/token.go

@ -704,14 +704,18 @@ func (ts *parseResp) sendAttention(ch chan tokenStruct) parseRespIter {
} }
func (ts *parseResp) dlog(msg string) { func (ts *parseResp) dlog(msg string) {
if ts.sess.logFlags&logDebug != 0 {
// logging from goroutine is disabled to prevent
// data race detection from firing
// The race is probably happening when
// test logger changes between tests.
/*if ts.sess.logFlags&logDebug != 0 {
ts.sess.log.Println(msg) ts.sess.log.Println(msg)
}
}*/
} }
func (ts *parseResp) dlogf(f string, v ...interface{}) { func (ts *parseResp) dlogf(f string, v ...interface{}) {
if ts.sess.logFlags&logDebug != 0 {
/*if ts.sess.logFlags&logDebug != 0 {
ts.sess.log.Printf(f, v...) ts.sess.log.Printf(f, v...)
}
}*/
} }
func (ts *parseResp) iter(ctx context.Context, ch chan tokenStruct, tokChan chan tokenStruct) parseRespIter { func (ts *parseResp) iter(ctx context.Context, ch chan tokenStruct, tokChan chan tokenStruct) parseRespIter {

4
vendor/github.com/mattn/go-sqlite3/.codecov.yml

@ -0,0 +1,4 @@
coverage:
status:
project: off
patch: off

35
vendor/github.com/mattn/go-sqlite3/.travis.yml

@ -1,35 +0,0 @@
language: go
os:
- linux
- osx
addons:
apt:
update: true
go:
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- master
before_install:
- |
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update
fi
- go get github.com/mattn/goveralls
- go get golang.org/x/tools/cmd/cover
script:
- $HOME/gopath/bin/goveralls -repotoken 3qJVUE0iQwqnCbmNcDsjYu1nh4J4KIFXx -parallel
- go test -race -v . -tags ""
- go test -race -v . -tags "libsqlite3"
- go test -race -v . -tags "sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_preupdate_hook sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable sqlite_unlock_notify"
- go test -race -v . -tags "sqlite_vacuum_full"
notifications:
webhooks: https://coveralls.io/webhook?repo_token=3qJVUE0iQwqnCbmNcDsjYu1nh4J4KIFXx

12
vendor/github.com/mattn/go-sqlite3/README.md

@ -2,18 +2,20 @@ go-sqlite3
========== ==========
[![GoDoc Reference](https://godoc.org/github.com/mattn/go-sqlite3?status.svg)](http://godoc.org/github.com/mattn/go-sqlite3) [![GoDoc Reference](https://godoc.org/github.com/mattn/go-sqlite3?status.svg)](http://godoc.org/github.com/mattn/go-sqlite3)
[![Build Status](https://travis-ci.org/mattn/go-sqlite3.svg?branch=master)](https://travis-ci.org/mattn/go-sqlite3)
[![GitHub Actions](https://github.com/mattn/go-sqlite3/workflows/Go/badge.svg)](https://github.com/mattn/go-sqlite3/actions?query=workflow%3AGo)
[![Financial Contributors on Open Collective](https://opencollective.com/mattn-go-sqlite3/all/badge.svg?label=financial+contributors)](https://opencollective.com/mattn-go-sqlite3) [![Financial Contributors on Open Collective](https://opencollective.com/mattn-go-sqlite3/all/badge.svg?label=financial+contributors)](https://opencollective.com/mattn-go-sqlite3)
[![Coverage Status](https://coveralls.io/repos/mattn/go-sqlite3/badge.svg?branch=master)](https://coveralls.io/r/mattn/go-sqlite3?branch=master)
[![codecov](https://codecov.io/gh/mattn/go-sqlite3/branch/master/graph/badge.svg)](https://codecov.io/gh/mattn/go-sqlite3)
[![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-sqlite3)](https://goreportcard.com/report/github.com/mattn/go-sqlite3) [![Go Report Card](https://goreportcard.com/badge/github.com/mattn/go-sqlite3)](https://goreportcard.com/report/github.com/mattn/go-sqlite3)
**NOTE:** The increase to v2 was an accident. There were no major changes or features.
Latest stable version is v1.14 or later not v2.
~~**NOTE:** The increase to v2 was an accident. There were no major changes or features.~~
# Description # Description
sqlite3 driver conforming to the built-in database/sql interface sqlite3 driver conforming to the built-in database/sql interface
Supported Golang version: See .travis.yml
Supported Golang version: See [.github/workflows/go.yaml](./.github/workflows/go.yaml)
[This package follows the official Golang Release Policy.](https://golang.org/doc/devel/release.html#policy) [This package follows the official Golang Release Policy.](https://golang.org/doc/devel/release.html#policy)
@ -123,6 +125,8 @@ Boolean values can be one of:
| Time Zone Location | `_loc` | auto | Specify location of time format. | | Time Zone Location | `_loc` | auto | Specify location of time format. |
| Transaction Lock | `_txlock` | <ul><li>immediate</li><li>deferred</li><li>exclusive</li></ul> | Specify locking behavior for transactions. | | Transaction Lock | `_txlock` | <ul><li>immediate</li><li>deferred</li><li>exclusive</li></ul> | Specify locking behavior for transactions. |
| Writable Schema | `_writable_schema` | `Boolean` | When this pragma is on, the SQLITE_MASTER tables in which database can be changed using ordinary UPDATE, INSERT, and DELETE statements. Warning: misuse of this pragma can easily result in a corrupt database file. | | Writable Schema | `_writable_schema` | `Boolean` | When this pragma is on, the SQLITE_MASTER tables in which database can be changed using ordinary UPDATE, INSERT, and DELETE statements. Warning: misuse of this pragma can easily result in a corrupt database file. |
| Cache Size | `_cache_size` | `int` | Maximum cache size; default is 2000K (2M). See [PRAGMA cache_size](https://sqlite.org/pragma.html#pragma_cache_size) |
## DSN Examples ## DSN Examples

50
vendor/github.com/mattn/go-sqlite3/callback.go

@ -35,56 +35,55 @@ import (
//export callbackTrampoline //export callbackTrampoline
func callbackTrampoline(ctx *C.sqlite3_context, argc int, argv **C.sqlite3_value) { func callbackTrampoline(ctx *C.sqlite3_context, argc int, argv **C.sqlite3_value) {
args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc] args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
fi := lookupHandle(uintptr(C.sqlite3_user_data(ctx))).(*functionInfo)
fi := lookupHandle(C.sqlite3_user_data(ctx)).(*functionInfo)
fi.Call(ctx, args) fi.Call(ctx, args)
} }
//export stepTrampoline //export stepTrampoline
func stepTrampoline(ctx *C.sqlite3_context, argc C.int, argv **C.sqlite3_value) { func stepTrampoline(ctx *C.sqlite3_context, argc C.int, argv **C.sqlite3_value) {
args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:int(argc):int(argc)] args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:int(argc):int(argc)]
ai := lookupHandle(uintptr(C.sqlite3_user_data(ctx))).(*aggInfo)
ai := lookupHandle(C.sqlite3_user_data(ctx)).(*aggInfo)
ai.Step(ctx, args) ai.Step(ctx, args)
} }
//export doneTrampoline //export doneTrampoline
func doneTrampoline(ctx *C.sqlite3_context) { func doneTrampoline(ctx *C.sqlite3_context) {
handle := uintptr(C.sqlite3_user_data(ctx))
ai := lookupHandle(handle).(*aggInfo)
ai := lookupHandle(C.sqlite3_user_data(ctx)).(*aggInfo)
ai.Done(ctx) ai.Done(ctx)
} }
//export compareTrampoline //export compareTrampoline
func compareTrampoline(handlePtr uintptr, la C.int, a *C.char, lb C.int, b *C.char) C.int {
func compareTrampoline(handlePtr unsafe.Pointer, la C.int, a *C.char, lb C.int, b *C.char) C.int {
cmp := lookupHandle(handlePtr).(func(string, string) int) cmp := lookupHandle(handlePtr).(func(string, string) int)
return C.int(cmp(C.GoStringN(a, la), C.GoStringN(b, lb))) return C.int(cmp(C.GoStringN(a, la), C.GoStringN(b, lb)))
} }
//export commitHookTrampoline //export commitHookTrampoline
func commitHookTrampoline(handle uintptr) int {
func commitHookTrampoline(handle unsafe.Pointer) int {
callback := lookupHandle(handle).(func() int) callback := lookupHandle(handle).(func() int)
return callback() return callback()
} }
//export rollbackHookTrampoline //export rollbackHookTrampoline
func rollbackHookTrampoline(handle uintptr) {
func rollbackHookTrampoline(handle unsafe.Pointer) {
callback := lookupHandle(handle).(func()) callback := lookupHandle(handle).(func())
callback() callback()
} }
//export updateHookTrampoline //export updateHookTrampoline
func updateHookTrampoline(handle uintptr, op int, db *C.char, table *C.char, rowid int64) {
func updateHookTrampoline(handle unsafe.Pointer, op int, db *C.char, table *C.char, rowid int64) {
callback := lookupHandle(handle).(func(int, string, string, int64)) callback := lookupHandle(handle).(func(int, string, string, int64))
callback(op, C.GoString(db), C.GoString(table), rowid) callback(op, C.GoString(db), C.GoString(table), rowid)
} }
//export authorizerTrampoline //export authorizerTrampoline
func authorizerTrampoline(handle uintptr, op int, arg1 *C.char, arg2 *C.char, arg3 *C.char) int {
func authorizerTrampoline(handle unsafe.Pointer, op int, arg1 *C.char, arg2 *C.char, arg3 *C.char) int {
callback := lookupHandle(handle).(func(int, string, string, string) int) callback := lookupHandle(handle).(func(int, string, string, string) int)
return callback(op, C.GoString(arg1), C.GoString(arg2), C.GoString(arg3)) return callback(op, C.GoString(arg1), C.GoString(arg2), C.GoString(arg3))
} }
//export preUpdateHookTrampoline //export preUpdateHookTrampoline
func preUpdateHookTrampoline(handle uintptr, dbHandle uintptr, op int, db *C.char, table *C.char, oldrowid int64, newrowid int64) {
func preUpdateHookTrampoline(handle unsafe.Pointer, dbHandle uintptr, op int, db *C.char, table *C.char, oldrowid int64, newrowid int64) {
hval := lookupHandleVal(handle) hval := lookupHandleVal(handle)
data := SQLitePreUpdateData{ data := SQLitePreUpdateData{
Conn: hval.db, Conn: hval.db,
@ -105,33 +104,27 @@ type handleVal struct {
} }
var handleLock sync.Mutex var handleLock sync.Mutex
var handleVals = make(map[uintptr]handleVal)
var handleIndex uintptr = 100
var handleVals = make(map[unsafe.Pointer]handleVal)
func newHandle(db *SQLiteConn, v interface{}) uintptr {
func newHandle(db *SQLiteConn, v interface{}) unsafe.Pointer {
handleLock.Lock() handleLock.Lock()
defer handleLock.Unlock() defer handleLock.Unlock()
i := handleIndex
handleIndex++
handleVals[i] = handleVal{db, v}
return i
val := handleVal{db: db, val: v}
var p unsafe.Pointer = C.malloc(C.size_t(1))
if p == nil {
panic("can't allocate 'cgo-pointer hack index pointer': ptr == nil")
}
handleVals[p] = val
return p
} }
func lookupHandleVal(handle uintptr) handleVal {
func lookupHandleVal(handle unsafe.Pointer) handleVal {
handleLock.Lock() handleLock.Lock()
defer handleLock.Unlock() defer handleLock.Unlock()
r, ok := handleVals[handle]
if !ok {
if handle >= 100 && handle < handleIndex {
panic("deleted handle")
} else {
panic("invalid handle")
}
}
return r
return handleVals[handle]
} }
func lookupHandle(handle uintptr) interface{} {
func lookupHandle(handle unsafe.Pointer) interface{} {
return lookupHandleVal(handle).val return lookupHandleVal(handle).val
} }
@ -141,6 +134,7 @@ func deleteHandles(db *SQLiteConn) {
for handle, val := range handleVals { for handle, val := range handleVals {
if val.db == db { if val.db == db {
delete(handleVals, handle) delete(handleVals, handle)
C.free(handle)
} }
} }
} }

35
vendor/github.com/mattn/go-sqlite3/doc.go

@ -79,9 +79,8 @@ Then, you can use this extension.
Connection Hook Connection Hook
You can hook and inject your code when the connection is established. database/sql
doesn't provide a way to get native go-sqlite3 interfaces. So if you want,
you need to set ConnectHook and get the SQLiteConn.
You can hook and inject your code when the connection is established by setting
ConnectHook to get the SQLiteConn.
sql.Register("sqlite3_with_hook_example", sql.Register("sqlite3_with_hook_example",
&sqlite3.SQLiteDriver{ &sqlite3.SQLiteDriver{
@ -91,21 +90,45 @@ you need to set ConnectHook and get the SQLiteConn.
}, },
}) })
You can also use database/sql.Conn.Raw (Go >= 1.13):
conn, err := db.Conn(context.Background())
// if err != nil { ... }
defer conn.Close()
err = conn.Raw(func (driverConn interface{}) error {
sqliteConn := driverConn.(*sqlite3.SQLiteConn)
// ... use sqliteConn
})
// if err != nil { ... }
Go SQlite3 Extensions Go SQlite3 Extensions
If you want to register Go functions as SQLite extension functions,
call RegisterFunction from ConnectHook.
If you want to register Go functions as SQLite extension functions
you can make a custom driver by calling RegisterFunction from
ConnectHook.
regex = func(re, s string) (bool, error) { regex = func(re, s string) (bool, error) {
return regexp.MatchString(re, s) return regexp.MatchString(re, s)
} }
sql.Register("sqlite3_with_go_func",
sql.Register("sqlite3_extended",
&sqlite3.SQLiteDriver{ &sqlite3.SQLiteDriver{
ConnectHook: func(conn *sqlite3.SQLiteConn) error { ConnectHook: func(conn *sqlite3.SQLiteConn) error {
return conn.RegisterFunc("regexp", regex, true) return conn.RegisterFunc("regexp", regex, true)
}, },
}) })
You can then use the custom driver by passing its name to sql.Open.
var i int
conn, err := sql.Open("sqlite3_extended", "./foo.db")
if err != nil {
panic(err)
}
err = db.QueryRow(`SELECT regexp("foo.*", "seafood")`).Scan(&i)
if err != nil {
panic(err)
}
See the documentation of RegisterFunc for more details. See the documentation of RegisterFunc for more details.
*/ */

7
vendor/github.com/mattn/go-sqlite3/go.mod

@ -1,8 +1,3 @@
module github.com/mattn/go-sqlite3 module github.com/mattn/go-sqlite3
go 1.10
require (
github.com/PuerkitoBio/goquery v1.5.1
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
)
go 1.12

13
vendor/github.com/mattn/go-sqlite3/go.sum

@ -1,13 +0,0 @@
github.com/PuerkitoBio/goquery v1.5.1 h1:PSPBGne8NIUWw+/7vFBV+kG2J/5MOjbzc7154OaKCSE=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/andybalholm/cascadia v1.1.0 h1:BuuO6sSfQNFRu1LppgbD25Hr2vLYW25JvxHs5zzsLTo=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

22072
vendor/github.com/mattn/go-sqlite3/sqlite3-binding.c
File diff suppressed because it is too large
View File

1451
vendor/github.com/mattn/go-sqlite3/sqlite3-binding.h
File diff suppressed because it is too large
View File

76
vendor/github.com/mattn/go-sqlite3/sqlite3.go

@ -15,10 +15,8 @@ package sqlite3
#cgo CFLAGS: -DHAVE_USLEEP=1 #cgo CFLAGS: -DHAVE_USLEEP=1
#cgo CFLAGS: -DSQLITE_ENABLE_FTS3 #cgo CFLAGS: -DSQLITE_ENABLE_FTS3
#cgo CFLAGS: -DSQLITE_ENABLE_FTS3_PARENTHESIS #cgo CFLAGS: -DSQLITE_ENABLE_FTS3_PARENTHESIS
#cgo CFLAGS: -DSQLITE_ENABLE_FTS4_UNICODE61
#cgo CFLAGS: -DSQLITE_TRACE_SIZE_LIMIT=15 #cgo CFLAGS: -DSQLITE_TRACE_SIZE_LIMIT=15
#cgo CFLAGS: -DSQLITE_OMIT_DEPRECATED #cgo CFLAGS: -DSQLITE_OMIT_DEPRECATED
#cgo CFLAGS: -DSQLITE_DISABLE_INTRINSIC
#cgo CFLAGS: -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 #cgo CFLAGS: -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1
#cgo CFLAGS: -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT #cgo CFLAGS: -DSQLITE_ENABLE_UPDATE_DELETE_LIMIT
#cgo CFLAGS: -Wno-deprecated-declarations #cgo CFLAGS: -Wno-deprecated-declarations
@ -473,7 +471,7 @@ func (c *SQLiteConn) RegisterCollation(name string, cmp func(string, string) int
handle := newHandle(c, cmp) handle := newHandle(c, cmp)
cname := C.CString(name) cname := C.CString(name)
defer C.free(unsafe.Pointer(cname)) defer C.free(unsafe.Pointer(cname))
rv := C.sqlite3_create_collation(c.db, cname, C.SQLITE_UTF8, unsafe.Pointer(handle), (*[0]byte)(unsafe.Pointer(C.compareTrampoline)))
rv := C.sqlite3_create_collation(c.db, cname, C.SQLITE_UTF8, handle, (*[0]byte)(unsafe.Pointer(C.compareTrampoline)))
if rv != C.SQLITE_OK { if rv != C.SQLITE_OK {
return c.lastError() return c.lastError()
} }
@ -491,7 +489,7 @@ func (c *SQLiteConn) RegisterCommitHook(callback func() int) {
if callback == nil { if callback == nil {
C.sqlite3_commit_hook(c.db, nil, nil) C.sqlite3_commit_hook(c.db, nil, nil)
} else { } else {
C.sqlite3_commit_hook(c.db, (*[0]byte)(C.commitHookTrampoline), unsafe.Pointer(newHandle(c, callback)))
C.sqlite3_commit_hook(c.db, (*[0]byte)(C.commitHookTrampoline), newHandle(c, callback))
} }
} }
@ -504,7 +502,7 @@ func (c *SQLiteConn) RegisterRollbackHook(callback func()) {
if callback == nil { if callback == nil {
C.sqlite3_rollback_hook(c.db, nil, nil) C.sqlite3_rollback_hook(c.db, nil, nil)
} else { } else {
C.sqlite3_rollback_hook(c.db, (*[0]byte)(C.rollbackHookTrampoline), unsafe.Pointer(newHandle(c, callback)))
C.sqlite3_rollback_hook(c.db, (*[0]byte)(C.rollbackHookTrampoline), newHandle(c, callback))
} }
} }
@ -521,7 +519,7 @@ func (c *SQLiteConn) RegisterUpdateHook(callback func(int, string, string, int64
if callback == nil { if callback == nil {
C.sqlite3_update_hook(c.db, nil, nil) C.sqlite3_update_hook(c.db, nil, nil)
} else { } else {
C.sqlite3_update_hook(c.db, (*[0]byte)(C.updateHookTrampoline), unsafe.Pointer(newHandle(c, callback)))
C.sqlite3_update_hook(c.db, (*[0]byte)(C.updateHookTrampoline), newHandle(c, callback))
} }
} }
@ -535,7 +533,7 @@ func (c *SQLiteConn) RegisterAuthorizer(callback func(int, string, string, strin
if callback == nil { if callback == nil {
C.sqlite3_set_authorizer(c.db, nil, nil) C.sqlite3_set_authorizer(c.db, nil, nil)
} else { } else {
C.sqlite3_set_authorizer(c.db, (*[0]byte)(C.authorizerTrampoline), unsafe.Pointer(newHandle(c, callback)))
C.sqlite3_set_authorizer(c.db, (*[0]byte)(C.authorizerTrampoline), newHandle(c, callback))
} }
} }
@ -616,8 +614,8 @@ func (c *SQLiteConn) RegisterFunc(name string, impl interface{}, pure bool) erro
return nil return nil
} }
func sqlite3CreateFunction(db *C.sqlite3, zFunctionName *C.char, nArg C.int, eTextRep C.int, pApp uintptr, xFunc unsafe.Pointer, xStep unsafe.Pointer, xFinal unsafe.Pointer) C.int {
return C._sqlite3_create_function(db, zFunctionName, nArg, eTextRep, C.uintptr_t(pApp), (*[0]byte)(xFunc), (*[0]byte)(xStep), (*[0]byte)(xFinal))
func sqlite3CreateFunction(db *C.sqlite3, zFunctionName *C.char, nArg C.int, eTextRep C.int, pApp unsafe.Pointer, xFunc unsafe.Pointer, xStep unsafe.Pointer, xFinal unsafe.Pointer) C.int {
return C._sqlite3_create_function(db, zFunctionName, nArg, eTextRep, C.uintptr_t(uintptr(pApp)), (*[0]byte)(xFunc), (*[0]byte)(xStep), (*[0]byte)(xFinal))
} }
// RegisterAggregator makes a Go type available as a SQLite aggregation function. // RegisterAggregator makes a Go type available as a SQLite aggregation function.
@ -804,7 +802,7 @@ func (c *SQLiteConn) exec(ctx context.Context, query string, args []namedValue)
if s.(*SQLiteStmt).s != nil { if s.(*SQLiteStmt).s != nil {
stmtArgs := make([]namedValue, 0, len(args)) stmtArgs := make([]namedValue, 0, len(args))
na := s.NumInput() na := s.NumInput()
if len(args) - start < na {
if len(args)-start < na {
s.Close() s.Close()
return nil, fmt.Errorf("not enough args to execute query: want %d got %d", na, len(args)) return nil, fmt.Errorf("not enough args to execute query: want %d got %d", na, len(args))
} }
@ -864,8 +862,8 @@ func (c *SQLiteConn) query(ctx context.Context, query string, args []namedValue)
} }
s.(*SQLiteStmt).cls = true s.(*SQLiteStmt).cls = true
na := s.NumInput() na := s.NumInput()
if len(args) - start < na {
return nil, fmt.Errorf("not enough args to execute query: want %d got %d", na, len(args) - start)
if len(args)-start < na {
return nil, fmt.Errorf("not enough args to execute query: want %d got %d", na, len(args)-start)
} }
// consume the number of arguments used in the current // consume the number of arguments used in the current
// statement and append all named arguments not contained // statement and append all named arguments not contained
@ -1041,6 +1039,8 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
secureDelete := "DEFAULT" secureDelete := "DEFAULT"
synchronousMode := "NORMAL" synchronousMode := "NORMAL"
writableSchema := -1 writableSchema := -1
vfsName := ""
var cacheSize *int64
pos := strings.IndexRune(dsn, '?') pos := strings.IndexRune(dsn, '?')
if pos >= 1 { if pos >= 1 {
@ -1364,6 +1364,22 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
} }
} }
// Cache size (_cache_size)
//
// https://sqlite.org/pragma.html#pragma_cache_size
//
if val := params.Get("_cache_size"); val != "" {
iv, err := strconv.ParseInt(val, 10, 64)
if err != nil {
return nil, fmt.Errorf("Invalid _cache_size: %v: %v", val, err)
}
cacheSize = &iv
}
if val := params.Get("vfs"); val != "" {
vfsName = val
}
if !strings.HasPrefix(dsn, "file:") { if !strings.HasPrefix(dsn, "file:") {
dsn = dsn[:pos] dsn = dsn[:pos]
} }
@ -1372,9 +1388,14 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
var db *C.sqlite3 var db *C.sqlite3
name := C.CString(dsn) name := C.CString(dsn)
defer C.free(unsafe.Pointer(name)) defer C.free(unsafe.Pointer(name))
var vfs *C.char
if vfsName != "" {
vfs = C.CString(vfsName)
defer C.free(unsafe.Pointer(vfs))
}
rv := C._sqlite3_open_v2(name, &db, rv := C._sqlite3_open_v2(name, &db,
mutex|C.SQLITE_OPEN_READWRITE|C.SQLITE_OPEN_CREATE, mutex|C.SQLITE_OPEN_READWRITE|C.SQLITE_OPEN_CREATE,
nil)
vfs)
if rv != 0 { if rv != 0 {
// Save off the error _before_ closing the database. // Save off the error _before_ closing the database.
// This is safe even if db is nil. // This is safe even if db is nil.
@ -1667,6 +1688,14 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
} }
} }
// Cache Size
if cacheSize != nil {
if err := exec(fmt.Sprintf("PRAGMA cache_size = %d;", *cacheSize)); err != nil {
C.sqlite3_close_v2(db)
return nil, err
}
}
if len(d.Extensions) > 0 { if len(d.Extensions) > 0 {
if err := conn.loadExtensions(d.Extensions); err != nil { if err := conn.loadExtensions(d.Extensions); err != nil {
conn.Close() conn.Close()
@ -1918,6 +1947,14 @@ func (s *SQLiteStmt) Exec(args []driver.Value) (driver.Result, error) {
return s.exec(context.Background(), list) return s.exec(context.Background(), list)
} }
func isInterruptErr(err error) bool {
sqliteErr, ok := err.(Error)
if ok {
return sqliteErr.Code == ErrInterrupt
}
return false
}
// exec executes a query that doesn't return rows. Attempts to honor context timeout. // exec executes a query that doesn't return rows. Attempts to honor context timeout.
func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result, error) { func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result, error) {
if ctx.Done() == nil { if ctx.Done() == nil {
@ -1933,19 +1970,22 @@ func (s *SQLiteStmt) exec(ctx context.Context, args []namedValue) (driver.Result
r, err := s.execSync(args) r, err := s.execSync(args)
resultCh <- result{r, err} resultCh <- result{r, err}
}() }()
var rv result
select { select {
case rv := <-resultCh:
return rv.r, rv.err
case rv = <-resultCh:
case <-ctx.Done(): case <-ctx.Done():
select { select {
case <-resultCh: // no need to interrupt
case rv = <-resultCh: // no need to interrupt, operation completed in db
default: default:
// this is still racy and can be no-op if executed between sqlite3_* calls in execSync. // this is still racy and can be no-op if executed between sqlite3_* calls in execSync.
C.sqlite3_interrupt(s.c.db) C.sqlite3_interrupt(s.c.db)
<-resultCh // ensure goroutine completed
rv = <-resultCh // wait for goroutine completed
if isInterruptErr(rv.err) {
return nil, ctx.Err()
}
} }
return nil, ctx.Err()
} }
return rv.r, rv.err
} }
func (s *SQLiteStmt) execSync(args []namedValue) (driver.Result, error) { func (s *SQLiteStmt) execSync(args []namedValue) (driver.Result, error) {

1
vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go

@ -14,5 +14,6 @@ package sqlite3
#cgo darwin CFLAGS: -I/usr/local/opt/sqlite/include #cgo darwin CFLAGS: -I/usr/local/opt/sqlite/include
#cgo openbsd LDFLAGS: -lsqlite3 #cgo openbsd LDFLAGS: -lsqlite3
#cgo solaris LDFLAGS: -lsqlite3 #cgo solaris LDFLAGS: -lsqlite3
#cgo windows LDFLAGS: -lsqlite3
*/ */
import "C" import "C"

2
vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go

@ -68,7 +68,7 @@ func (c *SQLiteConn) loadExtension(lib string, entry *string) error {
var centry *C.char var centry *C.char
if entry != nil { if entry != nil {
centry := C.CString(*entry)
centry = C.CString(*entry)
defer C.free(unsafe.Pointer(centry)) defer C.free(unsafe.Pointer(centry))
} }

115
vendor/github.com/mattn/go-sqlite3/sqlite3_opt_vtable.go

@ -226,11 +226,43 @@ static sqlite3_module goModule = {
0 // xRollbackTo 0 // xRollbackTo
}; };
// See https://sqlite.org/vtab.html#eponymous_only_virtual_tables
static sqlite3_module goModuleEponymousOnly = {
0, // iVersion
0, // xCreate - create a table, which here is null
cXConnect, // xConnect - connect to an existing table
cXBestIndex, // xBestIndex - Determine search strategy
cXDisconnect, // xDisconnect - Disconnect from a table
cXDestroy, // xDestroy - Drop a table
cXOpen, // xOpen - open a cursor
cXClose, // xClose - close a cursor
cXFilter, // xFilter - configure scan constraints
cXNext, // xNext - advance a cursor
cXEof, // xEof
cXColumn, // xColumn - read data
cXRowid, // xRowid - read data
cXUpdate, // xUpdate - write data
// Not implemented
0, // xBegin - begin transaction
0, // xSync - sync transaction
0, // xCommit - commit transaction
0, // xRollback - rollback transaction
0, // xFindFunction - function overloading
0, // xRename - rename the table
0, // xSavepoint
0, // xRelease
0 // xRollbackTo
};
void goMDestroy(void*); void goMDestroy(void*);
static int _sqlite3_create_module(sqlite3 *db, const char *zName, uintptr_t pClientData) { static int _sqlite3_create_module(sqlite3 *db, const char *zName, uintptr_t pClientData) {
return sqlite3_create_module_v2(db, zName, &goModule, (void*) pClientData, goMDestroy); return sqlite3_create_module_v2(db, zName, &goModule, (void*) pClientData, goMDestroy);
} }
static int _sqlite3_create_module_eponymous_only(sqlite3 *db, const char *zName, uintptr_t pClientData) {
return sqlite3_create_module_v2(db, zName, &goModuleEponymousOnly, (void*) pClientData, goMDestroy);
}
*/ */
import "C" import "C"
@ -288,10 +320,13 @@ type InfoOrderBy struct {
} }
func constraints(info *C.sqlite3_index_info) []InfoConstraint { func constraints(info *C.sqlite3_index_info) []InfoConstraint {
l := info.nConstraint
slice := (*[1 << 30]C.struct_sqlite3_index_constraint)(unsafe.Pointer(info.aConstraint))[:l:l]
slice := *(*[]C.struct_sqlite3_index_constraint)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(info.aConstraint)),
Len: int(info.nConstraint),
Cap: int(info.nConstraint),
}))
cst := make([]InfoConstraint, 0, l)
cst := make([]InfoConstraint, 0, len(slice))
for _, c := range slice { for _, c := range slice {
var usable bool var usable bool
if c.usable > 0 { if c.usable > 0 {
@ -307,10 +342,13 @@ func constraints(info *C.sqlite3_index_info) []InfoConstraint {
} }
func orderBys(info *C.sqlite3_index_info) []InfoOrderBy { func orderBys(info *C.sqlite3_index_info) []InfoOrderBy {
l := info.nOrderBy
slice := (*[1 << 30]C.struct_sqlite3_index_orderby)(unsafe.Pointer(info.aOrderBy))[:l:l]
slice := *(*[]C.struct_sqlite3_index_orderby)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(info.aOrderBy)),
Len: int(info.nOrderBy),
Cap: int(info.nOrderBy),
}))
ob := make([]InfoOrderBy, 0, l)
ob := make([]InfoOrderBy, 0, len(slice))
for _, c := range slice { for _, c := range slice {
var desc bool var desc bool
if c.desc > 0 { if c.desc > 0 {
@ -347,7 +385,7 @@ func mPrintf(format, arg string) *C.char {
//export goMInit //export goMInit
func goMInit(db, pClientData unsafe.Pointer, argc C.int, argv **C.char, pzErr **C.char, isCreate C.int) C.uintptr_t { func goMInit(db, pClientData unsafe.Pointer, argc C.int, argv **C.char, pzErr **C.char, isCreate C.int) C.uintptr_t {
m := lookupHandle(uintptr(pClientData)).(*sqliteModule)
m := lookupHandle(pClientData).(*sqliteModule)
if m.c.db != (*C.sqlite3)(db) { if m.c.db != (*C.sqlite3)(db) {
*pzErr = mPrintf("%s", "Inconsistent db handles") *pzErr = mPrintf("%s", "Inconsistent db handles")
return 0 return 0
@ -373,12 +411,12 @@ func goMInit(db, pClientData unsafe.Pointer, argc C.int, argv **C.char, pzErr **
} }
vt := sqliteVTab{m, vTab} vt := sqliteVTab{m, vTab}
*pzErr = nil *pzErr = nil
return C.uintptr_t(newHandle(m.c, &vt))
return C.uintptr_t(uintptr(newHandle(m.c, &vt)))
} }
//export goVRelease //export goVRelease
func goVRelease(pVTab unsafe.Pointer, isDestroy C.int) *C.char { func goVRelease(pVTab unsafe.Pointer, isDestroy C.int) *C.char {
vt := lookupHandle(uintptr(pVTab)).(*sqliteVTab)
vt := lookupHandle(pVTab).(*sqliteVTab)
var err error var err error
if isDestroy == 1 { if isDestroy == 1 {
err = vt.vTab.Destroy() err = vt.vTab.Destroy()
@ -393,7 +431,7 @@ func goVRelease(pVTab unsafe.Pointer, isDestroy C.int) *C.char {
//export goVOpen //export goVOpen
func goVOpen(pVTab unsafe.Pointer, pzErr **C.char) C.uintptr_t { func goVOpen(pVTab unsafe.Pointer, pzErr **C.char) C.uintptr_t {
vt := lookupHandle(uintptr(pVTab)).(*sqliteVTab)
vt := lookupHandle(pVTab).(*sqliteVTab)
vTabCursor, err := vt.vTab.Open() vTabCursor, err := vt.vTab.Open()
if err != nil { if err != nil {
*pzErr = mPrintf("%s", err.Error()) *pzErr = mPrintf("%s", err.Error())
@ -401,12 +439,12 @@ func goVOpen(pVTab unsafe.Pointer, pzErr **C.char) C.uintptr_t {
} }
vtc := sqliteVTabCursor{vt, vTabCursor} vtc := sqliteVTabCursor{vt, vTabCursor}
*pzErr = nil *pzErr = nil
return C.uintptr_t(newHandle(vt.module.c, &vtc))
return C.uintptr_t(uintptr(newHandle(vt.module.c, &vtc)))
} }
//export goVBestIndex //export goVBestIndex
func goVBestIndex(pVTab unsafe.Pointer, icp unsafe.Pointer) *C.char { func goVBestIndex(pVTab unsafe.Pointer, icp unsafe.Pointer) *C.char {
vt := lookupHandle(uintptr(pVTab)).(*sqliteVTab)
vt := lookupHandle(pVTab).(*sqliteVTab)
info := (*C.sqlite3_index_info)(icp) info := (*C.sqlite3_index_info)(icp)
csts := constraints(info) csts := constraints(info)
res, err := vt.vTab.BestIndex(csts, orderBys(info)) res, err := vt.vTab.BestIndex(csts, orderBys(info))
@ -418,13 +456,17 @@ func goVBestIndex(pVTab unsafe.Pointer, icp unsafe.Pointer) *C.char {
} }
// Get a pointer to constraint_usage struct so we can update in place. // Get a pointer to constraint_usage struct so we can update in place.
l := info.nConstraint
s := (*[1 << 30]C.struct_sqlite3_index_constraint_usage)(unsafe.Pointer(info.aConstraintUsage))[:l:l]
slice := *(*[]C.struct_sqlite3_index_constraint_usage)(unsafe.Pointer(&reflect.SliceHeader{
Data: uintptr(unsafe.Pointer(info.aConstraintUsage)),
Len: int(info.nConstraint),
Cap: int(info.nConstraint),
}))
index := 1 index := 1
for i := C.int(0); i < info.nConstraint; i++ {
for i := range slice {
if res.Used[i] { if res.Used[i] {
s[i].argvIndex = C.int(index)
s[i].omit = C.uchar(1)
slice[i].argvIndex = C.int(index)
slice[i].omit = C.uchar(1)
index++ index++
} }
} }
@ -445,7 +487,7 @@ func goVBestIndex(pVTab unsafe.Pointer, icp unsafe.Pointer) *C.char {
//export goVClose //export goVClose
func goVClose(pCursor unsafe.Pointer) *C.char { func goVClose(pCursor unsafe.Pointer) *C.char {
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
err := vtc.vTabCursor.Close() err := vtc.vTabCursor.Close()
if err != nil { if err != nil {
return mPrintf("%s", err.Error()) return mPrintf("%s", err.Error())
@ -455,13 +497,13 @@ func goVClose(pCursor unsafe.Pointer) *C.char {
//export goMDestroy //export goMDestroy
func goMDestroy(pClientData unsafe.Pointer) { func goMDestroy(pClientData unsafe.Pointer) {
m := lookupHandle(uintptr(pClientData)).(*sqliteModule)
m := lookupHandle(pClientData).(*sqliteModule)
m.module.DestroyModule() m.module.DestroyModule()
} }
//export goVFilter //export goVFilter
func goVFilter(pCursor unsafe.Pointer, idxNum C.int, idxName *C.char, argc C.int, argv **C.sqlite3_value) *C.char { func goVFilter(pCursor unsafe.Pointer, idxNum C.int, idxName *C.char, argc C.int, argv **C.sqlite3_value) *C.char {
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc] args := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.sqlite3_value)(nil))]*C.sqlite3_value)(unsafe.Pointer(argv))[:argc:argc]
vals := make([]interface{}, 0, argc) vals := make([]interface{}, 0, argc)
for _, v := range args { for _, v := range args {
@ -480,7 +522,7 @@ func goVFilter(pCursor unsafe.Pointer, idxNum C.int, idxName *C.char, argc C.int
//export goVNext //export goVNext
func goVNext(pCursor unsafe.Pointer) *C.char { func goVNext(pCursor unsafe.Pointer) *C.char {
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
err := vtc.vTabCursor.Next() err := vtc.vTabCursor.Next()
if err != nil { if err != nil {
return mPrintf("%s", err.Error()) return mPrintf("%s", err.Error())
@ -490,7 +532,7 @@ func goVNext(pCursor unsafe.Pointer) *C.char {
//export goVEof //export goVEof
func goVEof(pCursor unsafe.Pointer) C.int { func goVEof(pCursor unsafe.Pointer) C.int {
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
err := vtc.vTabCursor.EOF() err := vtc.vTabCursor.EOF()
if err { if err {
return 1 return 1
@ -500,7 +542,7 @@ func goVEof(pCursor unsafe.Pointer) C.int {
//export goVColumn //export goVColumn
func goVColumn(pCursor, cp unsafe.Pointer, col C.int) *C.char { func goVColumn(pCursor, cp unsafe.Pointer, col C.int) *C.char {
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
c := (*SQLiteContext)(cp) c := (*SQLiteContext)(cp)
err := vtc.vTabCursor.Column(c, int(col)) err := vtc.vTabCursor.Column(c, int(col))
if err != nil { if err != nil {
@ -511,7 +553,7 @@ func goVColumn(pCursor, cp unsafe.Pointer, col C.int) *C.char {
//export goVRowid //export goVRowid
func goVRowid(pCursor unsafe.Pointer, pRowid *C.sqlite3_int64) *C.char { func goVRowid(pCursor unsafe.Pointer, pRowid *C.sqlite3_int64) *C.char {
vtc := lookupHandle(uintptr(pCursor)).(*sqliteVTabCursor)
vtc := lookupHandle(pCursor).(*sqliteVTabCursor)
rowid, err := vtc.vTabCursor.Rowid() rowid, err := vtc.vTabCursor.Rowid()
if err != nil { if err != nil {
return mPrintf("%s", err.Error()) return mPrintf("%s", err.Error())
@ -522,7 +564,7 @@ func goVRowid(pCursor unsafe.Pointer, pRowid *C.sqlite3_int64) *C.char {
//export goVUpdate //export goVUpdate
func goVUpdate(pVTab unsafe.Pointer, argc C.int, argv **C.sqlite3_value, pRowid *C.sqlite3_int64) *C.char { func goVUpdate(pVTab unsafe.Pointer, argc C.int, argv **C.sqlite3_value, pRowid *C.sqlite3_int64) *C.char {
vt := lookupHandle(uintptr(pVTab)).(*sqliteVTab)
vt := lookupHandle(pVTab).(*sqliteVTab)
var tname string var tname string
if n, ok := vt.vTab.(interface { if n, ok := vt.vTab.(interface {
@ -585,6 +627,13 @@ type Module interface {
DestroyModule() DestroyModule()
} }
// EponymousOnlyModule is a "virtual table module" (as above), but
// for defining "eponymous only" virtual tables See: https://sqlite.org/vtab.html#eponymous_only_virtual_tables
type EponymousOnlyModule interface {
Module
EponymousOnlyModule()
}
// VTab describes a particular instance of the virtual table. // VTab describes a particular instance of the virtual table.
// See: http://sqlite.org/c3ref/vtab.html // See: http://sqlite.org/c3ref/vtab.html
type VTab interface { type VTab interface {
@ -642,9 +691,19 @@ func (c *SQLiteConn) CreateModule(moduleName string, module Module) error {
mname := C.CString(moduleName) mname := C.CString(moduleName)
defer C.free(unsafe.Pointer(mname)) defer C.free(unsafe.Pointer(mname))
udm := sqliteModule{c, moduleName, module} udm := sqliteModule{c, moduleName, module}
rv := C._sqlite3_create_module(c.db, mname, C.uintptr_t(newHandle(c, &udm)))
if rv != C.SQLITE_OK {
return c.lastError()
switch module.(type) {
case EponymousOnlyModule:
rv := C._sqlite3_create_module_eponymous_only(c.db, mname, C.uintptr_t(uintptr(newHandle(c, &udm))))
if rv != C.SQLITE_OK {
return c.lastError()
}
return nil
case Module:
rv := C._sqlite3_create_module(c.db, mname, C.uintptr_t(uintptr(newHandle(c, &udm))))
if rv != C.SQLITE_OK {
return c.lastError()
}
return nil
} }
return nil return nil
} }

4
vendor/github.com/mattn/go-sqlite3/sqlite3_type.go

@ -31,12 +31,12 @@ func (rc *SQLiteRows) ColumnTypeLength(index int) (length int64, ok bool) {
func (rc *SQLiteRows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { func (rc *SQLiteRows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) {
return 0, 0, false return 0, 0, false
} }
*/
// ColumnTypeNullable implement RowsColumnTypeNullable. // ColumnTypeNullable implement RowsColumnTypeNullable.
func (rc *SQLiteRows) ColumnTypeNullable(i int) (nullable, ok bool) { func (rc *SQLiteRows) ColumnTypeNullable(i int) (nullable, ok bool) {
return true, true
return false, false
} }
*/
// ColumnTypeScanType implement RowsColumnTypeScanType. // ColumnTypeScanType implement RowsColumnTypeScanType.
func (rc *SQLiteRows) ColumnTypeScanType(i int) reflect.Type { func (rc *SQLiteRows) ColumnTypeScanType(i int) reflect.Type {

4
vendor/github.com/mattn/go-sqlite3/sqlite3_usleep_windows.go

@ -15,7 +15,9 @@ package sqlite3
// This code should improve performance on windows because // This code should improve performance on windows because
// without the presence of usleep SQLite waits 1 second. // without the presence of usleep SQLite waits 1 second.
// //
// Source: https://stackoverflow.com/questions/5801813/c-usleep-is-obsolete-workarounds-for-windows-mingw?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
// Source: https://github.com/php/php-src/blob/PHP-5.0/win32/time.c
// License: https://github.com/php/php-src/blob/PHP-5.0/LICENSE
// Details: https://stackoverflow.com/questions/5801813/c-usleep-is-obsolete-workarounds-for-windows-mingw?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
/* /*
#include <windows.h> #include <windows.h>

4
vendor/github.com/mattn/go-sqlite3/sqlite3ext.h

@ -336,6 +336,8 @@ struct sqlite3_api_routines {
int,const char**); int,const char**);
void (*free_filename)(char*); void (*free_filename)(char*);
sqlite3_file *(*database_file_object)(const char*); sqlite3_file *(*database_file_object)(const char*);
/* Version 3.34.0 and later */
int (*txn_state)(sqlite3*,const char*);
}; };
/* /*
@ -640,6 +642,8 @@ typedef int (*sqlite3_loadext_entry)(
#define sqlite3_create_filename sqlite3_api->create_filename #define sqlite3_create_filename sqlite3_api->create_filename
#define sqlite3_free_filename sqlite3_api->free_filename #define sqlite3_free_filename sqlite3_api->free_filename
#define sqlite3_database_file_object sqlite3_api->database_file_object #define sqlite3_database_file_object sqlite3_api->database_file_object
/* Version 3.34.0 and later */
#define sqlite3_txn_state sqlite3_api->txn_state
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */ #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)

10
vendor/modules.txt

@ -2,7 +2,7 @@
gitea.com/lunny/log gitea.com/lunny/log
# github.com/davecgh/go-spew v1.1.1 # github.com/davecgh/go-spew v1.1.1
github.com/davecgh/go-spew/spew github.com/davecgh/go-spew/spew
# github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc
# github.com/denisenkom/go-mssqldb v0.9.0
github.com/denisenkom/go-mssqldb github.com/denisenkom/go-mssqldb
github.com/denisenkom/go-mssqldb/internal/cp github.com/denisenkom/go-mssqldb/internal/cp
github.com/denisenkom/go-mssqldb/internal/decimal github.com/denisenkom/go-mssqldb/internal/decimal
@ -28,7 +28,7 @@ github.com/inconshreveable/mousetrap
github.com/lib/pq github.com/lib/pq
github.com/lib/pq/oid github.com/lib/pq/oid
github.com/lib/pq/scram github.com/lib/pq/scram
# github.com/mattn/go-sqlite3 v1.14.0
# github.com/mattn/go-sqlite3 v1.14.6
github.com/mattn/go-sqlite3 github.com/mattn/go-sqlite3
# github.com/pmezard/go-difflib v1.0.0 # github.com/pmezard/go-difflib v1.0.0
github.com/pmezard/go-difflib/difflib github.com/pmezard/go-difflib/difflib
@ -51,13 +51,13 @@ github.com/syndtr/goleveldb/leveldb/opt
github.com/syndtr/goleveldb/leveldb/storage github.com/syndtr/goleveldb/leveldb/storage
github.com/syndtr/goleveldb/leveldb/table github.com/syndtr/goleveldb/leveldb/table
github.com/syndtr/goleveldb/leveldb/util github.com/syndtr/goleveldb/leveldb/util
# golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c
# golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
golang.org/x/crypto/md4 golang.org/x/crypto/md4
# gopkg.in/yaml.v2 v2.2.2 # gopkg.in/yaml.v2 v2.2.2
gopkg.in/yaml.v2 gopkg.in/yaml.v2
# xorm.io/builder v0.3.7
# xorm.io/builder v0.3.8
xorm.io/builder xorm.io/builder
# xorm.io/xorm v1.0.5
# xorm.io/xorm v1.1.0
xorm.io/xorm xorm.io/xorm
xorm.io/xorm/caches xorm.io/xorm/caches
xorm.io/xorm/contexts xorm.io/xorm/contexts

2
vendor/xorm.io/builder/cond_in.go

@ -23,7 +23,7 @@ func In(col string, values ...interface{}) Cond {
} }
func (condIn condIn) handleBlank(w Writer) error { func (condIn condIn) handleBlank(w Writer) error {
_, err := fmt.Fprint(w, "0=1")
_, err := fmt.Fprintf(w, "%s IN ()", condIn.col)
return err return err
} }

2
vendor/xorm.io/builder/cond_notin.go

@ -20,7 +20,7 @@ func NotIn(col string, values ...interface{}) Cond {
} }
func (condNotIn condNotIn) handleBlank(w Writer) error { func (condNotIn condNotIn) handleBlank(w Writer) error {
_, err := fmt.Fprint(w, "0=0")
_, err := fmt.Fprintf(w, "%s NOT IN ()", condNotIn.col)
return err return err
} }

3
vendor/xorm.io/builder/sql.go

@ -59,6 +59,9 @@ func ToBoundSQL(cond interface{}) (string, error) {
} }
func noSQLQuoteNeeded(a interface{}) bool { func noSQLQuoteNeeded(a interface{}) bool {
if a == nil {
return false
}
switch a.(type) { switch a.(type) {
case int, int8, int16, int32, int64: case int, int8, int16, int32, int64:
return true return true

756
vendor/xorm.io/xorm/.drone.yml

@ -2,79 +2,189 @@
kind: pipeline kind: pipeline
name: testing name: testing
steps: steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-vet - name: test-vet
image: golang:1.11 # The lowest golang requirement
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
commands: commands:
- make vet - make vet
- make test
- make fmt-check - make fmt-check
volumes:
- name: cache
path: /go
when: when:
event: event:
- push - push
- pull_request - pull_request
- name: rebuild-cache
image: meltwater/drone-cache
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
---
kind: pipeline
name: test-sqlite
depends_on:
- testing
steps:
- name: restore-cache
image: meltwater/drone-cache:dev
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-sqlite3
image: golang:1.15
environment:
GO111MODULE: "on"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
commands:
- make test-sqlite3
- TEST_CACHE_ENABLE=true make test-sqlite3
- TEST_QUOTE_POLICY=reserved make test-sqlite3
volumes:
- name: cache
path: /go
- name: test-sqlite - name: test-sqlite
image: golang:1.12
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
commands: commands:
- make test-sqlite - make test-sqlite
- TEST_CACHE_ENABLE=true make test-sqlite - TEST_CACHE_ENABLE=true make test-sqlite
- TEST_QUOTE_POLICY=reserved make test-sqlite - TEST_QUOTE_POLICY=reserved make test-sqlite
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: rebuild-cache
image: meltwater/drone-cache:dev
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
---
kind: pipeline
name: test-mysql
depends_on:
- testing
steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-mysql - name: test-mysql
image: golang:1.12
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_MYSQL_HOST: mysql TEST_MYSQL_HOST: mysql
TEST_MYSQL_CHARSET: utf8 TEST_MYSQL_CHARSET: utf8
TEST_MYSQL_DBNAME: xorm_test TEST_MYSQL_DBNAME: xorm_test
TEST_MYSQL_USERNAME: root TEST_MYSQL_USERNAME: root
TEST_MYSQL_PASSWORD: TEST_MYSQL_PASSWORD:
commands: commands:
- make test
- make test-mysql - make test-mysql
- TEST_CACHE_ENABLE=true make test-mysql - TEST_CACHE_ENABLE=true make test-mysql
- TEST_QUOTE_POLICY=reserved make test-mysql - TEST_QUOTE_POLICY=reserved make test-mysql
when:
event:
- push
- pull_request
- name: test-mysql8
image: golang:1.12
environment:
GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
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
- TEST_QUOTE_POLICY=reserved make test-mysql
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: test-mysql-utf8mb4 - name: test-mysql-utf8mb4
image: golang:1.12
image: golang:1.15
depends_on: depends_on:
- test-mysql - test-mysql
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_MYSQL_HOST: mysql TEST_MYSQL_HOST: mysql
TEST_MYSQL_CHARSET: utf8mb4 TEST_MYSQL_CHARSET: utf8mb4
TEST_MYSQL_DBNAME: xorm_test TEST_MYSQL_DBNAME: xorm_test
@ -84,19 +194,21 @@ steps:
- make test-mysql - make test-mysql
- TEST_CACHE_ENABLE=true make test-mysql - TEST_CACHE_ENABLE=true make test-mysql
- TEST_QUOTE_POLICY=reserved make test-mysql - TEST_QUOTE_POLICY=reserved make test-mysql
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: test-mymysql - name: test-mymysql
pull: default pull: default
image: golang:1.12
image: golang:1.15
depends_on: depends_on:
- test-mysql-utf8mb4 - test-mysql-utf8mb4
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_MYSQL_HOST: mysql:3306 TEST_MYSQL_HOST: mysql:3306
TEST_MYSQL_DBNAME: xorm_test TEST_MYSQL_DBNAME: xorm_test
TEST_MYSQL_USERNAME: root TEST_MYSQL_USERNAME: root
@ -105,16 +217,146 @@ steps:
- make test-mymysql - make test-mymysql
- TEST_CACHE_ENABLE=true make test-mymysql - TEST_CACHE_ENABLE=true make test-mymysql
- TEST_QUOTE_POLICY=reserved make test-mymysql - TEST_QUOTE_POLICY=reserved make test-mymysql
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: rebuild-cache
image: meltwater/drone-cache
depends_on:
- test-mysql
- test-mysql-utf8mb4
- test-mymysql
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
services:
- name: mysql
pull: default
image: mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: xorm_test
---
kind: pipeline
name: test-mysql8
depends_on:
- test-mysql
- test-sqlite
steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-mysql8
image: golang:1.15
environment:
GO111MODULE: "on"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
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
- TEST_QUOTE_POLICY=reserved make test-mysql
volumes:
- name: cache
path: /go
- name: rebuild-cache
image: meltwater/drone-cache:dev
pull: true
depends_on:
- test-mysql8
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
services:
- name: mysql8
pull: default
image: mysql:8.0
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: xorm_test
---
kind: pipeline
name: test-mariadb
depends_on:
- test-mysql8
steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-mariadb - name: test-mariadb
image: golang:1.12
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_MYSQL_HOST: mariadb TEST_MYSQL_HOST: mariadb
TEST_MYSQL_CHARSET: utf8mb4 TEST_MYSQL_CHARSET: utf8mb4
TEST_MYSQL_DBNAME: xorm_test TEST_MYSQL_DBNAME: xorm_test
@ -124,17 +366,71 @@ steps:
- make test-mysql - make test-mysql
- TEST_CACHE_ENABLE=true make test-mysql - TEST_CACHE_ENABLE=true make test-mysql
- TEST_QUOTE_POLICY=reserved make test-mysql - TEST_QUOTE_POLICY=reserved make test-mysql
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: rebuild-cache
image: meltwater/drone-cache:dev
depends_on:
- test-mariadb
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
services:
- name: mariadb
pull: default
image: mariadb:10.4
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: xorm_test
---
kind: pipeline
name: test-postgres
depends_on:
- test-mariadb
steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-postgres - name: test-postgres
pull: default pull: default
image: golang:1.12
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_PGSQL_HOST: pgsql TEST_PGSQL_HOST: pgsql
TEST_PGSQL_DBNAME: xorm_test TEST_PGSQL_DBNAME: xorm_test
TEST_PGSQL_USERNAME: postgres TEST_PGSQL_USERNAME: postgres
@ -143,19 +439,21 @@ steps:
- make test-postgres - make test-postgres
- TEST_CACHE_ENABLE=true make test-postgres - TEST_CACHE_ENABLE=true make test-postgres
- TEST_QUOTE_POLICY=reserved make test-postgres - TEST_QUOTE_POLICY=reserved make test-postgres
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: test-postgres-schema - name: test-postgres-schema
pull: default pull: default
image: golang:1.12
image: golang:1.15
depends_on: depends_on:
- test-postgres - test-postgres
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_PGSQL_HOST: pgsql TEST_PGSQL_HOST: pgsql
TEST_PGSQL_SCHEMA: xorm TEST_PGSQL_SCHEMA: xorm
TEST_PGSQL_DBNAME: xorm_test TEST_PGSQL_DBNAME: xorm_test
@ -165,17 +463,72 @@ steps:
- make test-postgres - make test-postgres
- TEST_CACHE_ENABLE=true make test-postgres - TEST_CACHE_ENABLE=true make test-postgres
- TEST_QUOTE_POLICY=reserved make test-postgres - TEST_QUOTE_POLICY=reserved make test-postgres
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: rebuild-cache
image: meltwater/drone-cache:dev
pull: true
depends_on:
- test-postgres-schema
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
services:
- name: pgsql
pull: default
image: postgres:9.5
environment:
POSTGRES_DB: xorm_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
---
kind: pipeline
name: test-mssql
depends_on:
- test-postgres
steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-mssql - name: test-mssql
pull: default pull: default
image: golang:1.12
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_MSSQL_HOST: mssql TEST_MSSQL_HOST: mssql
TEST_MSSQL_DBNAME: xorm_test TEST_MSSQL_DBNAME: xorm_test
TEST_MSSQL_USERNAME: sa TEST_MSSQL_USERNAME: sa
@ -185,17 +538,70 @@ steps:
- TEST_CACHE_ENABLE=true make test-mssql - TEST_CACHE_ENABLE=true make test-mssql
- TEST_QUOTE_POLICY=reserved make test-mssql - TEST_QUOTE_POLICY=reserved make test-mssql
- TEST_MSSQL_DEFAULT_VARCHAR=NVARCHAR TEST_MSSQL_DEFAULT_CHAR=NCHAR make test-mssql - TEST_MSSQL_DEFAULT_VARCHAR=NVARCHAR TEST_MSSQL_DEFAULT_CHAR=NCHAR make test-mssql
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: rebuild-cache
image: meltwater/drone-cache:dev
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
services:
- name: mssql
pull: default
image: microsoft/mssql-server-linux:latest
environment:
ACCEPT_EULA: Y
SA_PASSWORD: yourStrong(!)Password
MSSQL_PID: Developer
---
kind: pipeline
name: test-tidb
depends_on:
- test-mssql
steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-tidb - name: test-tidb
pull: default pull: default
image: golang:1.12
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_TIDB_HOST: "tidb:4000" TEST_TIDB_HOST: "tidb:4000"
TEST_TIDB_DBNAME: xorm_test TEST_TIDB_DBNAME: xorm_test
TEST_TIDB_USERNAME: root TEST_TIDB_USERNAME: root
@ -204,17 +610,66 @@ steps:
- make test-tidb - make test-tidb
- TEST_CACHE_ENABLE=true make test-tidb - TEST_CACHE_ENABLE=true make test-tidb
- TEST_QUOTE_POLICY=reserved make test-tidb - TEST_QUOTE_POLICY=reserved make test-tidb
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: rebuild-cache
image: meltwater/drone-cache:dev
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
services:
- name: tidb
pull: default
image: pingcap/tidb:v3.0.3
---
kind: pipeline
name: test-cockroach
depends_on:
- test-tidb
steps:
- name: restore-cache
image: meltwater/drone-cache
pull: always
settings:
backend: "filesystem"
restore: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
- name: test-cockroach - name: test-cockroach
pull: default pull: default
image: golang:1.13
image: golang:1.15
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
GOPROXY: "https://goproxy.io"
CGO_ENABLED: 1
GOMODCACHE: '/drone/src/pkg.mod'
GOCACHE: '/drone/src/pkg.build'
TEST_COCKROACH_HOST: "cockroach:26257" TEST_COCKROACH_HOST: "cockroach:26257"
TEST_COCKROACH_DBNAME: xorm_test TEST_COCKROACH_DBNAME: xorm_test
TEST_COCKROACH_USERNAME: root TEST_COCKROACH_USERNAME: root
@ -223,115 +678,62 @@ steps:
- sleep 10 - sleep 10
- make test-cockroach - make test-cockroach
- TEST_CACHE_ENABLE=true make test-cockroach - TEST_CACHE_ENABLE=true make test-cockroach
when:
event:
- push
- pull_request
volumes:
- name: cache
path: /go
- name: merge_coverage
- name: rebuild-cache
image: meltwater/drone-cache:dev
pull: true
settings:
backend: "filesystem"
rebuild: true
cache_key: '{{ .Repo.Name }}_{{ checksum "go.mod" }}_{{ checksum "go.sum" }}_{{ arch }}_{{ os }}'
archive_format: "gzip"
filesystem_cache_root: "/go"
mount:
- pkg.mod
- pkg.build
volumes:
- name: cache
path: /go
volumes:
- name: cache
temp: {}
services:
- name: cockroach
pull: default pull: default
image: golang:1.12
environment:
GO111MODULE: "on"
GOPROXY: "https://goproxy.cn"
depends_on:
- test-vet
image: cockroachdb/cockroach:v19.2.4
commands:
- /cockroach/cockroach start --insecure
---
kind: pipeline
name: merge_coverage
depends_on:
- testing
- test-sqlite - test-sqlite
- test-mysql - test-mysql
- test-mysql8 - test-mysql8
- test-mymysql
- test-mariadb
- test-postgres - test-postgres
- test-postgres-schema
- test-mssql - test-mssql
- test-tidb - test-tidb
- test-cockroach - test-cockroach
commands:
- make coverage
when:
event:
- push
- pull_request
services:
- name: mysql
pull: default
image: mysql:5.7
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: xorm_test
when:
event:
- push
- tag
- pull_request
- name: mysql8
pull: default
image: mysql:8.0
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: xorm_test
when:
event:
- push
- tag
- pull_request
- name: mariadb
pull: default
image: mariadb:10.4
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: xorm_test
when:
event:
- push
- tag
- pull_request
- name: pgsql
pull: default
image: postgres:9.5
environment:
POSTGRES_DB: xorm_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
when:
event:
- push
- tag
- pull_request
- name: mssql
steps:
- name: merge_coverage
pull: default pull: default
image: microsoft/mssql-server-linux:latest
image: golang:1.15
environment: environment:
ACCEPT_EULA: Y
SA_PASSWORD: yourStrong(!)Password
MSSQL_PID: Developer
when:
event:
- push
- tag
- pull_request
- name: tidb
pull: default
image: pingcap/tidb:v3.0.3
when:
event:
- push
- tag
- pull_request
- name: cockroach
pull: default
image: cockroachdb/cockroach:v19.2.4
GO111MODULE: "on"
GOPROXY: "https://goproxy.io"
commands: commands:
- /cockroach/cockroach start --insecure
- make coverage
when: when:
branch:
- master
event: event:
- push
- tag
- pull_request
- push
- pull_request

1
vendor/xorm.io/xorm/.gitignore

@ -36,3 +36,4 @@ test.db.sql
*coverage.out *coverage.out
test.db test.db
integrations/*.sql integrations/*.sql
integrations/test_sqlite*

4
vendor/xorm.io/xorm/.revive.toml

@ -15,6 +15,7 @@ warningCode = 1
[rule.if-return] [rule.if-return]
[rule.increment-decrement] [rule.increment-decrement]
[rule.var-naming] [rule.var-naming]
arguments = [["ID", "UID", "UUID", "URL", "JSON"], []]
[rule.var-declaration] [rule.var-declaration]
[rule.package-comments] [rule.package-comments]
[rule.range] [rule.range]
@ -22,4 +23,5 @@ warningCode = 1
[rule.time-naming] [rule.time-naming]
[rule.unexported-return] [rule.unexported-return]
[rule.indent-error-flow] [rule.indent-error-flow]
[rule.errorf]
[rule.errorf]
[rule.struct-tag]

36
vendor/xorm.io/xorm/CHANGELOG.md

@ -3,6 +3,42 @@
This changelog goes through all the changes that have been made in each release This changelog goes through all the changes that have been made in each release
without substantial changes to our git log. without substantial changes to our git log.
## [1.1.0](https://gitea.com/xorm/xorm/releases/tag/1.1.0) - 2021-05-14
* FEATURES
* Unsigned Support for mysql (#1889)
* Support modernc.org/sqlite (#1850)
* TESTING
* More tests (#1890)
* MISC
* Byte strings in postgres aren't 0x... (#1906)
* Fix another bug with #1872 (#1905)
* Fix two issues with dumptables (#1903)
* Fix comments (#1896)
* Fix comments (#1893)
* MariaDB 10.5 adds a suffix on old datatypes (#1885)
## [1.0.7](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1336) - 2021-01-21
* BUGFIXES
* Fix bug for mssql (#1854)
* MISC
* fix_bugs_for_mssql (#1852)
## [1.0.6](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1308) - 2021-01-05
* BUGFIXES
* Fix bug when modify column on mssql (#1849)
* Fix find and count bug with cols (#1826)
* Fix update bug (#1823)
* Fix json tag with other type (#1822)
* ENHANCEMENTS
* prevent panic when struct with unexport field (#1839)
* Automatically convert datetime to int64 (#1715)
* MISC
* Fix index (#1841)
* Performance improvement for columnsbyName (#1788)
## [1.0.5](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1299) - 2020-09-08 ## [1.0.5](https://gitea.com/xorm/xorm/pulls?q=&type=all&state=closed&milestone=1299) - 2020-09-08
* BUGFIXES * BUGFIXES

31
vendor/xorm.io/xorm/Makefile

@ -6,7 +6,9 @@ GOFMT ?= gofmt -s
TAGS ?= TAGS ?=
SED_INPLACE := sed -i SED_INPLACE := sed -i
GOFILES := $(shell find . -name "*.go" -type f)
GO_DIRS := caches contexts integrations convert core dialects internal log migrate names schemas tags
GOFILES := $(wildcard *.go)
GOFILES += $(shell find $(GO_DIRS) -name "*.go" -type f)
INTEGRATION_PACKAGES := xorm.io/xorm/integrations INTEGRATION_PACKAGES := xorm.io/xorm/integrations
PACKAGES ?= $(filter-out $(INTEGRATION_PACKAGES),$(shell $(GO) list ./...)) PACKAGES ?= $(filter-out $(INTEGRATION_PACKAGES),$(shell $(GO) list ./...))
@ -99,7 +101,8 @@ help:
@echo " - test-mysql run integration tests for mysql" @echo " - test-mysql run integration tests for mysql"
@echo " - test-mssql run integration tests for mssql" @echo " - test-mssql run integration tests for mssql"
@echo " - test-postgres run integration tests for postgres" @echo " - test-postgres run integration tests for postgres"
@echo " - test-sqlite run integration tests for sqlite"
@echo " - test-sqlite3 run integration tests for sqlite"
@echo " - test-sqlite run integration tests for pure go sqlite"
@echo " - test-tidb run integration tests for tidb" @echo " - test-tidb run integration tests for tidb"
@echo " - vet examines Go source code and reports suspicious constructs" @echo " - vet examines Go source code and reports suspicious constructs"
@ -195,21 +198,37 @@ test-postgres\#%: go-check
-conn_str="postgres://$(TEST_PGSQL_USERNAME):$(TEST_PGSQL_PASSWORD)@$(TEST_PGSQL_HOST)/$(TEST_PGSQL_DBNAME)?sslmode=disable" \ -conn_str="postgres://$(TEST_PGSQL_USERNAME):$(TEST_PGSQL_PASSWORD)@$(TEST_PGSQL_HOST)/$(TEST_PGSQL_DBNAME)?sslmode=disable" \
-quote=$(TEST_QUOTE_POLICY) -coverprofile=postgres.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic -quote=$(TEST_QUOTE_POLICY) -coverprofile=postgres.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
.PHONY: test-sqlite3
test-sqlite3: go-check
$(GO) test $(INTEGRATION_PACKAGES) -v -race -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
-quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite3.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
.PHONY: test-sqlite3-schema
test-sqlite3-schema: go-check
$(GO) test $(INTEGRATION_PACKAGES) -v -race -schema=xorm -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
-quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite3.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
.PHONY: test-sqlite3\#%
test-sqlite3\#%: go-check
$(GO) test $(INTEGRATION_PACKAGES) -v -race -run $* -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
-quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite3.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
.PHONY: test-sqlite .PHONY: test-sqlite
test-sqlite: go-check test-sqlite: go-check
$(GO) test $(INTEGRATION_PACKAGES) -v -race -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
$(GO) test $(INTEGRATION_PACKAGES) -v -race -cache=$(TEST_CACHE_ENABLE) -db=sqlite -conn_str="./test.db?cache=shared&mode=rwc" \
-quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic -quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
.PHONY: test-sqlite-schema .PHONY: test-sqlite-schema
test-sqlite-schema: go-check test-sqlite-schema: go-check
$(GO) test $(INTEGRATION_PACKAGES) -v -race -schema=xorm -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
$(GO) test $(INTEGRATION_PACKAGES) -v -race -schema=xorm -cache=$(TEST_CACHE_ENABLE) -db=sqlite -conn_str="./test.db?cache=shared&mode=rwc" \
-quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic -quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
.PHONY: test-sqlite\#% .PHONY: test-sqlite\#%
test-sqlite\#%: go-check test-sqlite\#%: go-check
$(GO) test $(INTEGRATION_PACKAGES) -v -race -run $* -cache=$(TEST_CACHE_ENABLE) -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" \
$(GO) test $(INTEGRATION_PACKAGES) -v -race -run $* -cache=$(TEST_CACHE_ENABLE) -db=sqlite -conn_str="./test.db?cache=shared&mode=rwc" \
-quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic -quote=$(TEST_QUOTE_POLICY) -coverprofile=sqlite.$(TEST_QUOTE_POLICY).$(TEST_CACHE_ENABLE).coverage.out -covermode=atomic
.PNONY: test-tidb .PNONY: test-tidb
test-tidb: go-check test-tidb: go-check
$(GO) test $(INTEGRATION_PACKAGES) -v -race -db=mysql -cache=$(TEST_CACHE_ENABLE) -ignore_select_update=true \ $(GO) test $(INTEGRATION_PACKAGES) -v -race -db=mysql -cache=$(TEST_CACHE_ENABLE) -ignore_select_update=true \
@ -224,4 +243,4 @@ test-tidb\#%: go-check
.PHONY: vet .PHONY: vet
vet: vet:
$(GO) vet $(shell $(GO) list ./...)
$(GO) vet $(shell $(GO) list ./...)

9
vendor/xorm.io/xorm/caches/encode.go

@ -13,22 +13,26 @@ import (
"io" "io"
) )
// md5 hash string
// Md5 return md5 hash string
func Md5(str string) string { func Md5(str string) string {
m := md5.New() m := md5.New()
io.WriteString(m, str) io.WriteString(m, str)
return fmt.Sprintf("%x", m.Sum(nil)) return fmt.Sprintf("%x", m.Sum(nil))
} }
// Encode Encode data
func Encode(data interface{}) ([]byte, error) { func Encode(data interface{}) ([]byte, error) {
//return JsonEncode(data) //return JsonEncode(data)
return GobEncode(data) return GobEncode(data)
} }
// Decode decode data
func Decode(data []byte, to interface{}) error { func Decode(data []byte, to interface{}) error {
//return JsonDecode(data, to) //return JsonDecode(data, to)
return GobDecode(data, to) return GobDecode(data, to)
} }
// GobEncode encode data with gob
func GobEncode(data interface{}) ([]byte, error) { func GobEncode(data interface{}) ([]byte, error) {
var buf bytes.Buffer var buf bytes.Buffer
enc := gob.NewEncoder(&buf) enc := gob.NewEncoder(&buf)
@ -39,12 +43,14 @@ func GobEncode(data interface{}) ([]byte, error) {
return buf.Bytes(), nil return buf.Bytes(), nil
} }
// GobDecode decode data with gob
func GobDecode(data []byte, to interface{}) error { func GobDecode(data []byte, to interface{}) error {
buf := bytes.NewBuffer(data) buf := bytes.NewBuffer(data)
dec := gob.NewDecoder(buf) dec := gob.NewDecoder(buf)
return dec.Decode(to) return dec.Decode(to)
} }
// JsonEncode encode data with json
func JsonEncode(data interface{}) ([]byte, error) { func JsonEncode(data interface{}) ([]byte, error) {
val, err := json.Marshal(data) val, err := json.Marshal(data)
if err != nil { if err != nil {
@ -53,6 +59,7 @@ func JsonEncode(data interface{}) ([]byte, error) {
return val, nil return val, nil
} }
// JsonDecode decode data with json
func JsonDecode(data []byte, to interface{}) error { func JsonDecode(data []byte, to interface{}) error {
return json.Unmarshal(data, to) return json.Unmarshal(data, to)
} }

5
vendor/xorm.io/xorm/caches/leveldb.go

@ -19,6 +19,7 @@ type LevelDBStore struct {
var _ CacheStore = &LevelDBStore{} var _ CacheStore = &LevelDBStore{}
// NewLevelDBStore creates a leveldb store
func NewLevelDBStore(dbfile string) (*LevelDBStore, error) { func NewLevelDBStore(dbfile string) (*LevelDBStore, error) {
db := &LevelDBStore{} db := &LevelDBStore{}
h, err := leveldb.OpenFile(dbfile, nil) h, err := leveldb.OpenFile(dbfile, nil)
@ -29,6 +30,7 @@ func NewLevelDBStore(dbfile string) (*LevelDBStore, error) {
return db, nil return db, nil
} }
// Put implements CacheStore
func (s *LevelDBStore) Put(key string, value interface{}) error { func (s *LevelDBStore) Put(key string, value interface{}) error {
val, err := Encode(value) val, err := Encode(value)
if err != nil { if err != nil {
@ -50,6 +52,7 @@ func (s *LevelDBStore) Put(key string, value interface{}) error {
return err return err
} }
// Get implements CacheStore
func (s *LevelDBStore) Get(key string) (interface{}, error) { func (s *LevelDBStore) Get(key string) (interface{}, error) {
data, err := s.store.Get([]byte(key), nil) data, err := s.store.Get([]byte(key), nil)
if err != nil { if err != nil {
@ -75,6 +78,7 @@ func (s *LevelDBStore) Get(key string) (interface{}, error) {
return s.v, err return s.v, err
} }
// Del implements CacheStore
func (s *LevelDBStore) Del(key string) error { func (s *LevelDBStore) Del(key string) error {
err := s.store.Delete([]byte(key), nil) err := s.store.Delete([]byte(key), nil)
if err != nil { if err != nil {
@ -89,6 +93,7 @@ func (s *LevelDBStore) Del(key string) error {
return err return err
} }
// Close implements CacheStore
func (s *LevelDBStore) Close() { func (s *LevelDBStore) Close() {
s.store.Close() s.store.Close()
} }

4
vendor/xorm.io/xorm/caches/manager.go

@ -6,6 +6,7 @@ package caches
import "sync" import "sync"
// Manager represents a cache manager
type Manager struct { type Manager struct {
cacher Cacher cacher Cacher
disableGlobalCache bool disableGlobalCache bool
@ -14,6 +15,7 @@ type Manager struct {
cacherLock sync.RWMutex cacherLock sync.RWMutex
} }
// NewManager creates a cache manager
func NewManager() *Manager { func NewManager() *Manager {
return &Manager{ return &Manager{
cachers: make(map[string]Cacher), cachers: make(map[string]Cacher),
@ -27,12 +29,14 @@ func (mgr *Manager) SetDisableGlobalCache(disable bool) {
} }
} }
// SetCacher set cacher of table
func (mgr *Manager) SetCacher(tableName string, cacher Cacher) { func (mgr *Manager) SetCacher(tableName string, cacher Cacher) {
mgr.cacherLock.Lock() mgr.cacherLock.Lock()
mgr.cachers[tableName] = cacher mgr.cachers[tableName] = cacher
mgr.cacherLock.Unlock() mgr.cacherLock.Unlock()
} }
// GetCacher returns a cache of a table
func (mgr *Manager) GetCacher(tableName string) Cacher { func (mgr *Manager) GetCacher(tableName string) Cacher {
var cacher Cacher var cacher Cacher
var ok bool var ok bool

6
vendor/xorm.io/xorm/contexts/hook.go

@ -31,6 +31,7 @@ func NewContextHook(ctx context.Context, sql string, args []interface{}) *Contex
} }
} }
// End finish the hook invokation
func (c *ContextHook) End(ctx context.Context, result sql.Result, err error) { func (c *ContextHook) End(ctx context.Context, result sql.Result, err error) {
c.Ctx = ctx c.Ctx = ctx
c.Result = result c.Result = result
@ -38,19 +39,23 @@ func (c *ContextHook) End(ctx context.Context, result sql.Result, err error) {
c.ExecuteTime = time.Now().Sub(c.start) c.ExecuteTime = time.Now().Sub(c.start)
} }
// Hook represents a hook behaviour
type Hook interface { type Hook interface {
BeforeProcess(c *ContextHook) (context.Context, error) BeforeProcess(c *ContextHook) (context.Context, error)
AfterProcess(c *ContextHook) error AfterProcess(c *ContextHook) error
} }
// Hooks implements Hook interface but contains multiple Hook
type Hooks struct { type Hooks struct {
hooks []Hook hooks []Hook
} }
// AddHook adds a Hook
func (h *Hooks) AddHook(hooks ...Hook) { func (h *Hooks) AddHook(hooks ...Hook) {
h.hooks = append(h.hooks, hooks...) h.hooks = append(h.hooks, hooks...)
} }
// BeforeProcess invoked before execute the process
func (h *Hooks) BeforeProcess(c *ContextHook) (context.Context, error) { func (h *Hooks) BeforeProcess(c *ContextHook) (context.Context, error) {
ctx := c.Ctx ctx := c.Ctx
for _, h := range h.hooks { for _, h := range h.hooks {
@ -63,6 +68,7 @@ func (h *Hooks) BeforeProcess(c *ContextHook) (context.Context, error) {
return ctx, nil return ctx, nil
} }
// AfterProcess invoked after exetue the process
func (h *Hooks) AfterProcess(c *ContextHook) error { func (h *Hooks) AfterProcess(c *ContextHook) error {
firstErr := c.Err firstErr := c.Err
for _, h := range h.hooks { for _, h := range h.hooks {

15
vendor/xorm.io/xorm/core/db.go

@ -23,6 +23,7 @@ var (
DefaultCacheSize = 200 DefaultCacheSize = 200
) )
// MapToSlice map query and struct as sql and args
func MapToSlice(query string, mp interface{}) (string, []interface{}, error) { func MapToSlice(query string, mp interface{}) (string, []interface{}, error) {
vv := reflect.ValueOf(mp) vv := reflect.ValueOf(mp)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map {
@ -44,6 +45,7 @@ func MapToSlice(query string, mp interface{}) (string, []interface{}, error) {
return query, args, err return query, args, err
} }
// StructToSlice converts a query and struct as sql and args
func StructToSlice(query string, st interface{}) (string, []interface{}, error) { func StructToSlice(query string, st interface{}) (string, []interface{}, error) {
vv := reflect.ValueOf(st) vv := reflect.ValueOf(st)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
@ -176,6 +178,7 @@ func (db *DB) QueryMap(query string, mp interface{}) (*Rows, error) {
return db.QueryMapContext(context.Background(), query, mp) return db.QueryMapContext(context.Background(), query, mp)
} }
// QueryStructContext query rows with struct
func (db *DB) QueryStructContext(ctx context.Context, query string, st interface{}) (*Rows, error) { func (db *DB) QueryStructContext(ctx context.Context, query string, st interface{}) (*Rows, error) {
query, args, err := StructToSlice(query, st) query, args, err := StructToSlice(query, st)
if err != nil { if err != nil {
@ -184,10 +187,12 @@ func (db *DB) QueryStructContext(ctx context.Context, query string, st interface
return db.QueryContext(ctx, query, args...) return db.QueryContext(ctx, query, args...)
} }
// QueryStruct query rows with struct
func (db *DB) QueryStruct(query string, st interface{}) (*Rows, error) { func (db *DB) QueryStruct(query string, st interface{}) (*Rows, error) {
return db.QueryStructContext(context.Background(), query, st) return db.QueryStructContext(context.Background(), query, st)
} }
// QueryRowContext query row with args
func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row { func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row {
rows, err := db.QueryContext(ctx, query, args...) rows, err := db.QueryContext(ctx, query, args...)
if err != nil { if err != nil {
@ -196,10 +201,12 @@ func (db *DB) QueryRowContext(ctx context.Context, query string, args ...interfa
return &Row{rows, nil} return &Row{rows, nil}
} }
// QueryRow query row with args
func (db *DB) QueryRow(query string, args ...interface{}) *Row { func (db *DB) QueryRow(query string, args ...interface{}) *Row {
return db.QueryRowContext(context.Background(), query, args...) return db.QueryRowContext(context.Background(), query, args...)
} }
// QueryRowMapContext query row with map
func (db *DB) QueryRowMapContext(ctx context.Context, query string, mp interface{}) *Row { func (db *DB) QueryRowMapContext(ctx context.Context, query string, mp interface{}) *Row {
query, args, err := MapToSlice(query, mp) query, args, err := MapToSlice(query, mp)
if err != nil { if err != nil {
@ -208,10 +215,12 @@ func (db *DB) QueryRowMapContext(ctx context.Context, query string, mp interface
return db.QueryRowContext(ctx, query, args...) return db.QueryRowContext(ctx, query, args...)
} }
// QueryRowMap query row with map
func (db *DB) QueryRowMap(query string, mp interface{}) *Row { func (db *DB) QueryRowMap(query string, mp interface{}) *Row {
return db.QueryRowMapContext(context.Background(), query, mp) return db.QueryRowMapContext(context.Background(), query, mp)
} }
// QueryRowStructContext query row with struct
func (db *DB) QueryRowStructContext(ctx context.Context, query string, st interface{}) *Row { func (db *DB) QueryRowStructContext(ctx context.Context, query string, st interface{}) *Row {
query, args, err := StructToSlice(query, st) query, args, err := StructToSlice(query, st)
if err != nil { if err != nil {
@ -220,6 +229,7 @@ func (db *DB) QueryRowStructContext(ctx context.Context, query string, st interf
return db.QueryRowContext(ctx, query, args...) return db.QueryRowContext(ctx, query, args...)
} }
// QueryRowStruct query row with struct
func (db *DB) QueryRowStruct(query string, st interface{}) *Row { func (db *DB) QueryRowStruct(query string, st interface{}) *Row {
return db.QueryRowStructContext(context.Background(), query, st) return db.QueryRowStructContext(context.Background(), query, st)
} }
@ -239,10 +249,12 @@ func (db *DB) ExecMapContext(ctx context.Context, query string, mp interface{})
return db.ExecContext(ctx, query, args...) return db.ExecContext(ctx, query, args...)
} }
// ExecMap exec query with map
func (db *DB) ExecMap(query string, mp interface{}) (sql.Result, error) { func (db *DB) ExecMap(query string, mp interface{}) (sql.Result, error) {
return db.ExecMapContext(context.Background(), query, mp) return db.ExecMapContext(context.Background(), query, mp)
} }
// ExecStructContext exec query with map
func (db *DB) ExecStructContext(ctx context.Context, query string, st interface{}) (sql.Result, error) { func (db *DB) ExecStructContext(ctx context.Context, query string, st interface{}) (sql.Result, error) {
query, args, err := StructToSlice(query, st) query, args, err := StructToSlice(query, st)
if err != nil { if err != nil {
@ -251,6 +263,7 @@ func (db *DB) ExecStructContext(ctx context.Context, query string, st interface{
return db.ExecContext(ctx, query, args...) return db.ExecContext(ctx, query, args...)
} }
// ExecContext exec query with args
func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
hookCtx := contexts.NewContextHook(ctx, query, args) hookCtx := contexts.NewContextHook(ctx, query, args)
ctx, err := db.beforeProcess(hookCtx) ctx, err := db.beforeProcess(hookCtx)
@ -265,6 +278,7 @@ func (db *DB) ExecContext(ctx context.Context, query string, args ...interface{}
return res, nil return res, nil
} }
// ExecStruct exec query with struct
func (db *DB) ExecStruct(query string, st interface{}) (sql.Result, error) { func (db *DB) ExecStruct(query string, st interface{}) (sql.Result, error) {
return db.ExecStructContext(context.Background(), query, st) return db.ExecStructContext(context.Background(), query, st)
} }
@ -288,6 +302,7 @@ func (db *DB) afterProcess(c *contexts.ContextHook) error {
return err return err
} }
// AddHook adds hook
func (db *DB) AddHook(h ...contexts.Hook) { func (db *DB) AddHook(h ...contexts.Hook) {
db.hooks.AddHook(h...) db.hooks.AddHook(h...)
} }

20
vendor/xorm.io/xorm/core/rows.go

@ -11,11 +11,13 @@ import (
"sync" "sync"
) )
// Rows represents rows of table
type Rows struct { type Rows struct {
*sql.Rows *sql.Rows
db *DB db *DB
} }
// ToMapString returns all records
func (rs *Rows) ToMapString() ([]map[string]string, error) { func (rs *Rows) ToMapString() ([]map[string]string, error) {
cols, err := rs.Columns() cols, err := rs.Columns()
if err != nil { if err != nil {
@ -34,7 +36,7 @@ func (rs *Rows) ToMapString() ([]map[string]string, error) {
return results, nil return results, nil
} }
// scan data to a struct's pointer according field index
// ScanStructByIndex scan data to a struct's pointer according field index
func (rs *Rows) ScanStructByIndex(dest ...interface{}) error { func (rs *Rows) ScanStructByIndex(dest ...interface{}) error {
if len(dest) == 0 { if len(dest) == 0 {
return errors.New("at least one struct") return errors.New("at least one struct")
@ -94,7 +96,7 @@ func fieldByName(v reflect.Value, name string) reflect.Value {
return reflect.Zero(t) return reflect.Zero(t)
} }
// scan data to a struct's pointer according field name
// ScanStructByName scan data to a struct's pointer according field name
func (rs *Rows) ScanStructByName(dest interface{}) error { func (rs *Rows) ScanStructByName(dest interface{}) error {
vv := reflect.ValueOf(dest) vv := reflect.ValueOf(dest)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
@ -120,7 +122,7 @@ func (rs *Rows) ScanStructByName(dest interface{}) error {
return rs.Rows.Scan(newDest...) return rs.Rows.Scan(newDest...)
} }
// scan data to a slice's pointer, slice's length should equal to columns' number
// ScanSlice scan data to a slice's pointer, slice's length should equal to columns' number
func (rs *Rows) ScanSlice(dest interface{}) error { func (rs *Rows) ScanSlice(dest interface{}) error {
vv := reflect.ValueOf(dest) vv := reflect.ValueOf(dest)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Slice { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Slice {
@ -155,7 +157,7 @@ func (rs *Rows) ScanSlice(dest interface{}) error {
return nil return nil
} }
// scan data to a map's pointer
// ScanMap scan data to a map's pointer
func (rs *Rows) ScanMap(dest interface{}) error { func (rs *Rows) ScanMap(dest interface{}) error {
vv := reflect.ValueOf(dest) vv := reflect.ValueOf(dest)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map {
@ -187,6 +189,7 @@ func (rs *Rows) ScanMap(dest interface{}) error {
return nil return nil
} }
// Row reprents a row of a tab
type Row struct { type Row struct {
rows *Rows rows *Rows
// One of these two will be non-nil: // One of these two will be non-nil:
@ -205,6 +208,7 @@ func NewRow(rows *Rows, err error) *Row {
return &Row{rows, err} return &Row{rows, err}
} }
// Columns returns all columns of the row
func (row *Row) Columns() ([]string, error) { func (row *Row) Columns() ([]string, error) {
if row.err != nil { if row.err != nil {
return nil, row.err return nil, row.err
@ -212,6 +216,7 @@ func (row *Row) Columns() ([]string, error) {
return row.rows.Columns() return row.rows.Columns()
} }
// Scan retrieves all row column values
func (row *Row) Scan(dest ...interface{}) error { func (row *Row) Scan(dest ...interface{}) error {
if row.err != nil { if row.err != nil {
return row.err return row.err
@ -238,6 +243,7 @@ func (row *Row) Scan(dest ...interface{}) error {
return row.rows.Close() return row.rows.Close()
} }
// ScanStructByName retrieves all row column values into a struct
func (row *Row) ScanStructByName(dest interface{}) error { func (row *Row) ScanStructByName(dest interface{}) error {
if row.err != nil { if row.err != nil {
return row.err return row.err
@ -258,6 +264,7 @@ func (row *Row) ScanStructByName(dest interface{}) error {
return row.rows.Close() return row.rows.Close()
} }
// ScanStructByIndex retrieves all row column values into a struct
func (row *Row) ScanStructByIndex(dest interface{}) error { func (row *Row) ScanStructByIndex(dest interface{}) error {
if row.err != nil { if row.err != nil {
return row.err return row.err
@ -278,7 +285,7 @@ func (row *Row) ScanStructByIndex(dest interface{}) error {
return row.rows.Close() return row.rows.Close()
} }
// scan data to a slice's pointer, slice's length should equal to columns' number
// ScanSlice scan data to a slice's pointer, slice's length should equal to columns' number
func (row *Row) ScanSlice(dest interface{}) error { func (row *Row) ScanSlice(dest interface{}) error {
if row.err != nil { if row.err != nil {
return row.err return row.err
@ -300,7 +307,7 @@ func (row *Row) ScanSlice(dest interface{}) error {
return row.rows.Close() return row.rows.Close()
} }
// scan data to a map's pointer
// ScanMap scan data to a map's pointer
func (row *Row) ScanMap(dest interface{}) error { func (row *Row) ScanMap(dest interface{}) error {
if row.err != nil { if row.err != nil {
return row.err return row.err
@ -322,6 +329,7 @@ func (row *Row) ScanMap(dest interface{}) error {
return row.rows.Close() return row.rows.Close()
} }
// ToMapString returns all clumns of this record
func (row *Row) ToMapString() (map[string]string, error) { func (row *Row) ToMapString() (map[string]string, error) {
cols, err := row.Columns() cols, err := row.Columns()
if err != nil { if err != nil {

4
vendor/xorm.io/xorm/core/scan.go

@ -10,12 +10,14 @@ import (
"time" "time"
) )
// NullTime defines a customize type NullTime
type NullTime time.Time type NullTime time.Time
var ( var (
_ driver.Valuer = NullTime{} _ driver.Valuer = NullTime{}
) )
// Scan implements driver.Valuer
func (ns *NullTime) Scan(value interface{}) error { func (ns *NullTime) Scan(value interface{}) error {
if value == nil { if value == nil {
return nil return nil
@ -58,9 +60,11 @@ func convertTime(dest *NullTime, src interface{}) error {
return nil return nil
} }
// EmptyScanner represents an empty scanner
type EmptyScanner struct { type EmptyScanner struct {
} }
// Scan implements
func (EmptyScanner) Scan(src interface{}) error { func (EmptyScanner) Scan(src interface{}) error {
return nil return nil
} }

19
vendor/xorm.io/xorm/core/stmt.go

@ -21,6 +21,7 @@ type Stmt struct {
query string query string
} }
// PrepareContext creates a prepare statement
func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error) { func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error) {
names := make(map[string]int) names := make(map[string]int)
var i int var i int
@ -42,10 +43,12 @@ func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error) {
return &Stmt{stmt, db, names, query}, nil return &Stmt{stmt, db, names, query}, nil
} }
// Prepare creates a prepare statement
func (db *DB) Prepare(query string) (*Stmt, error) { func (db *DB) Prepare(query string) (*Stmt, error) {
return db.PrepareContext(context.Background(), query) return db.PrepareContext(context.Background(), query)
} }
// ExecMapContext execute with map
func (s *Stmt) ExecMapContext(ctx context.Context, mp interface{}) (sql.Result, error) { func (s *Stmt) ExecMapContext(ctx context.Context, mp interface{}) (sql.Result, error) {
vv := reflect.ValueOf(mp) vv := reflect.ValueOf(mp)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map {
@ -59,10 +62,12 @@ func (s *Stmt) ExecMapContext(ctx context.Context, mp interface{}) (sql.Result,
return s.ExecContext(ctx, args...) return s.ExecContext(ctx, args...)
} }
// ExecMap executes with map
func (s *Stmt) ExecMap(mp interface{}) (sql.Result, error) { func (s *Stmt) ExecMap(mp interface{}) (sql.Result, error) {
return s.ExecMapContext(context.Background(), mp) return s.ExecMapContext(context.Background(), mp)
} }
// ExecStructContext executes with struct
func (s *Stmt) ExecStructContext(ctx context.Context, st interface{}) (sql.Result, error) { func (s *Stmt) ExecStructContext(ctx context.Context, st interface{}) (sql.Result, error) {
vv := reflect.ValueOf(st) vv := reflect.ValueOf(st)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
@ -76,10 +81,12 @@ func (s *Stmt) ExecStructContext(ctx context.Context, st interface{}) (sql.Resul
return s.ExecContext(ctx, args...) return s.ExecContext(ctx, args...)
} }
// ExecStruct executes with struct
func (s *Stmt) ExecStruct(st interface{}) (sql.Result, error) { func (s *Stmt) ExecStruct(st interface{}) (sql.Result, error) {
return s.ExecStructContext(context.Background(), st) return s.ExecStructContext(context.Background(), st)
} }
// ExecContext with args
func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error) { func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error) {
hookCtx := contexts.NewContextHook(ctx, s.query, args) hookCtx := contexts.NewContextHook(ctx, s.query, args)
ctx, err := s.db.beforeProcess(hookCtx) ctx, err := s.db.beforeProcess(hookCtx)
@ -94,6 +101,7 @@ func (s *Stmt) ExecContext(ctx context.Context, args ...interface{}) (sql.Result
return res, nil return res, nil
} }
// QueryContext query with args
func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, error) { func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, error) {
hookCtx := contexts.NewContextHook(ctx, s.query, args) hookCtx := contexts.NewContextHook(ctx, s.query, args)
ctx, err := s.db.beforeProcess(hookCtx) ctx, err := s.db.beforeProcess(hookCtx)
@ -108,10 +116,12 @@ func (s *Stmt) QueryContext(ctx context.Context, args ...interface{}) (*Rows, er
return &Rows{rows, s.db}, nil return &Rows{rows, s.db}, nil
} }
// Query query with args
func (s *Stmt) Query(args ...interface{}) (*Rows, error) { func (s *Stmt) Query(args ...interface{}) (*Rows, error) {
return s.QueryContext(context.Background(), args...) return s.QueryContext(context.Background(), args...)
} }
// QueryMapContext query with map
func (s *Stmt) QueryMapContext(ctx context.Context, mp interface{}) (*Rows, error) { func (s *Stmt) QueryMapContext(ctx context.Context, mp interface{}) (*Rows, error) {
vv := reflect.ValueOf(mp) vv := reflect.ValueOf(mp)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map {
@ -126,10 +136,12 @@ func (s *Stmt) QueryMapContext(ctx context.Context, mp interface{}) (*Rows, erro
return s.QueryContext(ctx, args...) return s.QueryContext(ctx, args...)
} }
// QueryMap query with map
func (s *Stmt) QueryMap(mp interface{}) (*Rows, error) { func (s *Stmt) QueryMap(mp interface{}) (*Rows, error) {
return s.QueryMapContext(context.Background(), mp) return s.QueryMapContext(context.Background(), mp)
} }
// QueryStructContext query with struct
func (s *Stmt) QueryStructContext(ctx context.Context, st interface{}) (*Rows, error) { func (s *Stmt) QueryStructContext(ctx context.Context, st interface{}) (*Rows, error) {
vv := reflect.ValueOf(st) vv := reflect.ValueOf(st)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
@ -144,19 +156,23 @@ func (s *Stmt) QueryStructContext(ctx context.Context, st interface{}) (*Rows, e
return s.QueryContext(ctx, args...) return s.QueryContext(ctx, args...)
} }
// QueryStruct query with struct
func (s *Stmt) QueryStruct(st interface{}) (*Rows, error) { func (s *Stmt) QueryStruct(st interface{}) (*Rows, error) {
return s.QueryStructContext(context.Background(), st) return s.QueryStructContext(context.Background(), st)
} }
// QueryRowContext query row with args
func (s *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *Row { func (s *Stmt) QueryRowContext(ctx context.Context, args ...interface{}) *Row {
rows, err := s.QueryContext(ctx, args...) rows, err := s.QueryContext(ctx, args...)
return &Row{rows, err} return &Row{rows, err}
} }
// QueryRow query row with args
func (s *Stmt) QueryRow(args ...interface{}) *Row { func (s *Stmt) QueryRow(args ...interface{}) *Row {
return s.QueryRowContext(context.Background(), args...) return s.QueryRowContext(context.Background(), args...)
} }
// QueryRowMapContext query row with map
func (s *Stmt) QueryRowMapContext(ctx context.Context, mp interface{}) *Row { func (s *Stmt) QueryRowMapContext(ctx context.Context, mp interface{}) *Row {
vv := reflect.ValueOf(mp) vv := reflect.ValueOf(mp)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Map {
@ -171,10 +187,12 @@ func (s *Stmt) QueryRowMapContext(ctx context.Context, mp interface{}) *Row {
return s.QueryRowContext(ctx, args...) return s.QueryRowContext(ctx, args...)
} }
// QueryRowMap query row with map
func (s *Stmt) QueryRowMap(mp interface{}) *Row { func (s *Stmt) QueryRowMap(mp interface{}) *Row {
return s.QueryRowMapContext(context.Background(), mp) return s.QueryRowMapContext(context.Background(), mp)
} }
// QueryRowStructContext query row with struct
func (s *Stmt) QueryRowStructContext(ctx context.Context, st interface{}) *Row { func (s *Stmt) QueryRowStructContext(ctx context.Context, st interface{}) *Row {
vv := reflect.ValueOf(st) vv := reflect.ValueOf(st)
if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct { if vv.Kind() != reflect.Ptr || vv.Elem().Kind() != reflect.Struct {
@ -189,6 +207,7 @@ func (s *Stmt) QueryRowStructContext(ctx context.Context, st interface{}) *Row {
return s.QueryRowContext(ctx, args...) return s.QueryRowContext(ctx, args...)
} }
// QueryRowStruct query row with struct
func (s *Stmt) QueryRowStruct(st interface{}) *Row { func (s *Stmt) QueryRowStruct(st interface{}) *Row {
return s.QueryRowStructContext(context.Background(), st) return s.QueryRowStructContext(context.Background(), st)
} }

35
vendor/xorm.io/xorm/core/tx.go

@ -22,6 +22,7 @@ type Tx struct {
ctx context.Context ctx context.Context
} }
// BeginTx begin a transaction with option
func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) { func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
hookCtx := contexts.NewContextHook(ctx, "BEGIN TRANSACTION", nil) hookCtx := contexts.NewContextHook(ctx, "BEGIN TRANSACTION", nil)
ctx, err := db.beforeProcess(hookCtx) ctx, err := db.beforeProcess(hookCtx)
@ -36,10 +37,12 @@ func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error) {
return &Tx{tx, db, ctx}, nil return &Tx{tx, db, ctx}, nil
} }
// Begin begins a transaction
func (db *DB) Begin() (*Tx, error) { func (db *DB) Begin() (*Tx, error) {
return db.BeginTx(context.Background(), nil) return db.BeginTx(context.Background(), nil)
} }
// Commit submit the transaction
func (tx *Tx) Commit() error { func (tx *Tx) Commit() error {
hookCtx := contexts.NewContextHook(tx.ctx, "COMMIT", nil) hookCtx := contexts.NewContextHook(tx.ctx, "COMMIT", nil)
ctx, err := tx.db.beforeProcess(hookCtx) ctx, err := tx.db.beforeProcess(hookCtx)
@ -48,12 +51,10 @@ func (tx *Tx) Commit() error {
} }
err = tx.Tx.Commit() err = tx.Tx.Commit()
hookCtx.End(ctx, nil, err) hookCtx.End(ctx, nil, err)
if err := tx.db.afterProcess(hookCtx); err != nil {
return err
}
return nil
return tx.db.afterProcess(hookCtx)
} }
// Rollback rollback the transaction
func (tx *Tx) Rollback() error { func (tx *Tx) Rollback() error {
hookCtx := contexts.NewContextHook(tx.ctx, "ROLLBACK", nil) hookCtx := contexts.NewContextHook(tx.ctx, "ROLLBACK", nil)
ctx, err := tx.db.beforeProcess(hookCtx) ctx, err := tx.db.beforeProcess(hookCtx)
@ -62,12 +63,10 @@ func (tx *Tx) Rollback() error {
} }
err = tx.Tx.Rollback() err = tx.Tx.Rollback()
hookCtx.End(ctx, nil, err) hookCtx.End(ctx, nil, err)
if err := tx.db.afterProcess(hookCtx); err != nil {
return err
}
return nil
return tx.db.afterProcess(hookCtx)
} }
// PrepareContext prepare the query
func (tx *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error) { func (tx *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error) {
names := make(map[string]int) names := make(map[string]int)
var i int var i int
@ -89,19 +88,23 @@ func (tx *Tx) PrepareContext(ctx context.Context, query string) (*Stmt, error) {
return &Stmt{stmt, tx.db, names, query}, nil return &Stmt{stmt, tx.db, names, query}, nil
} }
// Prepare prepare the query
func (tx *Tx) Prepare(query string) (*Stmt, error) { func (tx *Tx) Prepare(query string) (*Stmt, error) {
return tx.PrepareContext(context.Background(), query) return tx.PrepareContext(context.Background(), query)
} }
// StmtContext creates Stmt with context
func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt { func (tx *Tx) StmtContext(ctx context.Context, stmt *Stmt) *Stmt {
stmt.Stmt = tx.Tx.StmtContext(ctx, stmt.Stmt) stmt.Stmt = tx.Tx.StmtContext(ctx, stmt.Stmt)
return stmt return stmt
} }
// Stmt creates Stmt
func (tx *Tx) Stmt(stmt *Stmt) *Stmt { func (tx *Tx) Stmt(stmt *Stmt) *Stmt {
return tx.StmtContext(context.Background(), stmt) return tx.StmtContext(context.Background(), stmt)
} }
// ExecMapContext executes query with args in a map
func (tx *Tx) ExecMapContext(ctx context.Context, query string, mp interface{}) (sql.Result, error) { func (tx *Tx) ExecMapContext(ctx context.Context, query string, mp interface{}) (sql.Result, error) {
query, args, err := MapToSlice(query, mp) query, args, err := MapToSlice(query, mp)
if err != nil { if err != nil {
@ -110,10 +113,12 @@ func (tx *Tx) ExecMapContext(ctx context.Context, query string, mp interface{})
return tx.ExecContext(ctx, query, args...) return tx.ExecContext(ctx, query, args...)
} }
// ExecMap executes query with args in a map
func (tx *Tx) ExecMap(query string, mp interface{}) (sql.Result, error) { func (tx *Tx) ExecMap(query string, mp interface{}) (sql.Result, error) {
return tx.ExecMapContext(context.Background(), query, mp) return tx.ExecMapContext(context.Background(), query, mp)
} }
// ExecStructContext executes query with args in a struct
func (tx *Tx) ExecStructContext(ctx context.Context, query string, st interface{}) (sql.Result, error) { func (tx *Tx) ExecStructContext(ctx context.Context, query string, st interface{}) (sql.Result, error) {
query, args, err := StructToSlice(query, st) query, args, err := StructToSlice(query, st)
if err != nil { if err != nil {
@ -122,6 +127,7 @@ func (tx *Tx) ExecStructContext(ctx context.Context, query string, st interface{
return tx.ExecContext(ctx, query, args...) return tx.ExecContext(ctx, query, args...)
} }
// ExecContext executes a query with args
func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) { func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error) {
hookCtx := contexts.NewContextHook(ctx, query, args) hookCtx := contexts.NewContextHook(ctx, query, args)
ctx, err := tx.db.beforeProcess(hookCtx) ctx, err := tx.db.beforeProcess(hookCtx)
@ -136,10 +142,12 @@ func (tx *Tx) ExecContext(ctx context.Context, query string, args ...interface{}
return res, err return res, err
} }
// ExecStruct executes query with args in a struct
func (tx *Tx) ExecStruct(query string, st interface{}) (sql.Result, error) { func (tx *Tx) ExecStruct(query string, st interface{}) (sql.Result, error) {
return tx.ExecStructContext(context.Background(), query, st) return tx.ExecStructContext(context.Background(), query, st)
} }
// QueryContext query with args
func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) { func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{}) (*Rows, error) {
hookCtx := contexts.NewContextHook(ctx, query, args) hookCtx := contexts.NewContextHook(ctx, query, args)
ctx, err := tx.db.beforeProcess(hookCtx) ctx, err := tx.db.beforeProcess(hookCtx)
@ -157,10 +165,12 @@ func (tx *Tx) QueryContext(ctx context.Context, query string, args ...interface{
return &Rows{rows, tx.db}, nil return &Rows{rows, tx.db}, nil
} }
// Query query with args
func (tx *Tx) Query(query string, args ...interface{}) (*Rows, error) { func (tx *Tx) Query(query string, args ...interface{}) (*Rows, error) {
return tx.QueryContext(context.Background(), query, args...) return tx.QueryContext(context.Background(), query, args...)
} }
// QueryMapContext query with args in a map
func (tx *Tx) QueryMapContext(ctx context.Context, query string, mp interface{}) (*Rows, error) { func (tx *Tx) QueryMapContext(ctx context.Context, query string, mp interface{}) (*Rows, error) {
query, args, err := MapToSlice(query, mp) query, args, err := MapToSlice(query, mp)
if err != nil { if err != nil {
@ -169,10 +179,12 @@ func (tx *Tx) QueryMapContext(ctx context.Context, query string, mp interface{})
return tx.QueryContext(ctx, query, args...) return tx.QueryContext(ctx, query, args...)
} }
// QueryMap query with args in a map
func (tx *Tx) QueryMap(query string, mp interface{}) (*Rows, error) { func (tx *Tx) QueryMap(query string, mp interface{}) (*Rows, error) {
return tx.QueryMapContext(context.Background(), query, mp) return tx.QueryMapContext(context.Background(), query, mp)
} }
// QueryStructContext query with args in struct
func (tx *Tx) QueryStructContext(ctx context.Context, query string, st interface{}) (*Rows, error) { func (tx *Tx) QueryStructContext(ctx context.Context, query string, st interface{}) (*Rows, error) {
query, args, err := StructToSlice(query, st) query, args, err := StructToSlice(query, st)
if err != nil { if err != nil {
@ -181,19 +193,23 @@ func (tx *Tx) QueryStructContext(ctx context.Context, query string, st interface
return tx.QueryContext(ctx, query, args...) return tx.QueryContext(ctx, query, args...)
} }
// QueryStruct query with args in struct
func (tx *Tx) QueryStruct(query string, st interface{}) (*Rows, error) { func (tx *Tx) QueryStruct(query string, st interface{}) (*Rows, error) {
return tx.QueryStructContext(context.Background(), query, st) return tx.QueryStructContext(context.Background(), query, st)
} }
// QueryRowContext query one row with args
func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row { func (tx *Tx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *Row {
rows, err := tx.QueryContext(ctx, query, args...) rows, err := tx.QueryContext(ctx, query, args...)
return &Row{rows, err} return &Row{rows, err}
} }
// QueryRow query one row with args
func (tx *Tx) QueryRow(query string, args ...interface{}) *Row { func (tx *Tx) QueryRow(query string, args ...interface{}) *Row {
return tx.QueryRowContext(context.Background(), query, args...) return tx.QueryRowContext(context.Background(), query, args...)
} }
// QueryRowMapContext query one row with args in a map
func (tx *Tx) QueryRowMapContext(ctx context.Context, query string, mp interface{}) *Row { func (tx *Tx) QueryRowMapContext(ctx context.Context, query string, mp interface{}) *Row {
query, args, err := MapToSlice(query, mp) query, args, err := MapToSlice(query, mp)
if err != nil { if err != nil {
@ -202,10 +218,12 @@ func (tx *Tx) QueryRowMapContext(ctx context.Context, query string, mp interface
return tx.QueryRowContext(ctx, query, args...) return tx.QueryRowContext(ctx, query, args...)
} }
// QueryRowMap query one row with args in a map
func (tx *Tx) QueryRowMap(query string, mp interface{}) *Row { func (tx *Tx) QueryRowMap(query string, mp interface{}) *Row {
return tx.QueryRowMapContext(context.Background(), query, mp) return tx.QueryRowMapContext(context.Background(), query, mp)
} }
// QueryRowStructContext query one row with args in struct
func (tx *Tx) QueryRowStructContext(ctx context.Context, query string, st interface{}) *Row { func (tx *Tx) QueryRowStructContext(ctx context.Context, query string, st interface{}) *Row {
query, args, err := StructToSlice(query, st) query, args, err := StructToSlice(query, st)
if err != nil { if err != nil {
@ -214,6 +232,7 @@ func (tx *Tx) QueryRowStructContext(ctx context.Context, query string, st interf
return tx.QueryRowContext(ctx, query, args...) return tx.QueryRowContext(ctx, query, args...)
} }
// QueryRowStruct query one row with args in struct
func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row { func (tx *Tx) QueryRowStruct(query string, st interface{}) *Row {
return tx.QueryRowStructContext(context.Background(), query, st) return tx.QueryRowStructContext(context.Background(), query, st)
} }

38
vendor/xorm.io/xorm/dialects/dialect.go

@ -79,32 +79,34 @@ type Base struct {
quoter schemas.Quoter quoter schemas.Quoter
} }
func (b *Base) Quoter() schemas.Quoter {
return b.quoter
// Quoter returns the current database Quoter
func (db *Base) Quoter() schemas.Quoter {
return db.quoter
} }
func (b *Base) Init(dialect Dialect, uri *URI) error {
b.dialect, b.uri = dialect, uri
// Init initialize the dialect
func (db *Base) Init(dialect Dialect, uri *URI) error {
db.dialect, db.uri = dialect, uri
return nil return nil
} }
func (b *Base) URI() *URI {
return b.uri
// URI returns the uri of database
func (db *Base) URI() *URI {
return db.uri
} }
func (b *Base) DBType() schemas.DBType {
return b.uri.DBType
}
func (b *Base) FormatBytes(bs []byte) string {
// FormatBytes formats bytes
func (db *Base) FormatBytes(bs []byte) string {
return fmt.Sprintf("0x%x", bs) return fmt.Sprintf("0x%x", bs)
} }
// DropTableSQL returns drop table SQL
func (db *Base) DropTableSQL(tableName string) (string, bool) { func (db *Base) DropTableSQL(tableName string) (string, bool) {
quote := db.dialect.Quoter().Quote quote := db.dialect.Quoter().Quote
return fmt.Sprintf("DROP TABLE IF EXISTS %s", quote(tableName)), true return fmt.Sprintf("DROP TABLE IF EXISTS %s", quote(tableName)), true
} }
// HasRecords returns true if the SQL has records returned
func (db *Base) HasRecords(queryer core.Queryer, ctx context.Context, query string, args ...interface{}) (bool, error) { func (db *Base) HasRecords(queryer core.Queryer, ctx context.Context, query string, args ...interface{}) (bool, error) {
rows, err := queryer.QueryContext(ctx, query, args...) rows, err := queryer.QueryContext(ctx, query, args...)
if err != nil { if err != nil {
@ -118,6 +120,7 @@ func (db *Base) HasRecords(queryer core.Queryer, ctx context.Context, query stri
return false, nil return false, nil
} }
// IsColumnExist returns true if the column of the table exist
func (db *Base) IsColumnExist(queryer core.Queryer, ctx context.Context, tableName, colName string) (bool, error) { func (db *Base) IsColumnExist(queryer core.Queryer, ctx context.Context, tableName, colName string) (bool, error) {
quote := db.dialect.Quoter().Quote quote := db.dialect.Quoter().Quote
query := fmt.Sprintf( query := fmt.Sprintf(
@ -132,11 +135,13 @@ func (db *Base) IsColumnExist(queryer core.Queryer, ctx context.Context, tableNa
return db.HasRecords(queryer, ctx, query, db.uri.DBName, tableName, colName) return db.HasRecords(queryer, ctx, query, db.uri.DBName, tableName, colName)
} }
// 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)
return fmt.Sprintf("ALTER TABLE %v ADD %v", db.dialect.Quoter().Quote(tableName), s) return fmt.Sprintf("ALTER TABLE %v ADD %v", db.dialect.Quoter().Quote(tableName), s)
} }
// CreateIndexSQL returns a SQL to create index
func (db *Base) CreateIndexSQL(tableName string, index *schemas.Index) string { func (db *Base) CreateIndexSQL(tableName string, index *schemas.Index) string {
quoter := db.dialect.Quoter() quoter := db.dialect.Quoter()
var unique string var unique string
@ -150,6 +155,7 @@ func (db *Base) CreateIndexSQL(tableName string, index *schemas.Index) string {
quoter.Join(index.Cols, ",")) quoter.Join(index.Cols, ","))
} }
// DropIndexSQL returns a SQL to drop index
func (db *Base) DropIndexSQL(tableName string, index *schemas.Index) string { func (db *Base) DropIndexSQL(tableName string, index *schemas.Index) string {
quote := db.dialect.Quoter().Quote quote := db.dialect.Quoter().Quote
var name string var name string
@ -161,16 +167,19 @@ func (db *Base) DropIndexSQL(tableName string, index *schemas.Index) string {
return fmt.Sprintf("DROP INDEX %v ON %s", quote(name), quote(tableName)) return fmt.Sprintf("DROP INDEX %v ON %s", quote(name), quote(tableName))
} }
// 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)
return fmt.Sprintf("alter table %s MODIFY COLUMN %s", tableName, s)
return fmt.Sprintf("ALTER TABLE %s MODIFY COLUMN %s", tableName, s)
} }
func (b *Base) ForUpdateSQL(query string) string {
// ForUpdateSQL returns for updateSQL
func (db *Base) ForUpdateSQL(query string) string {
return query + " FOR UPDATE" return query + " FOR UPDATE"
} }
func (b *Base) SetParams(params map[string]string) {
// SetParams set params
func (db *Base) SetParams(params map[string]string) {
} }
var ( var (
@ -206,6 +215,7 @@ func regDrvsNDialects() bool {
"postgres": {"postgres", func() Driver { return &pqDriver{} }, func() Dialect { return &postgres{} }}, "postgres": {"postgres", func() Driver { return &pqDriver{} }, func() Dialect { return &postgres{} }},
"pgx": {"postgres", func() Driver { return &pqDriverPgx{} }, func() Dialect { return &postgres{} }}, "pgx": {"postgres", func() Driver { return &pqDriverPgx{} }, func() Dialect { return &postgres{} }},
"sqlite3": {"sqlite3", func() Driver { return &sqlite3Driver{} }, func() Dialect { return &sqlite3{} }}, "sqlite3": {"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{} }},
"goracle": {"oracle", func() Driver { return &goracleDriver{} }, func() Dialect { return &oracle{} }}, "goracle": {"oracle", func() Driver { return &goracleDriver{} }, func() Dialect { return &oracle{} }},
} }

8
vendor/xorm.io/xorm/dialects/driver.go

@ -8,6 +8,7 @@ import (
"fmt" "fmt"
) )
// Driver represents a database driver
type Driver interface { type Driver interface {
Parse(string, string) (*URI, error) Parse(string, string) (*URI, error)
} }
@ -16,6 +17,7 @@ var (
drivers = map[string]Driver{} drivers = map[string]Driver{}
) )
// RegisterDriver register a driver
func RegisterDriver(driverName string, driver Driver) { func RegisterDriver(driverName string, driver Driver) {
if driver == nil { if driver == nil {
panic("core: Register driver is nil") panic("core: Register driver is nil")
@ -26,10 +28,12 @@ func RegisterDriver(driverName string, driver Driver) {
drivers[driverName] = driver drivers[driverName] = driver
} }
// QueryDriver query a driver with name
func QueryDriver(driverName string) Driver { func QueryDriver(driverName string) Driver {
return drivers[driverName] return drivers[driverName]
} }
// RegisteredDriverSize returned all drivers's length
func RegisteredDriverSize() int { func RegisteredDriverSize() int {
return len(drivers) return len(drivers)
} }
@ -38,7 +42,7 @@ func RegisteredDriverSize() int {
func OpenDialect(driverName, connstr string) (Dialect, error) { func OpenDialect(driverName, connstr string) (Dialect, error) {
driver := QueryDriver(driverName) driver := QueryDriver(driverName)
if driver == nil { if driver == nil {
return nil, fmt.Errorf("Unsupported driver name: %v", driverName)
return nil, fmt.Errorf("unsupported driver name: %v", driverName)
} }
uri, err := driver.Parse(driverName, connstr) uri, err := driver.Parse(driverName, connstr)
@ -48,7 +52,7 @@ func OpenDialect(driverName, connstr string) (Dialect, error) {
dialect := QueryDialect(uri.DBType) dialect := QueryDialect(uri.DBType)
if dialect == nil { if dialect == nil {
return nil, fmt.Errorf("Unsupported dialect type: %v", uri.DBType)
return nil, fmt.Errorf("unsupported dialect type: %v", uri.DBType)
} }
dialect.Init(uri) dialect.Init(uri)

1
vendor/xorm.io/xorm/dialects/filter.go

@ -38,6 +38,7 @@ func convertQuestionMark(sql, prefix string, start int) string {
return buf.String() return buf.String()
} }
// Do implements Filter
func (s *SeqFilter) Do(sql string) string { func (s *SeqFilter) Do(sql string) string {
return convertQuestionMark(sql, s.Prefix, s.Start) return convertQuestionMark(sql, s.Prefix, s.Start)
} }

13
vendor/xorm.io/xorm/dialects/mssql.go

@ -220,6 +220,8 @@ type mssql struct {
func (db *mssql) Init(uri *URI) error { func (db *mssql) Init(uri *URI) error {
db.quoter = mssqlQuoter db.quoter = mssqlQuoter
db.defaultChar = "CHAR"
db.defaultVarchar = "VARCHAR"
return db.Base.Init(db, uri) return db.Base.Init(db, uri)
} }
@ -282,7 +284,7 @@ func (db *mssql) SQLType(c *schemas.Column) string {
case schemas.TimeStampz: case schemas.TimeStampz:
res = "DATETIMEOFFSET" res = "DATETIMEOFFSET"
c.Length = 7 c.Length = 7
case schemas.MediumInt:
case schemas.MediumInt, schemas.UnsignedInt:
res = schemas.Int res = schemas.Int
case schemas.Text, schemas.MediumText, schemas.TinyText, schemas.LongText, schemas.Json: case schemas.Text, schemas.MediumText, schemas.TinyText, schemas.LongText, schemas.Json:
res = db.defaultVarchar + "(MAX)" res = db.defaultVarchar + "(MAX)"
@ -294,7 +296,7 @@ func (db *mssql) SQLType(c *schemas.Column) string {
case schemas.TinyInt: case schemas.TinyInt:
res = schemas.TinyInt res = schemas.TinyInt
c.Length = 0 c.Length = 0
case schemas.BigInt:
case schemas.BigInt, schemas.UnsignedBigInt:
res = schemas.BigInt res = schemas.BigInt
c.Length = 0 c.Length = 0
case schemas.NVarchar: case schemas.NVarchar:
@ -368,6 +370,11 @@ func (db *mssql) DropTableSQL(tableName string) (string, bool) {
"DROP TABLE \"%s\"", tableName, tableName), true "DROP TABLE \"%s\"", tableName, tableName), true
} }
func (db *mssql) ModifyColumnSQL(tableName string, col *schemas.Column) string {
s, _ := ColumnString(db.dialect, col, false)
return fmt.Sprintf("ALTER TABLE %s ALTER COLUMN %s", tableName, s)
}
func (db *mssql) IndexCheckSQL(tableName, idxName string) (string, []interface{}) { func (db *mssql) IndexCheckSQL(tableName, idxName string) (string, []interface{}) {
args := []interface{}{idxName} args := []interface{}{idxName}
sql := "select name from sysindexes where id=object_id('" + tableName + "') and name=?" sql := "select name from sysindexes where id=object_id('" + tableName + "') and name=?"
@ -533,7 +540,7 @@ WHERE IXS.TYPE_DESC='NONCLUSTERED' and OBJECT_NAME(IXS.OBJECT_ID) =?
colName = strings.Trim(colName, "` ") colName = strings.Trim(colName, "` ")
var isRegular bool var isRegular bool
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
if (strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName)) && len(indexName) > (5+len(tableName)) {
indexName = indexName[5+len(tableName):] indexName = indexName[5+len(tableName):]
isRegular = true isRegular = true
} }

31
vendor/xorm.io/xorm/dialects/mysql.go

@ -254,6 +254,10 @@ func (db *mysql) SQLType(c *schemas.Column) string {
c.Length = 40 c.Length = 40
case schemas.Json: case schemas.Json:
res = schemas.Text res = schemas.Text
case schemas.UnsignedInt:
res = schemas.Int
case schemas.UnsignedBigInt:
res = schemas.BigInt
default: default:
res = t res = t
} }
@ -271,6 +275,11 @@ func (db *mysql) SQLType(c *schemas.Column) string {
} else if hasLen1 { } else if hasLen1 {
res += "(" + strconv.Itoa(c.Length) + ")" res += "(" + strconv.Itoa(c.Length) + ")"
} }
if c.SQLType.Name == schemas.UnsignedBigInt || c.SQLType.Name == schemas.UnsignedInt {
res += " UNSIGNED"
}
return res return res
} }
@ -331,16 +340,16 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
col := new(schemas.Column) col := new(schemas.Column)
col.Indexes = make(map[string]int) col.Indexes = make(map[string]int)
var columnName, isNullable, colType, colKey, extra, comment string
var alreadyQuoted bool
var columnName, nullableStr, colType, colKey, extra, comment string
var alreadyQuoted, isUnsigned bool
var colDefault *string var colDefault *string
err = rows.Scan(&columnName, &isNullable, &colDefault, &colType, &colKey, &extra, &comment, &alreadyQuoted)
err = rows.Scan(&columnName, &nullableStr, &colDefault, &colType, &colKey, &extra, &comment, &alreadyQuoted)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
col.Name = strings.Trim(columnName, "` ") col.Name = strings.Trim(columnName, "` ")
col.Comment = comment col.Comment = comment
if "YES" == isNullable {
if nullableStr == "YES" {
col.Nullable = true col.Nullable = true
} }
@ -351,8 +360,15 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
col.DefaultIsEmpty = true col.DefaultIsEmpty = true
} }
fields := strings.Fields(colType)
if len(fields) == 2 && fields[1] == "unsigned" {
isUnsigned = true
}
colType = fields[0]
cts := strings.Split(colType, "(") cts := strings.Split(colType, "(")
colName := cts[0] colName := cts[0]
// Remove the /* mariadb-5.3 */ suffix from coltypes
colName = strings.TrimSuffix(colName, "/* mariadb-5.3 */")
colType = strings.ToUpper(colName) colType = strings.ToUpper(colName)
var len1, len2 int var len1, len2 int
if len(cts) == 2 { if len(cts) == 2 {
@ -387,11 +403,8 @@ func (db *mysql) GetColumns(queryer core.Queryer, ctx context.Context, tableName
} }
} }
} }
if colType == "FLOAT UNSIGNED" {
colType = "FLOAT"
}
if colType == "DOUBLE UNSIGNED" {
colType = "DOUBLE"
if isUnsigned {
colType = "UNSIGNED " + colType
} }
col.Length = len1 col.Length = len1
col.Length2 = len2 col.Length2 = len2

13
vendor/xorm.io/xorm/dialects/postgres.go

@ -824,6 +824,11 @@ func (db *postgres) SetQuotePolicy(quotePolicy QuotePolicy) {
} }
} }
// FormatBytes formats bytes
func (db *postgres) FormatBytes(bs []byte) string {
return fmt.Sprintf("E'\\x%x'", bs)
}
func (db *postgres) SQLType(c *schemas.Column) string { func (db *postgres) SQLType(c *schemas.Column) string {
var res string var res string
switch t := c.SQLType.Name; t { switch t := c.SQLType.Name; t {
@ -833,12 +838,12 @@ func (db *postgres) SQLType(c *schemas.Column) string {
case schemas.Bit: case schemas.Bit:
res = schemas.Boolean res = schemas.Boolean
return res return res
case schemas.MediumInt, schemas.Int, schemas.Integer:
case schemas.MediumInt, schemas.Int, schemas.Integer, schemas.UnsignedInt:
if c.IsAutoIncrement { if c.IsAutoIncrement {
return schemas.Serial return schemas.Serial
} }
return schemas.Integer return schemas.Integer
case schemas.BigInt:
case schemas.BigInt, schemas.UnsignedBigInt:
if c.IsAutoIncrement { if c.IsAutoIncrement {
return schemas.BigSerial return schemas.BigSerial
} }
@ -1052,6 +1057,10 @@ WHERE n.nspname= s.table_schema AND c.relkind = 'r'::char AND c.relname = $1%s A
} }
} }
if colDefault != nil && *colDefault == "unique_rowid()" { // ignore the system column added by cockroach
continue
}
col.Name = strings.Trim(colName, `" `) col.Name = strings.Trim(colName, `" `)
if colDefault != nil { if colDefault != nil {

5
vendor/xorm.io/xorm/dialects/sqlite3.go

@ -193,7 +193,8 @@ func (db *sqlite3) SQLType(c *schemas.Column) string {
case schemas.Char, schemas.Varchar, schemas.NVarchar, schemas.TinyText, case schemas.Char, schemas.Varchar, schemas.NVarchar, schemas.TinyText,
schemas.Text, schemas.MediumText, schemas.LongText, schemas.Json: schemas.Text, schemas.MediumText, schemas.LongText, schemas.Json:
return schemas.Text return schemas.Text
case schemas.Bit, schemas.TinyInt, schemas.SmallInt, schemas.MediumInt, schemas.Int, schemas.Integer, schemas.BigInt:
case schemas.Bit, schemas.TinyInt, schemas.SmallInt, schemas.MediumInt, schemas.Int, schemas.Integer, schemas.BigInt,
schemas.UnsignedBigInt, schemas.UnsignedInt:
return schemas.Integer return schemas.Integer
case schemas.Float, schemas.Double, schemas.Real: case schemas.Float, schemas.Double, schemas.Real:
return schemas.Real return schemas.Real
@ -483,7 +484,7 @@ func (db *sqlite3) GetIndexes(queryer core.Queryer, ctx context.Context, tableNa
continue continue
} }
indexName := strings.Trim(sql[nNStart+6:nNEnd], "` []'\"")
indexName := strings.Trim(strings.TrimSpace(sql[nNStart+6:nNEnd]), "`[]'\"")
var isRegular bool var isRegular bool
if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) { if strings.HasPrefix(indexName, "IDX_"+tableName) || strings.HasPrefix(indexName, "UQE_"+tableName) {
index.Name = indexName[5+len(tableName):] index.Name = indexName[5+len(tableName):]

7
vendor/xorm.io/xorm/dialects/time.go

@ -19,7 +19,11 @@ func FormatTime(dialect Dialect, sqlTypeName string, t time.Time) (v interface{}
case schemas.Date: case schemas.Date:
v = t.Format("2006-01-02") v = t.Format("2006-01-02")
case schemas.DateTime, schemas.TimeStamp, schemas.Varchar: // !DarthPestilane! format time when sqlTypeName is schemas.Varchar. case schemas.DateTime, schemas.TimeStamp, schemas.Varchar: // !DarthPestilane! format time when sqlTypeName is schemas.Varchar.
v = t.Format("2006-01-02 15:04:05")
if dialect.URI().DBType == schemas.ORACLE {
v = t
} else {
v = t.Format("2006-01-02 15:04:05")
}
case schemas.TimeStampz: case schemas.TimeStampz:
if dialect.URI().DBType == schemas.MSSQL { if dialect.URI().DBType == schemas.MSSQL {
v = t.Format("2006-01-02T15:04:05.9999999Z07:00") v = t.Format("2006-01-02T15:04:05.9999999Z07:00")
@ -34,6 +38,7 @@ func FormatTime(dialect Dialect, sqlTypeName string, t time.Time) (v interface{}
return return
} }
// FormatColumnTime format column time
func FormatColumnTime(dialect Dialect, defaultTimeZone *time.Location, col *schemas.Column, t time.Time) (v interface{}) { func FormatColumnTime(dialect Dialect, defaultTimeZone *time.Location, col *schemas.Column, t time.Time) (v interface{}) {
if t.IsZero() { if t.IsZero() {
if col.Nullable { if col.Nullable {

182
vendor/xorm.io/xorm/engine.go

@ -21,6 +21,7 @@ import (
"xorm.io/xorm/contexts" "xorm.io/xorm/contexts"
"xorm.io/xorm/core" "xorm.io/xorm/core"
"xorm.io/xorm/dialects" "xorm.io/xorm/dialects"
"xorm.io/xorm/internal/json"
"xorm.io/xorm/internal/utils" "xorm.io/xorm/internal/utils"
"xorm.io/xorm/log" "xorm.io/xorm/log"
"xorm.io/xorm/names" "xorm.io/xorm/names"
@ -61,6 +62,10 @@ func NewEngine(driverName string, dataSourceName string) (*Engine, error) {
return nil, err return nil, err
} }
return newEngine(driverName, dataSourceName, dialect, db)
}
func newEngine(driverName, dataSourceName string, dialect dialects.Dialect, db *core.DB) (*Engine, error) {
cacherMgr := caches.NewManager() cacherMgr := caches.NewManager()
mapper := names.NewCacheMapper(new(names.SnakeMapper)) mapper := names.NewCacheMapper(new(names.SnakeMapper))
tagParser := tags.NewParser("xorm", dialect, mapper, mapper, cacherMgr) tagParser := tags.NewParser("xorm", dialect, mapper, mapper, cacherMgr)
@ -88,7 +93,7 @@ func NewEngine(driverName string, dataSourceName string) (*Engine, error) {
engine.SetLogger(log.NewLoggerAdapter(logger)) engine.SetLogger(log.NewLoggerAdapter(logger))
runtime.SetFinalizer(engine, func(engine *Engine) { runtime.SetFinalizer(engine, func(engine *Engine) {
engine.Close()
_ = engine.Close()
}) })
return engine, nil return engine, nil
@ -101,6 +106,23 @@ func NewEngineWithParams(driverName string, dataSourceName string, params map[st
return engine, err return engine, err
} }
// NewEngineWithDB new a db manager with db. The params will be passed to db.
func NewEngineWithDB(driverName string, dataSourceName string, db *core.DB) (*Engine, error) {
dialect, err := dialects.OpenDialect(driverName, dataSourceName)
if err != nil {
return nil, err
}
return newEngine(driverName, dataSourceName, dialect, db)
}
// NewEngineWithDialectAndDB new a db manager according to the parameter.
// If you do not want to use your own dialect or db, please use NewEngine.
// For creating dialect, you can call dialects.OpenDialect. And, for creating db,
// you can call core.Open or core.FromDB.
func NewEngineWithDialectAndDB(driverName, dataSourceName string, dialect dialects.Dialect, db *core.DB) (*Engine, error) {
return newEngine(driverName, dataSourceName, dialect, db)
}
// EnableSessionID if enable session id // EnableSessionID if enable session id
func (engine *Engine) EnableSessionID(enable bool) { func (engine *Engine) EnableSessionID(enable bool) {
engine.logSessionID = enable engine.logSessionID = enable
@ -147,6 +169,8 @@ func (engine *Engine) SetLogger(logger interface{}) {
realLogger = t realLogger = t
case log.Logger: case log.Logger:
realLogger = log.NewLoggerAdapter(t) realLogger = log.NewLoggerAdapter(t)
default:
panic("logger should implement either log.ContextLogger or log.Logger")
} }
engine.logger = realLogger engine.logger = realLogger
engine.DB().Logger = realLogger engine.DB().Logger = realLogger
@ -188,6 +212,11 @@ func (engine *Engine) SetColumnMapper(mapper names.Mapper) {
engine.tagParser.SetColumnMapper(mapper) engine.tagParser.SetColumnMapper(mapper)
} }
// SetTagIdentifier set the tag identifier
func (engine *Engine) SetTagIdentifier(tagIdentifier string) {
engine.tagParser.SetIdentifier(tagIdentifier)
}
// Quote Use QuoteStr quote the string sql // Quote Use QuoteStr quote the string sql
func (engine *Engine) Quote(value string) string { func (engine *Engine) Quote(value string) string {
value = strings.TrimSpace(value) value = strings.TrimSpace(value)
@ -347,13 +376,16 @@ func (engine *Engine) loadTableInfo(table *schemas.Table) error {
var seq int var seq int
for _, index := range indexes { for _, index := range indexes {
for _, name := range index.Cols { for _, name := range index.Cols {
parts := strings.Split(name, " ")
parts := strings.Split(strings.TrimSpace(name), " ")
if len(parts) > 1 { if len(parts) > 1 {
if parts[1] == "DESC" { if parts[1] == "DESC" {
seq = 1 seq = 1
} else if parts[1] == "ASC" {
seq = 0
} }
} }
if col := table.GetColumn(parts[0]); col != nil {
var colName = strings.Trim(parts[0], `"`)
if col := table.GetColumn(colName); col != nil {
col.Indexes[index.Name] = index.Type col.Indexes[index.Name] = index.Type
} else { } else {
return fmt.Errorf("Unknown col %s seq %d, in index %v of table %v, columns %v", name, seq, index.Name, table.Name, table.ColumnsSeq()) return fmt.Errorf("Unknown col %s seq %d, in index %v of table %v, columns %v", name, seq, index.Name, table.Name, table.ColumnsSeq())
@ -426,9 +458,26 @@ func formatColumnValue(dstDialect dialects.Dialect, d interface{}, col *schemas.
} }
if col.SQLType.IsText() { if col.SQLType.IsText() {
var v = fmt.Sprintf("%s", d)
var v string
switch reflect.TypeOf(d).Kind() {
case reflect.Struct, reflect.Array, reflect.Slice, reflect.Map:
bytes, err := json.DefaultJSONHandler.Marshal(d)
if err != nil {
v = fmt.Sprintf("%s", d)
} else {
v = string(bytes)
}
default:
v = fmt.Sprintf("%s", d)
}
return "'" + strings.Replace(v, "'", "''", -1) + "'" return "'" + strings.Replace(v, "'", "''", -1) + "'"
} else if col.SQLType.IsTime() { } else if col.SQLType.IsTime() {
if dstDialect.URI().DBType == schemas.MSSQL && col.SQLType.Name == schemas.DateTime {
if t, ok := d.(time.Time); ok {
return "'" + t.UTC().Format("2006-01-02 15:04:05") + "'"
}
}
var v = fmt.Sprintf("%s", d) var v = fmt.Sprintf("%s", d)
if strings.HasSuffix(v, " +0000 UTC") { if strings.HasSuffix(v, " +0000 UTC") {
return fmt.Sprintf("'%s'", v[0:len(v)-len(" +0000 UTC")]) return fmt.Sprintf("'%s'", v[0:len(v)-len(" +0000 UTC")])
@ -460,7 +509,7 @@ func formatColumnValue(dstDialect dialects.Dialect, d interface{}, col *schemas.
} }
return fmt.Sprintf("%v", strconv.FormatBool(v)) return fmt.Sprintf("%v", strconv.FormatBool(v))
} }
return fmt.Sprintf("%v", d)
return fmt.Sprintf("%d", d)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
if col.SQLType.Name == schemas.Bool { if col.SQLType.Name == schemas.Bool {
v := reflect.ValueOf(d).Uint() > 0 v := reflect.ValueOf(d).Uint() > 0
@ -472,7 +521,7 @@ func formatColumnValue(dstDialect dialects.Dialect, d interface{}, col *schemas.
} }
return fmt.Sprintf("%v", strconv.FormatBool(v)) return fmt.Sprintf("%v", strconv.FormatBool(v))
} }
return fmt.Sprintf("%v", d)
return fmt.Sprintf("%d", d)
default: default:
return fmt.Sprintf("%v", d) return fmt.Sprintf("%v", d)
} }
@ -506,6 +555,8 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
} }
dstDialect.Init(&destURI) dstDialect.Init(&destURI)
} }
cacherMgr := caches.NewManager()
dstTableCache := tags.NewParser("xorm", dstDialect, engine.GetTableMapper(), engine.GetColumnMapper(), cacherMgr)
_, err := io.WriteString(w, fmt.Sprintf("/*Generated by xorm %s, from %s to %s*/\n\n", _, err := io.WriteString(w, fmt.Sprintf("/*Generated by xorm %s, from %s to %s*/\n\n",
time.Now().In(engine.TZLocation).Format("2006-01-02 15:04:05"), engine.dialect.URI().DBType, dstDialect.URI().DBType)) time.Now().In(engine.TZLocation).Format("2006-01-02 15:04:05"), engine.dialect.URI().DBType, dstDialect.URI().DBType))
@ -514,9 +565,18 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
} }
for i, table := range tables { for i, table := range tables {
tableName := table.Name
dstTable := table
if table.Type != nil {
dstTable, err = dstTableCache.Parse(reflect.New(table.Type).Elem())
if err != nil {
engine.logger.Errorf("Unable to infer table for %s in new dialect. Error: %v", table.Name)
dstTable = table
}
}
dstTableName := dstTable.Name
if dstDialect.URI().Schema != "" { if dstDialect.URI().Schema != "" {
tableName = fmt.Sprintf("%s.%s", dstDialect.URI().Schema, table.Name)
dstTableName = fmt.Sprintf("%s.%s", dstDialect.URI().Schema, dstTable.Name)
} }
originalTableName := table.Name originalTableName := table.Name
if engine.dialect.URI().Schema != "" { if engine.dialect.URI().Schema != "" {
@ -528,27 +588,30 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
return err return err
} }
} }
sqls, _ := dstDialect.CreateTableSQL(table, tableName)
sqls, _ := dstDialect.CreateTableSQL(dstTable, dstTableName)
for _, s := range sqls { for _, s := range sqls {
_, err = io.WriteString(w, s+";\n") _, err = io.WriteString(w, s+";\n")
if err != nil { if err != nil {
return err return err
} }
} }
if len(table.PKColumns()) > 0 && dstDialect.URI().DBType == schemas.MSSQL {
fmt.Fprintf(w, "SET IDENTITY_INSERT [%s] ON;\n", table.Name)
if len(dstTable.PKColumns()) > 0 && dstDialect.URI().DBType == schemas.MSSQL {
fmt.Fprintf(w, "SET IDENTITY_INSERT [%s] ON;\n", dstTable.Name)
} }
for _, index := range table.Indexes {
_, err = io.WriteString(w, dstDialect.CreateIndexSQL(table.Name, index)+";\n")
for _, index := range dstTable.Indexes {
_, err = io.WriteString(w, dstDialect.CreateIndexSQL(dstTable.Name, index)+";\n")
if err != nil { if err != nil {
return err return err
} }
} }
cols := table.ColumnsSeq() cols := table.ColumnsSeq()
dstCols := dstTable.ColumnsSeq()
colNames := engine.dialect.Quoter().Join(cols, ", ") colNames := engine.dialect.Quoter().Join(cols, ", ")
destColNames := dstDialect.Quoter().Join(cols, ", ")
destColNames := dstDialect.Quoter().Join(dstCols, ", ")
rows, err := engine.DB().QueryContext(engine.defaultContext, "SELECT "+colNames+" FROM "+engine.Quote(originalTableName)) rows, err := engine.DB().QueryContext(engine.defaultContext, "SELECT "+colNames+" FROM "+engine.Quote(originalTableName))
if err != nil { if err != nil {
@ -556,35 +619,83 @@ func (engine *Engine) dumpTables(tables []*schemas.Table, w io.Writer, tp ...sch
} }
defer rows.Close() defer rows.Close()
for rows.Next() {
dest := make([]interface{}, len(cols))
err = rows.ScanSlice(&dest)
if err != nil {
return err
}
if table.Type != nil {
sess := engine.NewSession()
defer sess.Close()
for rows.Next() {
beanValue := reflect.New(table.Type)
bean := beanValue.Interface()
fields, err := rows.Columns()
if err != nil {
return err
}
scanResults, err := sess.row2Slice(rows, fields, bean)
if err != nil {
return err
}
_, err = io.WriteString(w, "INSERT INTO "+dstDialect.Quoter().Quote(tableName)+" ("+destColNames+") VALUES (")
if err != nil {
return err
}
dataStruct := utils.ReflectValue(bean)
_, err = sess.slice2Bean(scanResults, fields, bean, &dataStruct, table)
if err != nil {
return err
}
var temp string
for i, d := range dest {
col := table.GetColumn(cols[i])
if col == nil {
return errors.New("unknow column error")
_, err = io.WriteString(w, "INSERT INTO "+dstDialect.Quoter().Quote(dstTableName)+" ("+destColNames+") VALUES (")
if err != nil {
return err
}
var temp string
for _, d := range dstCols {
col := table.GetColumn(d)
if col == nil {
return errors.New("unknown column error")
}
fields := strings.Split(col.FieldName, ".")
field := dataStruct
for _, fieldName := range fields {
field = field.FieldByName(fieldName)
}
temp += "," + formatColumnValue(dstDialect, field.Interface(), col)
}
_, err = io.WriteString(w, temp[1:]+");\n")
if err != nil {
return err
} }
temp += "," + formatColumnValue(dstDialect, d, col)
} }
_, err = io.WriteString(w, temp[1:]+");\n")
if err != nil {
return err
} else {
for rows.Next() {
dest := make([]interface{}, len(cols))
err = rows.ScanSlice(&dest)
if err != nil {
return err
}
_, err = io.WriteString(w, "INSERT INTO "+dstDialect.Quoter().Quote(dstTableName)+" ("+destColNames+") VALUES (")
if err != nil {
return err
}
var temp string
for i, d := range dest {
col := table.GetColumn(cols[i])
if col == nil {
return errors.New("unknow column error")
}
temp += "," + formatColumnValue(dstDialect, d, col)
}
_, err = io.WriteString(w, temp[1:]+");\n")
if err != nil {
return err
}
} }
} }
// FIXME: Hack for postgres // FIXME: Hack for postgres
if dstDialect.URI().DBType == schemas.POSTGRES && table.AutoIncrColumn() != nil { if dstDialect.URI().DBType == schemas.POSTGRES && table.AutoIncrColumn() != nil {
_, err = io.WriteString(w, "SELECT setval('"+tableName+"_id_seq', COALESCE((SELECT MAX("+table.AutoIncrColumn().Name+") + 1 FROM "+dstDialect.Quoter().Quote(tableName)+"), 1), false);\n")
_, err = io.WriteString(w, "SELECT setval('"+dstTableName+"_id_seq', COALESCE((SELECT MAX("+table.AutoIncrColumn().Name+") + 1 FROM "+dstDialect.Quoter().Quote(dstTableName)+"), 1), false);\n")
if err != nil { if err != nil {
return err return err
} }
@ -1247,6 +1358,7 @@ func (engine *Engine) SetSchema(schema string) {
engine.dialect.URI().SetSchema(schema) engine.dialect.URI().SetSchema(schema)
} }
// AddHook adds a context Hook
func (engine *Engine) AddHook(hook contexts.Hook) { func (engine *Engine) AddHook(hook contexts.Hook) {
engine.db.AddHook(hook) engine.db.AddHook(hook)
} }
@ -1262,7 +1374,7 @@ func (engine *Engine) tbNameWithSchema(v string) string {
return dialects.TableNameWithSchema(engine.dialect, v) return dialects.TableNameWithSchema(engine.dialect, v)
} }
// ContextHook creates a session with the context
// Context creates a session with the context
func (engine *Engine) Context(ctx context.Context) *Session { func (engine *Engine) Context(ctx context.Context) *Session {
session := engine.NewSession() session := engine.NewSession()
session.isAutoClose = true session.isAutoClose = true

11
vendor/xorm.io/xorm/engine_group.go

@ -79,7 +79,7 @@ func (eg *EngineGroup) Close() error {
return nil return nil
} }
// ContextHook returned a group session
// Context returned a group session
func (eg *EngineGroup) Context(ctx context.Context) *Session { func (eg *EngineGroup) Context(ctx context.Context) *Session {
sess := eg.NewSession() sess := eg.NewSession()
sess.isAutoClose = true sess.isAutoClose = true
@ -144,6 +144,7 @@ func (eg *EngineGroup) SetLogger(logger interface{}) {
} }
} }
// AddHook adds Hook
func (eg *EngineGroup) AddHook(hook contexts.Hook) { func (eg *EngineGroup) AddHook(hook contexts.Hook) {
eg.Engine.AddHook(hook) eg.Engine.AddHook(hook)
for i := 0; i < len(eg.slaves); i++ { for i := 0; i < len(eg.slaves); i++ {
@ -167,6 +168,14 @@ func (eg *EngineGroup) SetMapper(mapper names.Mapper) {
} }
} }
// SetTagIdentifier set the tag identifier
func (eg *EngineGroup) SetTagIdentifier(tagIdentifier string) {
eg.Engine.SetTagIdentifier(tagIdentifier)
for i := 0; i < len(eg.slaves); i++ {
eg.slaves[i].SetTagIdentifier(tagIdentifier)
}
}
// SetMaxIdleConns set the max idle connections on pool, default is 2 // SetMaxIdleConns set the max idle connections on pool, default is 2
func (eg *EngineGroup) SetMaxIdleConns(conns int) { func (eg *EngineGroup) SetMaxIdleConns(conns int) {
eg.Engine.DB().SetMaxIdleConns(conns) eg.Engine.DB().SetMaxIdleConns(conns)

9
vendor/xorm.io/xorm/go.mod

@ -1,14 +1,15 @@
module xorm.io/xorm module xorm.io/xorm
go 1.11
go 1.13
require ( require (
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc
github.com/denisenkom/go-mssqldb v0.9.0
github.com/go-sql-driver/mysql v1.5.0 github.com/go-sql-driver/mysql v1.5.0
github.com/lib/pq v1.7.0 github.com/lib/pq v1.7.0
github.com/mattn/go-sqlite3 v1.14.0
github.com/mattn/go-sqlite3 v1.14.6
github.com/stretchr/testify v1.4.0 github.com/stretchr/testify v1.4.0
github.com/syndtr/goleveldb v1.0.0 github.com/syndtr/goleveldb v1.0.0
github.com/ziutek/mymysql v1.5.4 github.com/ziutek/mymysql v1.5.4
xorm.io/builder v0.3.7
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84
xorm.io/builder v0.3.8
) )

94
vendor/xorm.io/xorm/go.sum

@ -1,11 +1,11 @@
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=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc h1:VRRKCwnzqk8QCaRC4os14xoKDdbHqqlJtJA0oc1ZAjg=
github.com/denisenkom/go-mssqldb v0.0.0-20200428022330-06a60b6afbbc/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/denisenkom/go-mssqldb v0.9.0 h1:RSohk2RsiZqLZ0zCjtfn3S4Gp4exhpBWHyQ7D0yGjAk=
github.com/denisenkom/go-mssqldb v0.9.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs= github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
@ -16,12 +16,18 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db h1:woRePGFeVFfLKN/pOkfl+p/TAqKOfFu+7KPlMVpok/w=
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.3 h1:x95R7cp+rSeeqAMI2knLtQ0DKlaBhv2NrtrOvafPHRo=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
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/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY= github.com/lib/pq v1.7.0 h1:h93mCPfUSkaul3Ka/VG8uZdmW1uMHDGxzu0NWHuJmHY=
github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.7.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.14.6 h1:dNPt6NO46WmLVt2DLNpwczCmdV5boIZ6g/tlDrlRUbg=
github.com/mattn/go-sqlite3 v1.14.6/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@ -29,34 +35,53 @@ github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk=
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
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/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
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 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
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/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/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs= github.com/ziutek/mymysql v1.5.4 h1:GB0qdRGsTwQSBVYuVShFBKaXSnSnYYC2d9knnE1LHFs=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
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=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e h1:o3PsSEY8E4eXWkXrIP9YJALUkVZqzHJT5DOasTyn8Vs=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78 h1:M8tBwCtWD/cZV9DZpFYRUgaymAYAr+aIUTWzDaM3uPs=
golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
@ -66,5 +91,32 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWD
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 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
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=
xorm.io/builder v0.3.7 h1:2pETdKRK+2QG4mLX4oODHEhn5Z8j1m8sXa7jfu+/SZI=
xorm.io/builder v0.3.7/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=
modernc.org/cc/v3 v3.31.5-0.20210308123301-7a3e9dab9009 h1:u0oCo5b9wyLr++HF3AN9JicGhkUxJhMz51+8TIZH9N0=
modernc.org/cc/v3 v3.31.5-0.20210308123301-7a3e9dab9009/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878=
modernc.org/ccgo/v3 v3.9.0 h1:JbcEIqjw4Agf+0g3Tc85YvfYqkkFOv6xBwS4zkfqSoA=
modernc.org/ccgo/v3 v3.9.0/go.mod h1:nQbgkn8mwzPdp4mm6BT6+p85ugQ7FrGgIcYaE7nSrpY=
modernc.org/httpfs v1.0.6 h1:AAgIpFZRXuYnkjftxTAZwMIiwEqAfk8aVB2/oA6nAeM=
modernc.org/httpfs v1.0.6/go.mod h1:7dosgurJGp0sPaRanU53W4xZYKh14wfzX420oZADeHM=
modernc.org/libc v1.7.13-0.20210308123627-12f642a52bb8/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/libc v1.8.0 h1:Pp4uv9g0csgBMpGPABKtkieF6O5MGhfGo6ZiOdlYfR8=
modernc.org/libc v1.8.0/go.mod h1:U1eq8YWr/Kc1RWCMFUWEdkTg8OTcfLw2kY8EDwl039w=
modernc.org/mathutil v1.1.1/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/mathutil v1.2.2 h1:+yFk8hBprV+4c0U9GjFtL+dV3N8hOJ8JCituQcMShFY=
modernc.org/mathutil v1.2.2/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
modernc.org/memory v1.0.4 h1:utMBrFcpnQDdNsmM6asmyH/FM9TqLPS7XF7otpJmrwM=
modernc.org/memory v1.0.4/go.mod h1:nV2OApxradM3/OVbs2/0OsP6nPfakXpi50C7dcoHXlc=
modernc.org/opt v0.1.1 h1:/0RX92k9vwVeDXj+Xn23DKp2VJubL7k8qNffND6qn3A=
modernc.org/opt v0.1.1/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84 h1:rgEUzE849tFlHSoeCrKyS9cZAljC+DY7MdMHKq6R6sY=
modernc.org/sqlite v1.10.1-0.20210314190707-798bbeb9bb84/go.mod h1:PGzq6qlhyYjL6uVbSgS6WoF7ZopTW/sI7+7p+mb4ZVU=
modernc.org/strutil v1.1.0 h1:+1/yCzZxY2pZwwrsbH+4T7BQMoLQ9QiBshRC9eicYsc=
modernc.org/strutil v1.1.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/tcl v1.5.0 h1:euZSUNfE0Fd4W8VqXI1Ly1v7fqDJoBuAV88Ea+SnaSs=
modernc.org/tcl v1.5.0/go.mod h1:gb57hj4pO8fRrK54zveIfFXBaMHK3SKJNWcmRw1cRzc=
modernc.org/token v1.0.0 h1:a0jaWiNMDhDUtqOj09wvjWWAqd3q7WpBulmL9H2egsk=
modernc.org/token v1.0.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
modernc.org/z v1.0.1-0.20210308123920-1f282aa71362/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
modernc.org/z v1.0.1 h1:WyIDpEpAIx4Hel6q/Pcgj/VhaQV5XPJ2I6ryIYbjnpc=
modernc.org/z v1.0.1/go.mod h1:8/SRk5C/HgiQWCgXdfpb+1RvhORdkz5sw72d3jjtyqA=
xorm.io/builder v0.3.8 h1:P/wPgRqa9kX5uE0aA1/ukJ23u9KH0aSRpHLwDKXigSE=
xorm.io/builder v0.3.8/go.mod h1:aUW0S9eb9VCaPohFCH3j7czOx1PMW3i1HrSzbLYGBSE=

1
vendor/xorm.io/xorm/interface.go

@ -101,6 +101,7 @@ type EngineInterface interface {
SetCacher(string, caches.Cacher) SetCacher(string, caches.Cacher)
SetConnMaxLifetime(time.Duration) SetConnMaxLifetime(time.Duration)
SetColumnMapper(names.Mapper) SetColumnMapper(names.Mapper)
SetTagIdentifier(string)
SetDefaultCacher(caches.Cacher) SetDefaultCacher(caches.Cacher)
SetLogger(logger interface{}) SetLogger(logger interface{})
SetLogLevel(log.LogLevel) SetLogLevel(log.LogLevel)

6
vendor/xorm.io/xorm/internal/json/json.go

@ -6,15 +6,15 @@ package json
import "encoding/json" import "encoding/json"
// JSONInterface represents an interface to handle json data
type JSONInterface interface {
// Interface represents an interface to handle json data
type Interface interface {
Marshal(v interface{}) ([]byte, error) Marshal(v interface{}) ([]byte, error)
Unmarshal(data []byte, v interface{}) error Unmarshal(data []byte, v interface{}) error
} }
var ( var (
// DefaultJSONHandler default json handler // DefaultJSONHandler default json handler
DefaultJSONHandler JSONInterface = StdJSON{}
DefaultJSONHandler Interface = StdJSON{}
) )
// StdJSON implements JSONInterface via encoding/json // StdJSON implements JSONInterface via encoding/json

2
vendor/xorm.io/xorm/internal/statements/cache.go

@ -12,6 +12,7 @@ import (
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
) )
// ConvertIDSQL converts SQL with id
func (statement *Statement) ConvertIDSQL(sqlStr string) string { func (statement *Statement) ConvertIDSQL(sqlStr string) string {
if statement.RefTable != nil { if statement.RefTable != nil {
cols := statement.RefTable.PKColumns() cols := statement.RefTable.PKColumns()
@ -37,6 +38,7 @@ func (statement *Statement) ConvertIDSQL(sqlStr string) string {
return "" return ""
} }
// ConvertUpdateSQL converts update SQL
func (statement *Statement) ConvertUpdateSQL(sqlStr string) (string, string) { func (statement *Statement) ConvertUpdateSQL(sqlStr string) (string, string) {
if statement.RefTable == nil || len(statement.RefTable.PrimaryKeys) != 1 { if statement.RefTable == nil || len(statement.RefTable.PrimaryKeys) != 1 {
return "", "" return "", ""

1
vendor/xorm.io/xorm/internal/statements/expr_param.go

@ -12,6 +12,7 @@ import (
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
) )
// ErrUnsupportedExprType represents an error with unsupported express type
type ErrUnsupportedExprType struct { type ErrUnsupportedExprType struct {
tp string tp string
} }

5
vendor/xorm.io/xorm/internal/statements/query.go

@ -14,6 +14,7 @@ import (
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
) )
// GenQuerySQL generate query SQL
func (statement *Statement) GenQuerySQL(sqlOrArgs ...interface{}) (string, []interface{}, error) { func (statement *Statement) GenQuerySQL(sqlOrArgs ...interface{}) (string, []interface{}, error) {
if len(sqlOrArgs) > 0 { if len(sqlOrArgs) > 0 {
return statement.ConvertSQLOrArgs(sqlOrArgs...) return statement.ConvertSQLOrArgs(sqlOrArgs...)
@ -72,6 +73,7 @@ func (statement *Statement) GenQuerySQL(sqlOrArgs ...interface{}) (string, []int
return sqlStr, args, nil return sqlStr, args, nil
} }
// GenSumSQL generates sum SQL
func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (string, []interface{}, error) { func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (string, []interface{}, error) {
if statement.RawSQL != "" { if statement.RawSQL != "" {
return statement.GenRawSQL(), statement.RawParams, nil return statement.GenRawSQL(), statement.RawParams, nil
@ -102,6 +104,7 @@ func (statement *Statement) GenSumSQL(bean interface{}, columns ...string) (stri
return sqlStr, append(statement.joinArgs, condArgs...), nil return sqlStr, append(statement.joinArgs, condArgs...), nil
} }
// GenGetSQL generates Get SQL
func (statement *Statement) GenGetSQL(bean interface{}) (string, []interface{}, error) { func (statement *Statement) GenGetSQL(bean interface{}) (string, []interface{}, error) {
v := rValue(bean) v := rValue(bean)
isStruct := v.Kind() == reflect.Struct isStruct := v.Kind() == reflect.Struct
@ -316,6 +319,7 @@ func (statement *Statement) genSelectSQL(columnStr string, needLimit, needOrderB
return buf.String(), condArgs, nil return buf.String(), condArgs, nil
} }
// GenExistSQL generates Exist SQL
func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interface{}, error) { func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interface{}, error) {
if statement.RawSQL != "" { if statement.RawSQL != "" {
return statement.GenRawSQL(), statement.RawParams, nil return statement.GenRawSQL(), statement.RawParams, nil
@ -385,6 +389,7 @@ func (statement *Statement) GenExistSQL(bean ...interface{}) (string, []interfac
return sqlStr, args, nil return sqlStr, args, nil
} }
// 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 != "" {
return statement.GenRawSQL(), statement.RawParams, nil return statement.GenRawSQL(), statement.RawParams, nil

39
vendor/xorm.io/xorm/internal/statements/statement.go

@ -90,19 +90,17 @@ func NewStatement(dialect dialects.Dialect, tagParser *tags.Parser, defaultTimeZ
return statement return statement
} }
// SetTableName set table name
func (statement *Statement) SetTableName(tableName string) { func (statement *Statement) SetTableName(tableName string) {
statement.tableName = tableName statement.tableName = tableName
} }
func (statement *Statement) omitStr() string {
return statement.dialect.Quoter().Join(statement.OmitColumnMap, " ,")
}
// GenRawSQL generates correct raw sql // GenRawSQL generates correct raw sql
func (statement *Statement) GenRawSQL() string { func (statement *Statement) GenRawSQL() string {
return statement.ReplaceQuote(statement.RawSQL) return statement.ReplaceQuote(statement.RawSQL)
} }
// GenCondSQL generates condition SQL
func (statement *Statement) GenCondSQL(condOrBuilder interface{}) (string, []interface{}, error) { func (statement *Statement) GenCondSQL(condOrBuilder interface{}) (string, []interface{}, error) {
condSQL, condArgs, err := builder.ToSQL(condOrBuilder) condSQL, condArgs, err := builder.ToSQL(condOrBuilder)
if err != nil { if err != nil {
@ -111,6 +109,7 @@ func (statement *Statement) GenCondSQL(condOrBuilder interface{}) (string, []int
return statement.ReplaceQuote(condSQL), condArgs, nil return statement.ReplaceQuote(condSQL), condArgs, nil
} }
// ReplaceQuote replace sql key words with quote
func (statement *Statement) ReplaceQuote(sql string) string { func (statement *Statement) ReplaceQuote(sql string) string {
if sql == "" || statement.dialect.URI().DBType == schemas.MYSQL || if sql == "" || statement.dialect.URI().DBType == schemas.MYSQL ||
statement.dialect.URI().DBType == schemas.SQLITE { statement.dialect.URI().DBType == schemas.SQLITE {
@ -119,11 +118,12 @@ func (statement *Statement) ReplaceQuote(sql string) string {
return statement.dialect.Quoter().Replace(sql) return statement.dialect.Quoter().Replace(sql)
} }
// SetContextCache sets context cache
func (statement *Statement) SetContextCache(ctxCache contexts.ContextCache) { func (statement *Statement) SetContextCache(ctxCache contexts.ContextCache) {
statement.Context = ctxCache statement.Context = ctxCache
} }
// Init reset all the statement's fields
// Reset reset all the statement's fields
func (statement *Statement) Reset() { func (statement *Statement) Reset() {
statement.RefTable = nil statement.RefTable = nil
statement.Start = 0 statement.Start = 0
@ -163,7 +163,7 @@ func (statement *Statement) Reset() {
statement.LastError = nil statement.LastError = nil
} }
// NoAutoCondition if you do not want convert bean's field as query condition, then use this function
// SetNoAutoCondition if you do not want convert bean's field as query condition, then use this function
func (statement *Statement) SetNoAutoCondition(no ...bool) *Statement { func (statement *Statement) SetNoAutoCondition(no ...bool) *Statement {
statement.NoAutoCondition = true statement.NoAutoCondition = true
if len(no) > 0 { if len(no) > 0 {
@ -271,6 +271,7 @@ func (statement *Statement) NotIn(column string, args ...interface{}) *Statement
return statement return statement
} }
// SetRefValue set ref value
func (statement *Statement) SetRefValue(v reflect.Value) error { func (statement *Statement) SetRefValue(v reflect.Value) error {
var err error var err error
statement.RefTable, err = statement.tagParser.ParseWithCache(reflect.Indirect(v)) statement.RefTable, err = statement.tagParser.ParseWithCache(reflect.Indirect(v))
@ -285,6 +286,7 @@ func rValue(bean interface{}) reflect.Value {
return reflect.Indirect(reflect.ValueOf(bean)) return reflect.Indirect(reflect.ValueOf(bean))
} }
// SetRefBean set ref bean
func (statement *Statement) SetRefBean(bean interface{}) error { func (statement *Statement) SetRefBean(bean interface{}) error {
var err error var err error
statement.RefTable, err = statement.tagParser.ParseWithCache(rValue(bean)) statement.RefTable, err = statement.tagParser.ParseWithCache(rValue(bean))
@ -390,6 +392,7 @@ func (statement *Statement) Cols(columns ...string) *Statement {
return statement return statement
} }
// ColumnStr returns column string
func (statement *Statement) ColumnStr() string { func (statement *Statement) ColumnStr() string {
return statement.dialect.Quoter().Join(statement.ColumnMap, ", ") return statement.dialect.Quoter().Join(statement.ColumnMap, ", ")
} }
@ -493,11 +496,12 @@ func (statement *Statement) Asc(colNames ...string) *Statement {
return statement return statement
} }
// Conds returns condtions
func (statement *Statement) Conds() builder.Cond { func (statement *Statement) Conds() builder.Cond {
return statement.cond return statement.cond
} }
// Table tempororily set table name, the parameter could be a string or a pointer of struct
// SetTable tempororily set table name, the parameter could be a string or a pointer of struct
func (statement *Statement) SetTable(tableNameOrBean interface{}) error { func (statement *Statement) SetTable(tableNameOrBean interface{}) error {
v := rValue(tableNameOrBean) v := rValue(tableNameOrBean)
t := v.Type() t := v.Type()
@ -564,7 +568,7 @@ func (statement *Statement) Join(joinOP string, tablename interface{}, condition
return statement return statement
} }
// tbName get some table's table name
// tbNameNoSchema get some table's table name
func (statement *Statement) tbNameNoSchema(table *schemas.Table) string { func (statement *Statement) tbNameNoSchema(table *schemas.Table) string {
if len(statement.AltTableName) > 0 { if len(statement.AltTableName) > 0 {
return statement.AltTableName return statement.AltTableName
@ -585,12 +589,13 @@ func (statement *Statement) Having(conditions string) *Statement {
return statement return statement
} }
// Unscoped always disable struct tag "deleted"
// SetUnscoped always disable struct tag "deleted"
func (statement *Statement) SetUnscoped() *Statement { func (statement *Statement) SetUnscoped() *Statement {
statement.unscoped = true statement.unscoped = true
return statement return statement
} }
// GetUnscoped return true if it's unscoped
func (statement *Statement) GetUnscoped() bool { func (statement *Statement) GetUnscoped() bool {
return statement.unscoped return statement.unscoped
} }
@ -636,6 +641,7 @@ func (statement *Statement) genColumnStr() string {
return buf.String() return buf.String()
} }
// GenCreateTableSQL generated create table SQL
func (statement *Statement) GenCreateTableSQL() []string { func (statement *Statement) GenCreateTableSQL() []string {
statement.RefTable.StoreEngine = statement.StoreEngine statement.RefTable.StoreEngine = statement.StoreEngine
statement.RefTable.Charset = statement.Charset statement.RefTable.Charset = statement.Charset
@ -643,6 +649,7 @@ func (statement *Statement) GenCreateTableSQL() []string {
return s return s
} }
// GenIndexSQL generated create index SQL
func (statement *Statement) GenIndexSQL() []string { func (statement *Statement) GenIndexSQL() []string {
var sqls []string var sqls []string
tbName := statement.TableName() tbName := statement.TableName()
@ -659,6 +666,7 @@ func uniqueName(tableName, uqeName string) string {
return fmt.Sprintf("UQE_%v_%v", tableName, uqeName) return fmt.Sprintf("UQE_%v_%v", tableName, uqeName)
} }
// GenUniqueSQL generates unique SQL
func (statement *Statement) GenUniqueSQL() []string { func (statement *Statement) GenUniqueSQL() []string {
var sqls []string var sqls []string
tbName := statement.TableName() tbName := statement.TableName()
@ -671,6 +679,7 @@ func (statement *Statement) GenUniqueSQL() []string {
return sqls return sqls
} }
// GenDelIndexSQL generate delete index SQL
func (statement *Statement) GenDelIndexSQL() []string { func (statement *Statement) GenDelIndexSQL() []string {
var sqls []string var sqls []string
tbName := statement.TableName() tbName := statement.TableName()
@ -704,7 +713,7 @@ func (statement *Statement) buildConds2(table *schemas.Table, bean interface{},
col.SQLType.IsBlob() || col.SQLType.Name == schemas.TimeStampz) { col.SQLType.IsBlob() || col.SQLType.Name == schemas.TimeStampz) {
continue continue
} }
if col.SQLType.IsJson() {
if col.IsJSON {
continue continue
} }
@ -813,7 +822,7 @@ func (statement *Statement) buildConds2(table *schemas.Table, bean interface{},
continue continue
} }
} else { } else {
if col.SQLType.IsJson() {
if col.IsJSON {
if col.SQLType.IsText() { if col.SQLType.IsText() {
bytes, err := json.DefaultJSONHandler.Marshal(fieldValue.Interface()) bytes, err := json.DefaultJSONHandler.Marshal(fieldValue.Interface())
if err != nil { if err != nil {
@ -896,6 +905,7 @@ func (statement *Statement) buildConds2(table *schemas.Table, bean interface{},
return builder.And(conds...), nil return builder.And(conds...), nil
} }
// BuildConds builds condition
func (statement *Statement) BuildConds(table *schemas.Table, bean interface{}, includeVersion bool, includeUpdated bool, includeNil bool, includeAutoIncr bool, addedTableName bool) (builder.Cond, error) { func (statement *Statement) BuildConds(table *schemas.Table, bean interface{}, includeVersion bool, includeUpdated bool, includeNil bool, includeAutoIncr bool, addedTableName bool) (builder.Cond, error) {
return statement.buildConds2(table, bean, includeVersion, includeUpdated, includeNil, includeAutoIncr, statement.allUseBool, statement.useAllCols, return statement.buildConds2(table, bean, includeVersion, includeUpdated, includeNil, includeAutoIncr, statement.allUseBool, statement.useAllCols,
statement.unscoped, statement.MustColumnMap, statement.TableName(), statement.TableAlias, addedTableName) statement.unscoped, statement.MustColumnMap, statement.TableName(), statement.TableAlias, addedTableName)
@ -911,12 +921,10 @@ func (statement *Statement) mergeConds(bean interface{}) error {
statement.cond = statement.cond.And(autoCond) statement.cond = statement.cond.And(autoCond)
} }
if err := statement.ProcessIDParam(); err != nil {
return err
}
return nil
return statement.ProcessIDParam()
} }
// GenConds generates conditions
func (statement *Statement) GenConds(bean interface{}) (string, []interface{}, error) { func (statement *Statement) GenConds(bean interface{}) (string, []interface{}, error) {
if err := statement.mergeConds(bean); err != nil { if err := statement.mergeConds(bean); err != nil {
return "", nil, err return "", nil, err
@ -930,6 +938,7 @@ func (statement *Statement) quoteColumnStr(columnStr string) string {
return statement.dialect.Quoter().Join(columns, ",") return statement.dialect.Quoter().Join(columns, ",")
} }
// ConvertSQLOrArgs converts sql or args
func (statement *Statement) ConvertSQLOrArgs(sqlOrArgs ...interface{}) (string, []interface{}, error) { func (statement *Statement) ConvertSQLOrArgs(sqlOrArgs ...interface{}) (string, []interface{}, error) {
sql, args, err := convertSQLOrArgs(sqlOrArgs...) sql, args, err := convertSQLOrArgs(sqlOrArgs...)
if err != nil { if err != nil {

2
vendor/xorm.io/xorm/internal/statements/statement_args.go

@ -77,6 +77,7 @@ func convertArg(arg interface{}, convertFunc func(string) string) string {
const insertSelectPlaceHolder = true const insertSelectPlaceHolder = true
// WriteArg writes an arg
func (statement *Statement) WriteArg(w *builder.BytesWriter, arg interface{}) error { func (statement *Statement) WriteArg(w *builder.BytesWriter, arg interface{}) error {
switch argv := arg.(type) { switch argv := arg.(type) {
case *builder.Builder: case *builder.Builder:
@ -116,6 +117,7 @@ func (statement *Statement) WriteArg(w *builder.BytesWriter, arg interface{}) er
return nil return nil
} }
// WriteArgs writes args
func (statement *Statement) WriteArgs(w *builder.BytesWriter, args []interface{}) error { func (statement *Statement) WriteArgs(w *builder.BytesWriter, args []interface{}) error {
for i, arg := range args { for i, arg := range args {
if err := statement.WriteArg(w, arg); err != nil { if err := statement.WriteArg(w, arg); err != nil {

2
vendor/xorm.io/xorm/internal/statements/update.go

@ -204,7 +204,7 @@ func (statement *Statement) BuildUpdates(tableValue reflect.Value,
continue continue
} }
} else { } else {
if !col.SQLType.IsJson() {
if !col.IsJSON {
table, err := statement.tagParser.ParseWithCache(fieldValue) table, err := statement.tagParser.ParseWithCache(fieldValue)
if err != nil { if err != nil {
val = fieldValue.Interface() val = fieldValue.Interface()

2
vendor/xorm.io/xorm/internal/statements/values.go

@ -86,7 +86,7 @@ func (statement *Statement) Value2Interface(col *schemas.Column, fieldValue refl
return t.Float64, nil return t.Float64, nil
} }
if !col.SQLType.IsJson() {
if !col.IsJSON {
// !<winxxp>! 增加支持driver.Valuer接口的结构,如sql.NullString // !<winxxp>! 增加支持driver.Valuer接口的结构,如sql.NullString
if v, ok := fieldValue.Interface().(driver.Valuer); ok { if v, ok := fieldValue.Interface().(driver.Valuer); ok {
return v.Value() return v.Value()

1
vendor/xorm.io/xorm/internal/utils/name.go

@ -8,6 +8,7 @@ import (
"fmt" "fmt"
) )
// IndexName returns index name
func IndexName(tableName, idxName string) string { func IndexName(tableName, idxName string) string {
return fmt.Sprintf("IDX_%v_%v", tableName, idxName) return fmt.Sprintf("IDX_%v_%v", tableName, idxName)
} }

1
vendor/xorm.io/xorm/internal/utils/reflect.go

@ -8,6 +8,7 @@ import (
"reflect" "reflect"
) )
// ReflectValue returns value of a bean
func ReflectValue(bean interface{}) reflect.Value { func ReflectValue(bean interface{}) reflect.Value {
return reflect.Indirect(reflect.ValueOf(bean)) return reflect.Indirect(reflect.ValueOf(bean))
} }

1
vendor/xorm.io/xorm/internal/utils/sql.go

@ -8,6 +8,7 @@ import (
"strings" "strings"
) )
// IsSubQuery returns true if it contains a sub query
func IsSubQuery(tbName string) bool { func IsSubQuery(tbName string) bool {
const selStr = "select" const selStr = "select"
if len(tbName) <= len(selStr)+1 { if len(tbName) <= len(selStr)+1 {

3
vendor/xorm.io/xorm/internal/utils/strings.go

@ -8,10 +8,12 @@ import (
"strings" "strings"
) )
// IndexNoCase index a string in a string with no care of capitalize
func IndexNoCase(s, sep string) int { func IndexNoCase(s, sep string) int {
return strings.Index(strings.ToLower(s), strings.ToLower(sep)) return strings.Index(strings.ToLower(s), strings.ToLower(sep))
} }
// SplitNoCase split a string by a seperator with no care of capitalize
func SplitNoCase(s, sep string) []string { func SplitNoCase(s, sep string) []string {
idx := IndexNoCase(s, sep) idx := IndexNoCase(s, sep)
if idx < 0 { if idx < 0 {
@ -20,6 +22,7 @@ func SplitNoCase(s, sep string) []string {
return strings.Split(s, s[idx:idx+len(sep)]) return strings.Split(s, s[idx:idx+len(sep)])
} }
// SplitNNoCase split n by a seperator with no care of capitalize
func SplitNNoCase(s, sep string, n int) []string { func SplitNNoCase(s, sep string, n int) []string {
idx := IndexNoCase(s, sep) idx := IndexNoCase(s, sep)
if idx < 0 { if idx < 0 {

40
vendor/xorm.io/xorm/internal/utils/zero.go

@ -9,6 +9,7 @@ import (
"time" "time"
) )
// Zeroable represents an interface which could know if it's a zero value
type Zeroable interface { type Zeroable interface {
IsZero() bool IsZero() bool
} }
@ -21,39 +22,39 @@ func IsZero(k interface{}) bool {
return true return true
} }
switch k.(type) {
switch t := k.(type) {
case int: case int:
return k.(int) == 0
return t == 0
case int8: case int8:
return k.(int8) == 0
return t == 0
case int16: case int16:
return k.(int16) == 0
return t == 0
case int32: case int32:
return k.(int32) == 0
return t == 0
case int64: case int64:
return k.(int64) == 0
return t == 0
case uint: case uint:
return k.(uint) == 0
return t == 0
case uint8: case uint8:
return k.(uint8) == 0
return t == 0
case uint16: case uint16:
return k.(uint16) == 0
return t == 0
case uint32: case uint32:
return k.(uint32) == 0
return t == 0
case uint64: case uint64:
return k.(uint64) == 0
return t == 0
case float32: case float32:
return k.(float32) == 0
return t == 0
case float64: case float64:
return k.(float64) == 0
return t == 0
case bool: case bool:
return k.(bool) == false
return !t
case string: case string:
return k.(string) == ""
return t == ""
case *time.Time: case *time.Time:
return k.(*time.Time) == nilTime || IsTimeZero(*k.(*time.Time))
return t == nilTime || IsTimeZero(*t)
case time.Time: case time.Time:
return IsTimeZero(k.(time.Time))
return IsTimeZero(t)
case Zeroable: case Zeroable:
return k.(Zeroable) == nil || k.(Zeroable).IsZero() return k.(Zeroable) == nil || k.(Zeroable).IsZero()
case reflect.Value: // for go version less than 1.13 because reflect.Value has no method IsZero case reflect.Value: // for go version less than 1.13 because reflect.Value has no method IsZero
@ -65,6 +66,7 @@ func IsZero(k interface{}) bool {
var zeroType = reflect.TypeOf((*Zeroable)(nil)).Elem() var zeroType = reflect.TypeOf((*Zeroable)(nil)).Elem()
// IsValueZero returns true if the reflect Value is a zero
func IsValueZero(v reflect.Value) bool { func IsValueZero(v reflect.Value) bool {
switch v.Kind() { switch v.Kind() {
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Slice: case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Slice:
@ -88,6 +90,7 @@ func IsValueZero(v reflect.Value) bool {
return false return false
} }
// IsStructZero returns true if the Value is a struct and all fields is zero
func IsStructZero(v reflect.Value) bool { func IsStructZero(v reflect.Value) bool {
if !v.IsValid() || v.NumField() == 0 { if !v.IsValid() || v.NumField() == 0 {
return true return true
@ -120,6 +123,7 @@ func IsStructZero(v reflect.Value) bool {
return true return true
} }
// IsArrayZero returns true is a slice of array is zero
func IsArrayZero(v reflect.Value) bool { func IsArrayZero(v reflect.Value) bool {
if !v.IsValid() || v.Len() == 0 { if !v.IsValid() || v.Len() == 0 {
return true return true
@ -134,11 +138,13 @@ func IsArrayZero(v reflect.Value) bool {
return true return true
} }
// represents all zero times
const ( const (
ZeroTime0 = "0000-00-00 00:00:00" ZeroTime0 = "0000-00-00 00:00:00"
ZeroTime1 = "0001-01-01 00:00:00" ZeroTime1 = "0001-01-01 00:00:00"
) )
// IsTimeZero return true if a time is zero
func IsTimeZero(t time.Time) bool { func IsTimeZero(t time.Time) bool {
return t.IsZero() || t.Format("2006-01-02 15:04:05") == ZeroTime0 || return t.IsZero() || t.Format("2006-01-02 15:04:05") == ZeroTime0 ||
t.Format("2006-01-02 15:04:05") == ZeroTime1 t.Format("2006-01-02 15:04:05") == ZeroTime1

18
vendor/xorm.io/xorm/names/mapper.go

@ -16,6 +16,7 @@ type Mapper interface {
Table2Obj(string) string Table2Obj(string) string
} }
// CacheMapper represents a cache mapper
type CacheMapper struct { type CacheMapper struct {
oriMapper Mapper oriMapper Mapper
obj2tableCache map[string]string obj2tableCache map[string]string
@ -24,12 +25,14 @@ type CacheMapper struct {
table2objMutex sync.RWMutex table2objMutex sync.RWMutex
} }
// NewCacheMapper creates a cache mapper
func NewCacheMapper(mapper Mapper) *CacheMapper { func NewCacheMapper(mapper Mapper) *CacheMapper {
return &CacheMapper{oriMapper: mapper, obj2tableCache: make(map[string]string), return &CacheMapper{oriMapper: mapper, obj2tableCache: make(map[string]string),
table2objCache: make(map[string]string), table2objCache: make(map[string]string),
} }
} }
// Obj2Table implements Mapper
func (m *CacheMapper) Obj2Table(o string) string { func (m *CacheMapper) Obj2Table(o string) string {
m.obj2tableMutex.RLock() m.obj2tableMutex.RLock()
t, ok := m.obj2tableCache[o] t, ok := m.obj2tableCache[o]
@ -45,6 +48,7 @@ func (m *CacheMapper) Obj2Table(o string) string {
return t return t
} }
// Table2Obj implements Mapper
func (m *CacheMapper) Table2Obj(t string) string { func (m *CacheMapper) Table2Obj(t string) string {
m.table2objMutex.RLock() m.table2objMutex.RLock()
o, ok := m.table2objCache[t] o, ok := m.table2objCache[t]
@ -60,15 +64,17 @@ func (m *CacheMapper) Table2Obj(t string) string {
return o return o
} }
// SameMapper implements IMapper and provides same name between struct and
// SameMapper implements Mapper and provides same name between struct and
// database table // database table
type SameMapper struct { type SameMapper struct {
} }
// Obj2Table implements Mapper
func (m SameMapper) Obj2Table(o string) string { func (m SameMapper) Obj2Table(o string) string {
return o return o
} }
// Table2Obj implements Mapper
func (m SameMapper) Table2Obj(t string) string { func (m SameMapper) Table2Obj(t string) string {
return t return t
} }
@ -98,6 +104,7 @@ func snakeCasedName(name string) string {
return b2s(newstr) return b2s(newstr)
} }
// Obj2Table implements Mapper
func (mapper SnakeMapper) Obj2Table(name string) string { func (mapper SnakeMapper) Obj2Table(name string) string {
return snakeCasedName(name) return snakeCasedName(name)
} }
@ -127,6 +134,7 @@ func titleCasedName(name string) string {
return b2s(newstr) return b2s(newstr)
} }
// Table2Obj implements Mapper
func (mapper SnakeMapper) Table2Obj(name string) string { func (mapper SnakeMapper) Table2Obj(name string) string {
return titleCasedName(name) return titleCasedName(name)
} }
@ -168,10 +176,12 @@ func gonicCasedName(name string) string {
return strings.ToLower(string(newstr)) return strings.ToLower(string(newstr))
} }
// Obj2Table implements Mapper
func (mapper GonicMapper) Obj2Table(name string) string { func (mapper GonicMapper) Obj2Table(name string) string {
return gonicCasedName(name) return gonicCasedName(name)
} }
// Table2Obj implements Mapper
func (mapper GonicMapper) Table2Obj(name string) string { func (mapper GonicMapper) Table2Obj(name string) string {
newstr := make([]rune, 0) newstr := make([]rune, 0)
@ -234,14 +244,17 @@ type PrefixMapper struct {
Prefix string Prefix string
} }
// Obj2Table implements Mapper
func (mapper PrefixMapper) Obj2Table(name string) string { func (mapper PrefixMapper) Obj2Table(name string) string {
return mapper.Prefix + mapper.Mapper.Obj2Table(name) return mapper.Prefix + mapper.Mapper.Obj2Table(name)
} }
// Table2Obj implements Mapper
func (mapper PrefixMapper) Table2Obj(name string) string { func (mapper PrefixMapper) Table2Obj(name string) string {
return mapper.Mapper.Table2Obj(name[len(mapper.Prefix):]) return mapper.Mapper.Table2Obj(name[len(mapper.Prefix):])
} }
// NewPrefixMapper creates a prefix mapper
func NewPrefixMapper(mapper Mapper, prefix string) PrefixMapper { func NewPrefixMapper(mapper Mapper, prefix string) PrefixMapper {
return PrefixMapper{mapper, prefix} return PrefixMapper{mapper, prefix}
} }
@ -252,14 +265,17 @@ type SuffixMapper struct {
Suffix string Suffix string
} }
// Obj2Table implements Mapper
func (mapper SuffixMapper) Obj2Table(name string) string { func (mapper SuffixMapper) Obj2Table(name string) string {
return mapper.Mapper.Obj2Table(name) + mapper.Suffix return mapper.Mapper.Obj2Table(name) + mapper.Suffix
} }
// Table2Obj implements Mapper
func (mapper SuffixMapper) Table2Obj(name string) string { func (mapper SuffixMapper) Table2Obj(name string) string {
return mapper.Mapper.Table2Obj(name[:len(name)-len(mapper.Suffix)]) return mapper.Mapper.Table2Obj(name[:len(name)-len(mapper.Suffix)])
} }
// NewSuffixMapper creates a suffix mapper
func NewSuffixMapper(mapper Mapper, suffix string) SuffixMapper { func NewSuffixMapper(mapper Mapper, suffix string) SuffixMapper {
return SuffixMapper{mapper, suffix} return SuffixMapper{mapper, suffix}
} }

1
vendor/xorm.io/xorm/names/table_name.go

@ -19,6 +19,7 @@ var (
tvCache sync.Map tvCache sync.Map
) )
// GetTableName returns table name
func GetTableName(mapper Mapper, v reflect.Value) string { func GetTableName(mapper Mapper, v reflect.Value) string {
if v.Type().Implements(tpTableName) { if v.Type().Implements(tpTableName) {
return v.Interface().(TableName).TableName() return v.Interface().(TableName).TableName()

2
vendor/xorm.io/xorm/schemas/column.go

@ -13,6 +13,7 @@ import (
"time" "time"
) )
// enumerates all database mapping way
const ( const (
TWOSIDES = iota + 1 TWOSIDES = iota + 1
ONLYTODB ONLYTODB
@ -51,6 +52,7 @@ type Column struct {
func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column { func NewColumn(name, fieldName string, sqlType SQLType, len1, len2 int, nullable bool) *Column {
return &Column{ return &Column{
Name: name, Name: name,
IsJSON: sqlType.IsJson(),
TableName: "", TableName: "",
FieldName: fieldName, FieldName: fieldName,
SQLType: sqlType, SQLType: sqlType,

6
vendor/xorm.io/xorm/schemas/index.go

@ -28,6 +28,7 @@ func NewIndex(name string, indexType int) *Index {
return &Index{true, name, indexType, make([]string, 0)} return &Index{true, name, indexType, make([]string, 0)}
} }
// XName returns the special index name for the table
func (index *Index) XName(tableName string) string { func (index *Index) XName(tableName string) string {
if !strings.HasPrefix(index.Name, "UQE_") && if !strings.HasPrefix(index.Name, "UQE_") &&
!strings.HasPrefix(index.Name, "IDX_") { !strings.HasPrefix(index.Name, "IDX_") {
@ -43,11 +44,10 @@ func (index *Index) XName(tableName string) string {
// AddColumn add columns which will be composite index // AddColumn add columns which will be composite index
func (index *Index) AddColumn(cols ...string) { func (index *Index) AddColumn(cols ...string) {
for _, col := range cols {
index.Cols = append(index.Cols, col)
}
index.Cols = append(index.Cols, cols...)
} }
// Equal return true if the two Index is equal
func (index *Index) Equal(dst *Index) bool { func (index *Index) Equal(dst *Index) bool {
if index.Type != dst.Type { if index.Type != dst.Type {
return false return false

5
vendor/xorm.io/xorm/schemas/pk.go

@ -11,13 +11,16 @@ import (
"xorm.io/xorm/internal/utils" "xorm.io/xorm/internal/utils"
) )
// PK represents primary key values
type PK []interface{} type PK []interface{}
// NewPK creates primay keys
func NewPK(pks ...interface{}) *PK { func NewPK(pks ...interface{}) *PK {
p := PK(pks) p := PK(pks)
return &p return &p
} }
// IsZero return true if primay keys are zero
func (p *PK) IsZero() bool { func (p *PK) IsZero() bool {
for _, k := range *p { for _, k := range *p {
if utils.IsZero(k) { if utils.IsZero(k) {
@ -27,6 +30,7 @@ func (p *PK) IsZero() bool {
return false return false
} }
// ToString convert to SQL string
func (p *PK) ToString() (string, error) { func (p *PK) ToString() (string, error) {
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
enc := gob.NewEncoder(buf) enc := gob.NewEncoder(buf)
@ -34,6 +38,7 @@ func (p *PK) ToString() (string, error) {
return buf.String(), err return buf.String(), err
} }
// FromString reads content to load primary keys
func (p *PK) FromString(content string) error { func (p *PK) FromString(content string) error {
dec := gob.NewDecoder(bytes.NewBufferString(content)) dec := gob.NewDecoder(bytes.NewBufferString(content))
err := dec.Decode(p) err := dec.Decode(p)

8
vendor/xorm.io/xorm/schemas/quote.go

@ -16,10 +16,10 @@ type Quoter struct {
} }
var ( var (
// AlwaysFalseReverse always think it's not a reverse word
// AlwaysNoReserve always think it's not a reverse word
AlwaysNoReserve = func(string) bool { return false } AlwaysNoReserve = func(string) bool { return false }
// AlwaysReverse always reverse the word
// AlwaysReserve always reverse the word
AlwaysReserve = func(string) bool { return true } AlwaysReserve = func(string) bool { return true }
// CommanQuoteMark represnets the common quote mark // CommanQuoteMark represnets the common quote mark
@ -29,10 +29,12 @@ var (
CommonQuoter = Quoter{CommanQuoteMark, CommanQuoteMark, AlwaysReserve} CommonQuoter = Quoter{CommanQuoteMark, CommanQuoteMark, AlwaysReserve}
) )
// IsEmpty return true if no prefix and suffix
func (q Quoter) IsEmpty() bool { func (q Quoter) IsEmpty() bool {
return q.Prefix == 0 && q.Suffix == 0 return q.Prefix == 0 && q.Suffix == 0
} }
// Quote quote a string
func (q Quoter) Quote(s string) string { func (q Quoter) Quote(s string) string {
var buf strings.Builder var buf strings.Builder
q.QuoteTo(&buf, s) q.QuoteTo(&buf, s)
@ -59,12 +61,14 @@ func (q Quoter) Trim(s string) string {
return buf.String() return buf.String()
} }
// Join joins a slice with quoters
func (q Quoter) Join(a []string, sep string) string { func (q Quoter) Join(a []string, sep string) string {
var b strings.Builder var b strings.Builder
q.JoinWrite(&b, a, sep) q.JoinWrite(&b, a, sep)
return b.String() return b.String()
} }
// JoinWrite writes quoted content to a builder
func (q Quoter) JoinWrite(b *strings.Builder, a []string, sep string) error { func (q Quoter) JoinWrite(b *strings.Builder, a []string, sep string) error {
if len(a) == 0 { if len(a) == 0 {
return nil return nil

12
vendor/xorm.io/xorm/schemas/table.go

@ -58,12 +58,7 @@ func (table *Table) ColumnsSeq() []string {
} }
func (table *Table) columnsByName(name string) []*Column { func (table *Table) columnsByName(name string) []*Column {
for k, cols := range table.columnsMap {
if strings.EqualFold(k, name) {
return cols
}
}
return nil
return table.columnsMap[strings.ToLower(name)]
} }
// GetColumn returns column according column name, if column not found, return nil // GetColumn returns column according column name, if column not found, return nil
@ -95,23 +90,28 @@ func (table *Table) PKColumns() []*Column {
return columns return columns
} }
// ColumnType returns a column's type
func (table *Table) ColumnType(name string) reflect.Type { func (table *Table) ColumnType(name string) reflect.Type {
t, _ := table.Type.FieldByName(name) t, _ := table.Type.FieldByName(name)
return t.Type return t.Type
} }
// AutoIncrColumn returns autoincrement column
func (table *Table) AutoIncrColumn() *Column { func (table *Table) AutoIncrColumn() *Column {
return table.GetColumn(table.AutoIncrement) return table.GetColumn(table.AutoIncrement)
} }
// VersionColumn returns version column's information
func (table *Table) VersionColumn() *Column { func (table *Table) VersionColumn() *Column {
return table.GetColumn(table.Version) return table.GetColumn(table.Version)
} }
// UpdatedColumn returns updated column's information
func (table *Table) UpdatedColumn() *Column { func (table *Table) UpdatedColumn() *Column {
return table.GetColumn(table.Updated) return table.GetColumn(table.Updated)
} }
// DeletedColumn returns deleted column's information
func (table *Table) DeletedColumn() *Column { func (table *Table) DeletedColumn() *Column {
return table.GetColumn(table.Deleted) return table.GetColumn(table.Deleted)
} }

149
vendor/xorm.io/xorm/schemas/type.go

@ -11,8 +11,10 @@ import (
"time" "time"
) )
// DBType represents a database type
type DBType string type DBType string
// enumerates all database types
const ( const (
POSTGRES DBType = "postgres" POSTGRES DBType = "postgres"
SQLITE DBType = "sqlite3" SQLITE DBType = "sqlite3"
@ -28,6 +30,7 @@ type SQLType struct {
DefaultLength2 int DefaultLength2 int
} }
// enumerates all columns types
const ( const (
UNKNOW_TYPE = iota UNKNOW_TYPE = iota
TEXT_TYPE TEXT_TYPE
@ -37,6 +40,7 @@ const (
ARRAY_TYPE ARRAY_TYPE
) )
// IsType reutrns ture if the column type is the same as the parameter
func (s *SQLType) IsType(st int) bool { func (s *SQLType) IsType(st int) bool {
if t, ok := SqlTypes[s.Name]; ok && t == st { if t, ok := SqlTypes[s.Name]; ok && t == st {
return true return true
@ -44,38 +48,53 @@ func (s *SQLType) IsType(st int) bool {
return false return false
} }
// IsText returns true if column is a text type
func (s *SQLType) IsText() bool { func (s *SQLType) IsText() bool {
return s.IsType(TEXT_TYPE) return s.IsType(TEXT_TYPE)
} }
// IsBlob returns true if column is a binary type
func (s *SQLType) IsBlob() bool { func (s *SQLType) IsBlob() bool {
return s.IsType(BLOB_TYPE) return s.IsType(BLOB_TYPE)
} }
// IsTime returns true if column is a time type
func (s *SQLType) IsTime() bool { func (s *SQLType) IsTime() bool {
return s.IsType(TIME_TYPE) return s.IsType(TIME_TYPE)
} }
// IsNumeric returns true if column is a numeric type
func (s *SQLType) IsNumeric() bool { func (s *SQLType) IsNumeric() bool {
return s.IsType(NUMERIC_TYPE) return s.IsType(NUMERIC_TYPE)
} }
// IsArray returns true if column is an array type
func (s *SQLType) IsArray() bool { func (s *SQLType) IsArray() bool {
return s.IsType(ARRAY_TYPE) return s.IsType(ARRAY_TYPE)
} }
// IsJson returns true if column is an array type
func (s *SQLType) IsJson() bool { func (s *SQLType) IsJson() bool {
return s.Name == Json || s.Name == Jsonb return s.Name == Json || s.Name == Jsonb
} }
// IsXML returns true if column is an xml type
func (s *SQLType) IsXML() bool {
return s.Name == XML
}
// enumerates all the database column types
var ( var (
Bit = "BIT"
TinyInt = "TINYINT"
SmallInt = "SMALLINT"
MediumInt = "MEDIUMINT"
Int = "INT"
Integer = "INTEGER"
BigInt = "BIGINT"
Bit = "BIT"
UnsignedBit = "UNSIGNED BIT"
TinyInt = "TINYINT"
SmallInt = "SMALLINT"
MediumInt = "MEDIUMINT"
Int = "INT"
UnsignedInt = "UNSIGNED INT"
Integer = "INTEGER"
BigInt = "BIGINT"
UnsignedBigInt = "UNSIGNED BIGINT"
Enum = "ENUM" Enum = "ENUM"
Set = "SET" Set = "SET"
@ -128,22 +147,28 @@ var (
Json = "JSON" Json = "JSON"
Jsonb = "JSONB" Jsonb = "JSONB"
XML = "XML"
Array = "ARRAY" Array = "ARRAY"
SqlTypes = map[string]int{ SqlTypes = map[string]int{
Bit: NUMERIC_TYPE,
TinyInt: NUMERIC_TYPE,
SmallInt: NUMERIC_TYPE,
MediumInt: NUMERIC_TYPE,
Int: NUMERIC_TYPE,
Integer: NUMERIC_TYPE,
BigInt: NUMERIC_TYPE,
Bit: NUMERIC_TYPE,
UnsignedBit: NUMERIC_TYPE,
TinyInt: NUMERIC_TYPE,
SmallInt: NUMERIC_TYPE,
MediumInt: NUMERIC_TYPE,
Int: NUMERIC_TYPE,
UnsignedInt: NUMERIC_TYPE,
Integer: NUMERIC_TYPE,
BigInt: NUMERIC_TYPE,
UnsignedBigInt: NUMERIC_TYPE,
Enum: TEXT_TYPE, Enum: TEXT_TYPE,
Set: TEXT_TYPE, Set: TEXT_TYPE,
Json: TEXT_TYPE, Json: TEXT_TYPE,
Jsonb: TEXT_TYPE, Jsonb: TEXT_TYPE,
XML: TEXT_TYPE,
Char: TEXT_TYPE, Char: TEXT_TYPE,
NChar: TEXT_TYPE, NChar: TEXT_TYPE,
Varchar: TEXT_TYPE, Varchar: TEXT_TYPE,
@ -197,53 +222,55 @@ var (
// !nashtsai! treat following var as interal const values, these are used for reflect.TypeOf comparison // !nashtsai! treat following var as interal const values, these are used for reflect.TypeOf comparison
var ( var (
c_EMPTY_STRING string
c_BOOL_DEFAULT bool
c_BYTE_DEFAULT byte
c_COMPLEX64_DEFAULT complex64
c_COMPLEX128_DEFAULT complex128
c_FLOAT32_DEFAULT float32
c_FLOAT64_DEFAULT float64
c_INT64_DEFAULT int64
c_UINT64_DEFAULT uint64
c_INT32_DEFAULT int32
c_UINT32_DEFAULT uint32
c_INT16_DEFAULT int16
c_UINT16_DEFAULT uint16
c_INT8_DEFAULT int8
c_UINT8_DEFAULT uint8
c_INT_DEFAULT int
c_UINT_DEFAULT uint
c_TIME_DEFAULT time.Time
emptyString string
boolDefault bool
byteDefault byte
complex64Default complex64
complex128Default complex128
float32Default float32
float64Default float64
int64Default int64
uint64Default uint64
int32Default int32
uint32Default uint32
int16Default int16
uint16Default uint16
int8Default int8
uint8Default uint8
intDefault int
uintDefault uint
timeDefault time.Time
) )
// enumerates all types
var ( var (
IntType = reflect.TypeOf(c_INT_DEFAULT)
Int8Type = reflect.TypeOf(c_INT8_DEFAULT)
Int16Type = reflect.TypeOf(c_INT16_DEFAULT)
Int32Type = reflect.TypeOf(c_INT32_DEFAULT)
Int64Type = reflect.TypeOf(c_INT64_DEFAULT)
UintType = reflect.TypeOf(c_UINT_DEFAULT)
Uint8Type = reflect.TypeOf(c_UINT8_DEFAULT)
Uint16Type = reflect.TypeOf(c_UINT16_DEFAULT)
Uint32Type = reflect.TypeOf(c_UINT32_DEFAULT)
Uint64Type = reflect.TypeOf(c_UINT64_DEFAULT)
Float32Type = reflect.TypeOf(c_FLOAT32_DEFAULT)
Float64Type = reflect.TypeOf(c_FLOAT64_DEFAULT)
Complex64Type = reflect.TypeOf(c_COMPLEX64_DEFAULT)
Complex128Type = reflect.TypeOf(c_COMPLEX128_DEFAULT)
StringType = reflect.TypeOf(c_EMPTY_STRING)
BoolType = reflect.TypeOf(c_BOOL_DEFAULT)
ByteType = reflect.TypeOf(c_BYTE_DEFAULT)
IntType = reflect.TypeOf(intDefault)
Int8Type = reflect.TypeOf(int8Default)
Int16Type = reflect.TypeOf(int16Default)
Int32Type = reflect.TypeOf(int32Default)
Int64Type = reflect.TypeOf(int64Default)
UintType = reflect.TypeOf(uintDefault)
Uint8Type = reflect.TypeOf(uint8Default)
Uint16Type = reflect.TypeOf(uint16Default)
Uint32Type = reflect.TypeOf(uint32Default)
Uint64Type = reflect.TypeOf(uint64Default)
Float32Type = reflect.TypeOf(float32Default)
Float64Type = reflect.TypeOf(float64Default)
Complex64Type = reflect.TypeOf(complex64Default)
Complex128Type = reflect.TypeOf(complex128Default)
StringType = reflect.TypeOf(emptyString)
BoolType = reflect.TypeOf(boolDefault)
ByteType = reflect.TypeOf(byteDefault)
BytesType = reflect.SliceOf(ByteType) BytesType = reflect.SliceOf(ByteType)
TimeType = reflect.TypeOf(c_TIME_DEFAULT)
TimeType = reflect.TypeOf(timeDefault)
) )
// enumerates all types
var ( var (
PtrIntType = reflect.PtrTo(IntType) PtrIntType = reflect.PtrTo(IntType)
PtrInt8Type = reflect.PtrTo(Int8Type) PtrInt8Type = reflect.PtrTo(Int8Type)
@ -273,10 +300,14 @@ var (
// Type2SQLType generate SQLType acorrding Go's type // Type2SQLType generate SQLType acorrding Go's type
func Type2SQLType(t reflect.Type) (st SQLType) { func Type2SQLType(t reflect.Type) (st SQLType) {
switch k := t.Kind(); k { switch k := t.Kind(); k {
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:
st = SQLType{Int, 0, 0} st = SQLType{Int, 0, 0}
case reflect.Int64, reflect.Uint64:
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32:
st = SQLType{UnsignedInt, 0, 0}
case reflect.Int64:
st = SQLType{BigInt, 0, 0} st = SQLType{BigInt, 0, 0}
case reflect.Uint64:
st = SQLType{UnsignedBigInt, 0, 0}
case reflect.Float32: case reflect.Float32:
st = SQLType{Float, 0, 0} st = SQLType{Float, 0, 0}
case reflect.Float64: case reflect.Float64:
@ -284,7 +315,7 @@ func Type2SQLType(t reflect.Type) (st SQLType) {
case reflect.Complex64, reflect.Complex128: case reflect.Complex64, reflect.Complex128:
st = SQLType{Varchar, 64, 0} st = SQLType{Varchar, 64, 0}
case reflect.Array, reflect.Slice, reflect.Map: case reflect.Array, reflect.Slice, reflect.Map:
if t.Elem() == reflect.TypeOf(c_BYTE_DEFAULT) {
if t.Elem() == reflect.TypeOf(byteDefault) {
st = SQLType{Blob, 0, 0} st = SQLType{Blob, 0, 0}
} else { } else {
st = SQLType{Text, 0, 0} st = SQLType{Text, 0, 0}
@ -308,7 +339,7 @@ func Type2SQLType(t reflect.Type) (st SQLType) {
return return
} }
// default sql type change to go types
// SQLType2Type convert default sql type change to go types
func SQLType2Type(st SQLType) reflect.Type { func SQLType2Type(st SQLType) reflect.Type {
name := strings.ToUpper(st.Name) name := strings.ToUpper(st.Name)
switch name { switch name {
@ -327,7 +358,7 @@ func SQLType2Type(st SQLType) reflect.Type {
case Bool: case Bool:
return reflect.TypeOf(true) return reflect.TypeOf(true)
case DateTime, Date, Time, TimeStamp, TimeStampz, SmallDateTime, Year: case DateTime, Date, Time, TimeStamp, TimeStampz, SmallDateTime, Year:
return reflect.TypeOf(c_TIME_DEFAULT)
return reflect.TypeOf(timeDefault)
case Decimal, Numeric, Money, SmallMoney: case Decimal, Numeric, Money, SmallMoney:
return reflect.TypeOf("") return reflect.TypeOf("")
default: default:

7
vendor/xorm.io/xorm/session.go

@ -169,6 +169,7 @@ func (session *Session) db() *core.DB {
return session.engine.db return session.engine.db
} }
// Engine returns session Engine
func (session *Session) Engine() *Engine { func (session *Session) Engine() *Engine {
return session.engine return session.engine
} }
@ -503,7 +504,7 @@ func (session *Session) slice2Bean(scanResults []interface{}, fields []string, b
fieldType := fieldValue.Type() fieldType := fieldValue.Type()
hasAssigned := false hasAssigned := false
if col.SQLType.IsJson() {
if col.IsJSON {
var bs []byte var bs []byte
if rawValueType.Kind() == reflect.String { if rawValueType.Kind() == reflect.String {
bs = []byte(vv.String()) bs = []byte(vv.String())
@ -683,7 +684,7 @@ func (session *Session) slice2Bean(scanResults []interface{}, fields []string, b
session.engine.logger.Errorf("sql.Sanner error: %v", err) session.engine.logger.Errorf("sql.Sanner error: %v", err)
hasAssigned = false hasAssigned = false
} }
} else if col.SQLType.IsJson() {
} else if col.IsJSON {
if rawValueType.Kind() == reflect.String { if rawValueType.Kind() == reflect.String {
hasAssigned = true hasAssigned = true
x := reflect.New(fieldType) x := reflect.New(fieldType)
@ -895,7 +896,7 @@ func (session *Session) incrVersionFieldValue(fieldValue *reflect.Value) {
} }
} }
// ContextHook sets the context on this session
// Context sets the context on this session
func (session *Session) Context(ctx context.Context) *Session { func (session *Session) Context(ctx context.Context) *Session {
session.ctx = ctx session.ctx = ctx
return session return session

3
vendor/xorm.io/xorm/session_find.go

@ -57,6 +57,9 @@ func (session *Session) FindAndCount(rowsSlicePtr interface{}, condiBean ...inte
if session.statement.SelectStr != "" { if session.statement.SelectStr != "" {
session.statement.SelectStr = "" session.statement.SelectStr = ""
} }
if len(session.statement.ColumnMap) > 0 {
session.statement.ColumnMap = []string{}
}
if session.statement.OrderStr != "" { if session.statement.OrderStr != "" {
session.statement.OrderStr = "" session.statement.OrderStr = ""
} }

7
vendor/xorm.io/xorm/session_get.go

@ -16,6 +16,11 @@ import (
"xorm.io/xorm/schemas" "xorm.io/xorm/schemas"
) )
var (
// ErrObjectIsNil return error of object is nil
ErrObjectIsNil = errors.New("object should not be nil")
)
// Get retrieve one record from database, bean's non-empty fields // Get retrieve one record from database, bean's non-empty fields
// will be as conditions // will be as conditions
func (session *Session) Get(bean interface{}) (bool, error) { func (session *Session) Get(bean interface{}) (bool, error) {
@ -37,6 +42,8 @@ func (session *Session) get(bean interface{}) (bool, error) {
return false, errors.New("needs a pointer to a value") return false, errors.New("needs a pointer to a value")
} else if beanValue.Elem().Kind() == reflect.Ptr { } else if beanValue.Elem().Kind() == reflect.Ptr {
return false, errors.New("a pointer to a pointer is not allowed") return false, errors.New("a pointer to a pointer is not allowed")
} else if beanValue.IsNil() {
return false, ErrObjectIsNil
} }
if beanValue.Elem().Kind() == reflect.Struct { if beanValue.Elem().Kind() == reflect.Struct {

36
vendor/xorm.io/xorm/session_schema.go

@ -448,27 +448,43 @@ func (session *Session) ImportFile(ddlPath string) ([]sql.Result, error) {
// Import SQL DDL from io.Reader // Import SQL DDL from io.Reader
func (session *Session) Import(r io.Reader) ([]sql.Result, error) { func (session *Session) Import(r io.Reader) ([]sql.Result, error) {
var results []sql.Result
var lastError error
scanner := bufio.NewScanner(r)
var (
results []sql.Result
lastError error
inSingleQuote bool
startComment bool
)
var inSingleQuote bool
scanner := bufio.NewScanner(r)
semiColSpliter := func(data []byte, atEOF bool) (advance int, token []byte, err error) { semiColSpliter := func(data []byte, atEOF bool) (advance int, token []byte, err error) {
if atEOF && len(data) == 0 { if atEOF && len(data) == 0 {
return 0, nil, nil return 0, nil, nil
} }
var oriInSingleQuote = inSingleQuote
for i, b := range data { for i, b := range data {
if b == '\'' {
inSingleQuote = !inSingleQuote
}
if !inSingleQuote && b == ';' {
return i + 1, data[0:i], nil
if startComment {
if b == '\n' {
startComment = false
}
} else {
if i > 0 && data[i-1] == '-' && data[i] == '-' {
startComment = true
continue
}
if b == '\'' {
inSingleQuote = !inSingleQuote
}
if !inSingleQuote && b == ';' {
return i + 1, data[0:i], nil
}
} }
} }
// If we're at EOF, we have a final, non-terminated line. Return it. // If we're at EOF, we have a final, non-terminated line. Return it.
if atEOF { if atEOF {
return len(data), data, nil return len(data), data, nil
} }
inSingleQuote = oriInSingleQuote
// Request more data. // Request more data.
return 0, nil, nil return 0, nil, nil
} }
@ -479,10 +495,10 @@ func (session *Session) Import(r io.Reader) ([]sql.Result, error) {
query := strings.Trim(scanner.Text(), " \t\n\r") query := strings.Trim(scanner.Text(), " \t\n\r")
if len(query) > 0 { if len(query) > 0 {
result, err := session.Exec(query) result, err := session.Exec(query)
results = append(results, result)
if err != nil { if err != nil {
return nil, err return nil, err
} }
results = append(results, result)
} }
} }

5
vendor/xorm.io/xorm/session_tx.go

@ -84,3 +84,8 @@ func (session *Session) Commit() error {
} }
return nil return nil
} }
// IsInTx if current session is in a transaction
func (session *Session) IsInTx() bool {
return !session.isAutoCommit
}

9
vendor/xorm.io/xorm/session_update.go

@ -273,8 +273,15 @@ func (session *Session) Update(bean interface{}, condiBean ...interface{}) (int6
k = ct.Elem().Kind() k = ct.Elem().Kind()
} }
if k == reflect.Struct { if k == reflect.Struct {
var refTable = session.statement.RefTable
if refTable == nil {
refTable, err = session.engine.TableInfo(condiBean[0])
if err != nil {
return 0, err
}
}
var err error var err error
autoCond, err = session.statement.BuildConds(session.statement.RefTable, condiBean[0], true, true, false, true, false)
autoCond, err = session.statement.BuildConds(refTable, condiBean[0], true, true, false, true, false)
if err != nil { if err != nil {
return 0, err return 0, err
} }

18
vendor/xorm.io/xorm/tags/parser.go

@ -21,9 +21,11 @@ import (
) )
var ( var (
// ErrUnsupportedType represents an unsupported type error
ErrUnsupportedType = errors.New("Unsupported type") ErrUnsupportedType = errors.New("Unsupported type")
) )
// Parser represents a parser for xorm tag
type Parser struct { type Parser struct {
identifier string identifier string
dialect dialects.Dialect dialect dialects.Dialect
@ -34,6 +36,7 @@ type Parser struct {
tableCache sync.Map // map[reflect.Type]*schemas.Table tableCache sync.Map // map[reflect.Type]*schemas.Table
} }
// NewParser creates a tag parser
func NewParser(identifier string, dialect dialects.Dialect, tableMapper, columnMapper names.Mapper, cacherMgr *caches.Manager) *Parser { func NewParser(identifier string, dialect dialects.Dialect, tableMapper, columnMapper names.Mapper, cacherMgr *caches.Manager) *Parser {
return &Parser{ return &Parser{
identifier: identifier, identifier: identifier,
@ -45,24 +48,35 @@ func NewParser(identifier string, dialect dialects.Dialect, tableMapper, columnM
} }
} }
// GetTableMapper returns table mapper
func (parser *Parser) GetTableMapper() names.Mapper { func (parser *Parser) GetTableMapper() names.Mapper {
return parser.tableMapper return parser.tableMapper
} }
// SetTableMapper sets table mapper
func (parser *Parser) SetTableMapper(mapper names.Mapper) { func (parser *Parser) SetTableMapper(mapper names.Mapper) {
parser.ClearCaches() parser.ClearCaches()
parser.tableMapper = mapper parser.tableMapper = mapper
} }
// GetColumnMapper returns column mapper
func (parser *Parser) GetColumnMapper() names.Mapper { func (parser *Parser) GetColumnMapper() names.Mapper {
return parser.columnMapper return parser.columnMapper
} }
// SetColumnMapper sets column mapper
func (parser *Parser) SetColumnMapper(mapper names.Mapper) { func (parser *Parser) SetColumnMapper(mapper names.Mapper) {
parser.ClearCaches() parser.ClearCaches()
parser.columnMapper = mapper parser.columnMapper = mapper
} }
// SetIdentifier sets tag identifier
func (parser *Parser) SetIdentifier(identifier string) {
parser.ClearCaches()
parser.identifier = identifier
}
// ParseWithCache parse a struct with cache
func (parser *Parser) ParseWithCache(v reflect.Value) (*schemas.Table, error) { func (parser *Parser) ParseWithCache(v reflect.Value) (*schemas.Table, error) {
t := v.Type() t := v.Type()
tableI, ok := parser.tableCache.Load(t) tableI, ok := parser.tableCache.Load(t)
@ -253,7 +267,7 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) {
addIndex(indexName, table, col, indexType) addIndex(indexName, table, col, indexType)
} }
} }
} else {
} else if fieldValue.CanSet() {
var sqlType schemas.SQLType var sqlType schemas.SQLType
if fieldValue.CanAddr() { if fieldValue.CanAddr() {
if _, ok := fieldValue.Addr().Interface().(convert.Conversion); ok { if _, ok := fieldValue.Addr().Interface().(convert.Conversion); ok {
@ -272,6 +286,8 @@ func (parser *Parser) Parse(v reflect.Value) (*schemas.Table, error) {
if fieldType.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) { if fieldType.Kind() == reflect.Int64 && (strings.ToUpper(col.FieldName) == "ID" || strings.HasSuffix(strings.ToUpper(col.FieldName), ".ID")) {
idFieldColName = col.Name idFieldColName = col.Name
} }
} else {
continue
} }
if col.IsAutoIncrement { if col.IsAutoIncrement {
col.Nullable = false col.Nullable = false

3
vendor/xorm.io/xorm/tags/tag.go

@ -226,6 +226,9 @@ func CommentTagHandler(ctx *Context) error {
// 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.tagName} ctx.col.SQLType = schemas.SQLType{Name: ctx.tagName}
if strings.EqualFold(ctx.tagName, "JSON") {
ctx.col.IsJSON = true
}
if len(ctx.params) > 0 { if len(ctx.params) > 0 {
if ctx.tagName == schemas.Enum { if ctx.tagName == schemas.Enum {
ctx.col.EnumOptions = make(map[string]int) ctx.col.EnumOptions = make(map[string]int)

Loading…
Cancel
Save