├── .circleci └── config.yml ├── .gitignore ├── LICENSE ├── README.md ├── README_CN.md └── xorm ├── .gitignore ├── .gopmfile ├── c++.go ├── cmd.go ├── driver.go ├── dump.go ├── go.go ├── go.mod ├── go.sum ├── lang.go ├── objc.go ├── reverse.go ├── shell.go ├── source.go ├── sqlite3.go ├── templates ├── c++ │ ├── class.h.tpl │ └── config ├── dict │ ├── config │ └── struct.html.tpl ├── go │ ├── config │ └── struct.go.tpl ├── gomeddler │ ├── config │ └── struct.go.tpl ├── goxorm │ ├── config │ └── struct.go.tpl └── objc │ ├── class.h.tpl │ ├── class.m.tpl │ └── config ├── vendor ├── cloud.google.com │ └── go │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ └── civil │ │ └── civil.go ├── github.com │ ├── denisenkom │ │ └── go-mssqldb │ │ │ ├── LICENSE.txt │ │ │ ├── README.md │ │ │ ├── appveyor.yml │ │ │ ├── buf.go │ │ │ ├── bulkcopy.go │ │ │ ├── bulkcopy_sql.go │ │ │ ├── convert.go │ │ │ ├── decimal.go │ │ │ ├── doc.go │ │ │ ├── error.go │ │ │ ├── internal │ │ │ └── cp │ │ │ │ ├── charset.go │ │ │ │ ├── collation.go │ │ │ │ ├── cp1250.go │ │ │ │ ├── cp1251.go │ │ │ │ ├── cp1252.go │ │ │ │ ├── cp1253.go │ │ │ │ ├── cp1254.go │ │ │ │ ├── cp1255.go │ │ │ │ ├── cp1256.go │ │ │ │ ├── cp1257.go │ │ │ │ ├── cp1258.go │ │ │ │ ├── cp437.go │ │ │ │ ├── cp850.go │ │ │ │ ├── cp874.go │ │ │ │ ├── cp932.go │ │ │ │ ├── cp936.go │ │ │ │ ├── cp949.go │ │ │ │ └── cp950.go │ │ │ ├── log.go │ │ │ ├── mssql.go │ │ │ ├── mssql_go110.go │ │ │ ├── mssql_go19.go │ │ │ ├── mssql_go19pre.go │ │ │ ├── net.go │ │ │ ├── ntlm.go │ │ │ ├── parser.go │ │ │ ├── rpc.go │ │ │ ├── sspi_windows.go │ │ │ ├── tds.go │ │ │ ├── token.go │ │ │ ├── token_string.go │ │ │ ├── tran.go │ │ │ ├── types.go │ │ │ └── uniqueidentifier.go │ ├── go-sql-driver │ │ └── mysql │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── AUTHORS │ │ │ ├── CHANGELOG.md │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── appengine.go │ │ │ ├── auth.go │ │ │ ├── buffer.go │ │ │ ├── collations.go │ │ │ ├── connection.go │ │ │ ├── const.go │ │ │ ├── driver.go │ │ │ ├── dsn.go │ │ │ ├── errors.go │ │ │ ├── fields.go │ │ │ ├── infile.go │ │ │ ├── packets.go │ │ │ ├── result.go │ │ │ ├── rows.go │ │ │ ├── statement.go │ │ │ ├── transaction.go │ │ │ └── utils.go │ ├── go-xorm │ │ ├── builder │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── builder.go │ │ │ ├── builder_delete.go │ │ │ ├── builder_insert.go │ │ │ ├── builder_limit.go │ │ │ ├── builder_select.go │ │ │ ├── builder_union.go │ │ │ ├── builder_update.go │ │ │ ├── cond.go │ │ │ ├── cond_and.go │ │ │ ├── cond_between.go │ │ │ ├── cond_compare.go │ │ │ ├── cond_eq.go │ │ │ ├── cond_expr.go │ │ │ ├── cond_in.go │ │ │ ├── cond_like.go │ │ │ ├── cond_neq.go │ │ │ ├── cond_not.go │ │ │ ├── cond_notin.go │ │ │ ├── cond_null.go │ │ │ ├── cond_or.go │ │ │ ├── doc.go │ │ │ ├── error.go │ │ │ ├── go.mod │ │ │ ├── sql.go │ │ │ └── string_builder.go │ │ ├── core │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── benchmark.sh │ │ │ ├── cache.go │ │ │ ├── column.go │ │ │ ├── converstion.go │ │ │ ├── db.go │ │ │ ├── dialect.go │ │ │ ├── driver.go │ │ │ ├── error.go │ │ │ ├── filter.go │ │ │ ├── go.mod │ │ │ ├── ilogger.go │ │ │ ├── index.go │ │ │ ├── mapper.go │ │ │ ├── pk.go │ │ │ ├── rows.go │ │ │ ├── scan.go │ │ │ ├── table.go │ │ │ └── type.go │ │ └── xorm │ │ │ ├── .gitignore │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── README_CN.md │ │ │ ├── cache_lru.go │ │ │ ├── cache_memory_store.go │ │ │ ├── circle.yml │ │ │ ├── context.go │ │ │ ├── context_cache.go │ │ │ ├── convert.go │ │ │ ├── dialect_mssql.go │ │ │ ├── dialect_mysql.go │ │ │ ├── dialect_oracle.go │ │ │ ├── dialect_postgres.go │ │ │ ├── dialect_sqlite3.go │ │ │ ├── doc.go │ │ │ ├── engine.go │ │ │ ├── engine_cond.go │ │ │ ├── engine_group.go │ │ │ ├── engine_group_policy.go │ │ │ ├── engine_table.go │ │ │ ├── error.go │ │ │ ├── gen_reserved.sh │ │ │ ├── go.mod │ │ │ ├── helpers.go │ │ │ ├── helpler_time.go │ │ │ ├── interface.go │ │ │ ├── logger.go │ │ │ ├── pg_reserved.txt │ │ │ ├── processors.go │ │ │ ├── rows.go │ │ │ ├── session.go │ │ │ ├── session_cols.go │ │ │ ├── session_cond.go │ │ │ ├── session_convert.go │ │ │ ├── session_delete.go │ │ │ ├── session_exist.go │ │ │ ├── session_find.go │ │ │ ├── session_get.go │ │ │ ├── session_insert.go │ │ │ ├── session_iterate.go │ │ │ ├── session_query.go │ │ │ ├── session_raw.go │ │ │ ├── session_schema.go │ │ │ ├── session_stats.go │ │ │ ├── session_tx.go │ │ │ ├── session_update.go │ │ │ ├── statement.go │ │ │ ├── syslogger.go │ │ │ ├── tag.go │ │ │ ├── test_mssql.sh │ │ │ ├── test_mssql_cache.sh │ │ │ ├── test_mymysql.sh │ │ │ ├── test_mymysql_cache.sh │ │ │ ├── test_mysql.sh │ │ │ ├── test_mysql_cache.sh │ │ │ ├── test_postgres.sh │ │ │ ├── test_postgres_cache.sh │ │ │ ├── test_sqlite.sh │ │ │ ├── test_sqlite_cache.sh │ │ │ ├── transaction.go │ │ │ ├── types.go │ │ │ └── xorm.go │ ├── lib │ │ └── pq │ │ │ ├── .gitignore │ │ │ ├── .travis.sh │ │ │ ├── .travis.yml │ │ │ ├── CONTRIBUTING.md │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── TESTS.md │ │ │ ├── array.go │ │ │ ├── buf.go │ │ │ ├── conn.go │ │ │ ├── conn_go18.go │ │ │ ├── connector.go │ │ │ ├── copy.go │ │ │ ├── doc.go │ │ │ ├── encode.go │ │ │ ├── error.go │ │ │ ├── notify.go │ │ │ ├── oid │ │ │ ├── doc.go │ │ │ ├── gen.go │ │ │ └── types.go │ │ │ ├── rows.go │ │ │ ├── ssl.go │ │ │ ├── ssl_go1.7.go │ │ │ ├── ssl_permissions.go │ │ │ ├── ssl_renegotiation.go │ │ │ ├── ssl_windows.go │ │ │ ├── url.go │ │ │ ├── user_posix.go │ │ │ ├── user_windows.go │ │ │ └── uuid.go │ ├── lunny │ │ └── log │ │ │ ├── .gitignore │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── README_CN.md │ │ │ ├── dbwriter.go │ │ │ ├── filewriter.go │ │ │ └── logext.go │ ├── mattn │ │ └── go-sqlite3 │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── backup.go │ │ │ ├── callback.go │ │ │ ├── doc.go │ │ │ ├── error.go │ │ │ ├── sqlite3-binding.c │ │ │ ├── sqlite3-binding.h │ │ │ ├── sqlite3.go │ │ │ ├── sqlite3_context.go │ │ │ ├── sqlite3_func_crypt.go │ │ │ ├── sqlite3_go18.go │ │ │ ├── sqlite3_libsqlite3.go │ │ │ ├── sqlite3_load_extension.go │ │ │ ├── sqlite3_load_extension_omit.go │ │ │ ├── sqlite3_opt_allow_uri_authority.go │ │ │ ├── sqlite3_opt_app_armor.go │ │ │ ├── sqlite3_opt_foreign_keys.go │ │ │ ├── sqlite3_opt_fts5.go │ │ │ ├── sqlite3_opt_icu.go │ │ │ ├── sqlite3_opt_introspect.go │ │ │ ├── sqlite3_opt_json1.go │ │ │ ├── sqlite3_opt_secure_delete.go │ │ │ ├── sqlite3_opt_secure_delete_fast.go │ │ │ ├── sqlite3_opt_stat4.go │ │ │ ├── sqlite3_opt_userauth.go │ │ │ ├── sqlite3_opt_userauth_omit.go │ │ │ ├── sqlite3_opt_vacuum_full.go │ │ │ ├── sqlite3_opt_vacuum_incr.go │ │ │ ├── sqlite3_opt_vtable.go │ │ │ ├── sqlite3_other.go │ │ │ ├── sqlite3_solaris.go │ │ │ ├── sqlite3_trace.go │ │ │ ├── sqlite3_type.go │ │ │ ├── sqlite3_usleep_windows.go │ │ │ ├── sqlite3_windows.go │ │ │ ├── sqlite3ext.h │ │ │ └── static_mock.go │ └── ziutek │ │ └── mymysql │ │ ├── LICENSE │ │ ├── godrv │ │ ├── appengine.go │ │ └── driver.go │ │ ├── mysql │ │ ├── errors.go │ │ ├── field.go │ │ ├── interface.go │ │ ├── row.go │ │ ├── status.go │ │ ├── types.go │ │ └── utils.go │ │ └── native │ │ ├── LICENSE │ │ ├── addons.go │ │ ├── binding.go │ │ ├── codecs.go │ │ ├── command.go │ │ ├── common.go │ │ ├── consts.go │ │ ├── init.go │ │ ├── mysql.go │ │ ├── packet.go │ │ ├── paramvalue.go │ │ ├── passwd.go │ │ ├── prepared.go │ │ ├── result.go │ │ └── unsafe.go-disabled ├── golang.org │ └── x │ │ └── crypto │ │ ├── AUTHORS │ │ ├── CONTRIBUTORS │ │ ├── LICENSE │ │ ├── PATENTS │ │ └── md4 │ │ ├── md4.go │ │ └── md4block.go ├── google.golang.org │ └── appengine │ │ ├── LICENSE │ │ └── cloudsql │ │ ├── cloudsql.go │ │ ├── cloudsql_classic.go │ │ └── cloudsql_vm.go └── modules.txt └── xorm.go /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Golang CircleCI 2.0 configuration file 2 | # 3 | # Check https://circleci.com/docs/2.0/language-go/ for more details 4 | version: 2 5 | jobs: 6 | build: 7 | docker: 8 | # specify the version 9 | - image: circleci/golang:1.10 10 | 11 | working_directory: /go/src/github.com/go-xorm/cmd 12 | steps: 13 | - checkout 14 | 15 | - run: go get -t -d -v ./... 16 | - run: go test ./... -v -race -coverprofile=coverage-1.txt -covermode=atomic 17 | - run: go get -u github.com/wadey/gocovmerge 18 | - run: gocovmerge coverage-1.txt > coverage.txt 19 | - run: bash <(curl -s https://codecov.io/bash) -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | .DS_Store -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, go-xorm 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | 2 | [English](https://github.com/go-xorm/cmd/blob/master/README.md) 3 | 4 | # xorm 工具 5 | 6 | xorm 是一组数据库操作命令行工具。 7 | 8 | ## 源码安装 9 | 10 | `go get github.com/go-xorm/cmd/xorm` 11 | 12 | 同时你需要安装如下依赖: 13 | 14 | * github.com/go-xorm/xorm 15 | 16 | * Mysql: [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) 17 | 18 | * MyMysql: [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql/godrv) 19 | 20 | * Postgres: [github.com/lib/pq](https://github.com/lib/pq) 21 | 22 | * SQLite: [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) 23 | 24 | * MSSQL: [github.com/denisenkom/go-mssqldb](https://github.com/denisenkom/go-mssqldb) 25 | 26 | ** 对于sqlite3的支持,你需要自己进行编译 `go build -tags sqlite3` 因为sqlite3需要cgo的支持。 27 | 28 | ## 命令列表 29 | 30 | 有如下可用的命令: 31 | 32 | * **reverse** 反转一个数据库结构,生成代码 33 | * **shell** 通用的数据库操作客户端,可对数据库结构和数据操作 34 | * **dump** Dump数据库中所有结构和数据到标准输出 35 | * **source** 从标注输入中执行SQL文件 36 | * **driver** 列出所有支持的数据库驱动 37 | 38 | ## 反转 39 | 40 | Reverse 命令让你根据数据库的表来生成结构体或者类代码文件。安装好工具之后,可以通过 41 | 42 | `xorm help reverse` 43 | 44 | 获得帮助。 45 | 46 | 例子: 47 | 48 | 首先要进入到当前项目的目录下,主要是后面的命令最后一个参数中用到的模版存放在当前项目的目录下 49 | 50 | `cd $GOPATH/src/github.com/go-xorm/cmd/xorm` 51 | 52 | sqlite: 53 | `xorm reverse sqite3 test.db templates/goxorm` 54 | 55 | mysql: 56 | `xorm reverse mysql root:@/xorm_test?charset=utf8 templates/goxorm` 57 | 58 | mymysql: 59 | `xorm reverse mymysql xorm_test2/root/ templates/goxorm` 60 | 61 | postgres: 62 | `xorm reverse postgres "dbname=xorm_test sslmode=disable" templates/goxorm` 63 | 64 | 之后将会生成代码 generated go files in `./model` directory 65 | 66 | ### 模版和配置 67 | 68 | 当前,默认支持Go,C++ 和 objc 代码的生成。具体可以查看源码下的 templates 目录。在每个模版目录中,需要放置一个配置文件来控制代码的生成。如下: 69 | 70 | ``` 71 | lang=go 72 | genJson=1 73 | ``` 74 | 75 | `lang` 目前支持 go, c++ 和 objc。 76 | `genJson` 可以为0或者1,如果是1则结构会包含json的tag,此项配置目前仅支持Go语言。 77 | 78 | ## Shell 79 | 80 | Shell command provides a tool to operate database. For example, you can create table, alter table, insert data, delete data and etc. 81 | 82 | `xorm shell sqlite3 test.db` will connect to the sqlite3 database and you can type `help` to list all the shell commands. 83 | 84 | ## Dump 85 | 86 | Dump command provides a tool to dump all database structs and data as SQL to your standard output. 87 | 88 | `xorm dump sqlite3 test.db` could dump sqlite3 database test.db to standard output. If you want to save to file, just 89 | type `xorm dump sqlite3 test.db > test.sql`. 90 | 91 | ## Source 92 | 93 | `xorm source sqlite3 test.db < test.sql` will execute sql file on the test.db. 94 | 95 | ## Driver 96 | 97 | List all supported drivers since default build will not include sqlite3. 98 | 99 | ## LICENSE 100 | 101 | BSD License 102 | [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) 103 | -------------------------------------------------------------------------------- /xorm/.gitignore: -------------------------------------------------------------------------------- 1 | xorm/xorm 2 | xorm.db -------------------------------------------------------------------------------- /xorm/.gopmfile: -------------------------------------------------------------------------------- 1 | [deps] 2 | github.com/go-xorm/xorm = 3 | github.com/go-sql-driver/mysql = 4 | github.com/go-xorm/core = 5 | github.com/go-xweb/log = 6 | github.com/lib/pq = 7 | github.com/ziutek/mymysql = 8 | 9 | [res] 10 | include = templates 11 | 12 | -------------------------------------------------------------------------------- /xorm/c++.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "strings" 9 | "text/template" 10 | 11 | "github.com/go-xorm/core" 12 | ) 13 | 14 | var ( 15 | CPlusTmpl LangTmpl = LangTmpl{ 16 | template.FuncMap{"Mapper": mapper.Table2Obj, 17 | "Type": cPlusTypeStr, 18 | "UnTitle": unTitle, 19 | }, 20 | nil, 21 | genCPlusImports, 22 | } 23 | ) 24 | 25 | func cPlusTypeStr(col *core.Column) string { 26 | tp := col.SQLType 27 | name := strings.ToUpper(tp.Name) 28 | switch name { 29 | case core.Bit, core.TinyInt, core.SmallInt, core.MediumInt, core.Int, core.Integer, core.Serial: 30 | return "int" 31 | case core.BigInt, core.BigSerial: 32 | return "__int64" 33 | case core.Char, core.Varchar, core.TinyText, core.Text, core.MediumText, core.LongText: 34 | return "tstring" 35 | case core.Date, core.DateTime, core.Time, core.TimeStamp: 36 | return "time_t" 37 | case core.Decimal, core.Numeric: 38 | return "tstring" 39 | case core.Real, core.Float: 40 | return "float" 41 | case core.Double: 42 | return "double" 43 | case core.TinyBlob, core.Blob, core.MediumBlob, core.LongBlob, core.Bytea: 44 | return "tstring" 45 | case core.Bool: 46 | return "bool" 47 | default: 48 | return "tstring" 49 | } 50 | return "" 51 | } 52 | 53 | func genCPlusImports(tables []*core.Table) map[string]string { 54 | imports := make(map[string]string) 55 | 56 | for _, table := range tables { 57 | for _, col := range table.Columns() { 58 | switch cPlusTypeStr(col) { 59 | case "time_t": 60 | imports[``] = `` 61 | case "tstring": 62 | imports[""] = "" 63 | //case "__int64": 64 | // imports[""] = "" 65 | } 66 | } 67 | } 68 | return imports 69 | } 70 | -------------------------------------------------------------------------------- /xorm/cmd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | "strings" 11 | ) 12 | 13 | // A Command is an implementation of a go command 14 | // like go build or go fix. 15 | type Command struct { 16 | // Run runs the command. 17 | // The args are the arguments after the command name. 18 | Run func(cmd *Command, args []string) 19 | 20 | // UsageLine is the one-line usage message. 21 | // The first word in the line is taken to be the command name. 22 | UsageLine string 23 | 24 | // Short is the short description shown in the 'go help' output. 25 | Short string 26 | 27 | // Long is the long message shown in the 'go help ' output. 28 | Long string 29 | 30 | // Flag is a set of flags specific to this command. 31 | Flags map[string]bool 32 | } 33 | 34 | // Name returns the command's name: the first word in the usage line. 35 | func (c *Command) Name() string { 36 | name := c.UsageLine 37 | i := strings.Index(name, " ") 38 | if i >= 0 { 39 | name = name[:i] 40 | } 41 | return name 42 | } 43 | 44 | func (c *Command) Usage() { 45 | fmt.Fprintf(os.Stderr, "usage: %s\n\n", c.UsageLine) 46 | fmt.Fprintf(os.Stderr, "%s\n", strings.TrimSpace(c.Long)) 47 | os.Exit(2) 48 | } 49 | 50 | // Runnable reports whether the command can be run; otherwise 51 | // it is a documentation pseudo-command such as importpath. 52 | func (c *Command) Runnable() bool { 53 | return c.Run != nil 54 | } 55 | 56 | // checkFlags checks if the flag exists with correct format. 57 | func checkFlags(flags map[string]bool, args []string, print func(string)) int { 58 | num := 0 // Number of valid flags, use to cut out. 59 | for i, f := range args { 60 | // Check flag prefix '-'. 61 | if !strings.HasPrefix(f, "-") { 62 | // Not a flag, finish check process. 63 | break 64 | } 65 | 66 | // Check if it a valid flag. 67 | if v, ok := flags[f]; ok { 68 | flags[f] = !v 69 | if !v { 70 | print(f) 71 | } else { 72 | fmt.Println("DISABLE: " + f) 73 | } 74 | } else { 75 | fmt.Printf("[ERRO] Unknown flag: %s.\n", f) 76 | return -1 77 | } 78 | num = i + 1 79 | } 80 | 81 | return num 82 | } 83 | -------------------------------------------------------------------------------- /xorm/driver.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import "fmt" 8 | 9 | var CmdDriver = &Command{ 10 | UsageLine: "driver", 11 | Short: "list all supported drivers", 12 | Long: ` 13 | list all supported drivers 14 | `, 15 | } 16 | 17 | func init() { 18 | CmdDriver.Run = runDriver 19 | CmdDriver.Flags = map[string]bool{} 20 | } 21 | 22 | func runDriver(cmd *Command, args []string) { 23 | for n, d := range supportedDrivers { 24 | fmt.Println(n, "\t", d) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /xorm/dump.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | 11 | "github.com/go-xorm/core" 12 | "github.com/go-xorm/xorm" 13 | ) 14 | 15 | var CmdDump = &Command{ 16 | UsageLine: "dump driverName datasourceName", 17 | Short: "dump database all table struct's and data to standard output", 18 | Long: ` 19 | dump database for sqlite3, mysql, postgres. 20 | 21 | driverName Database driver name, now supported four: mysql mymysql sqlite3 postgres 22 | datasourceName Database connection uri, for detail infomation please visit driver's project page 23 | `, 24 | } 25 | 26 | func init() { 27 | CmdDump.Run = runDump 28 | CmdDump.Flags = map[string]bool{} 29 | } 30 | 31 | func runDump(cmd *Command, args []string) { 32 | if len(args) != 2 { 33 | fmt.Println("params error, please see xorm help dump") 34 | return 35 | } 36 | 37 | var err error 38 | engine, err = xorm.NewEngine(args[0], args[1]) 39 | if err != nil { 40 | fmt.Println(err) 41 | return 42 | } 43 | 44 | engine.ShowSQL(false) 45 | engine.Logger().SetLevel(core.LOG_UNKNOWN) 46 | 47 | err = engine.Ping() 48 | if err != nil { 49 | fmt.Println(err) 50 | return 51 | } 52 | 53 | err = engine.DumpAll(os.Stdout) 54 | if err != nil { 55 | fmt.Println(err) 56 | return 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /xorm/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-xorm/cmd/xorm 2 | 3 | require ( 4 | cloud.google.com/go v0.37.0 // indirect 5 | github.com/cockroachdb/apd v1.1.0 // indirect 6 | github.com/denisenkom/go-mssqldb v0.0.0-20180707235734-242fa5aa1b45 7 | github.com/go-sql-driver/mysql v0.0.0-20180719071942-99ff426eb706 8 | github.com/go-xorm/builder v0.0.0-20180826070321-377feedb49e3 // indirect 9 | github.com/go-xorm/core v0.6.1-0.20181008132326-6bc9412b1c4d 10 | github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a // indirect 11 | github.com/go-xorm/xorm v0.0.0-20180925133144-7a9249de3324 12 | github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect 13 | github.com/jackc/pgx v3.2.0+incompatible // indirect 14 | github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 15 | github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de 16 | github.com/mattn/go-sqlite3 v1.9.0 17 | github.com/pkg/errors v0.8.0 // indirect 18 | github.com/satori/go.uuid v1.2.0 // indirect 19 | github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24 // indirect 20 | github.com/ziutek/mymysql v0.0.0-20171217234033-ff6cc86d3d93 21 | golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a // indirect 22 | gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect 23 | ) 24 | -------------------------------------------------------------------------------- /xorm/lang.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "io/ioutil" 9 | "strings" 10 | "text/template" 11 | 12 | "github.com/go-xorm/core" 13 | ) 14 | 15 | type LangTmpl struct { 16 | Funcs template.FuncMap 17 | Formater func(string) (string, error) 18 | GenImports func([]*core.Table) map[string]string 19 | } 20 | 21 | var ( 22 | mapper = &core.SnakeMapper{} 23 | langTmpls = map[string]LangTmpl{ 24 | "go": GoLangTmpl, 25 | "c++": CPlusTmpl, 26 | "objc": ObjcTmpl, 27 | } 28 | ) 29 | 30 | func loadConfig(f string) map[string]string { 31 | bts, err := ioutil.ReadFile(f) 32 | if err != nil { 33 | return nil 34 | } 35 | configs := make(map[string]string) 36 | lines := strings.Split(string(bts), "\n") 37 | for _, line := range lines { 38 | line = strings.TrimRight(line, "\r") 39 | vs := strings.Split(line, "=") 40 | if len(vs) == 2 { 41 | configs[strings.TrimSpace(vs[0])] = strings.TrimSpace(vs[1]) 42 | } 43 | } 44 | return configs 45 | } 46 | 47 | func unTitle(src string) string { 48 | if src == "" { 49 | return "" 50 | } 51 | 52 | if len(src) == 1 { 53 | return strings.ToLower(string(src[0])) 54 | } else { 55 | return strings.ToLower(string(src[0])) + src[1:] 56 | } 57 | } 58 | 59 | func upTitle(src string) string { 60 | if src == "" { 61 | return "" 62 | } 63 | 64 | return strings.ToUpper(src) 65 | } 66 | -------------------------------------------------------------------------------- /xorm/objc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | //"fmt" 9 | "strings" 10 | "text/template" 11 | 12 | "github.com/go-xorm/core" 13 | ) 14 | 15 | var ( 16 | ObjcTmpl LangTmpl = LangTmpl{ 17 | template.FuncMap{"Mapper": mapper.Table2Obj, 18 | "Type": objcTypeStr, 19 | "UnTitle": unTitle, 20 | }, 21 | nil, 22 | genCPlusImports, 23 | } 24 | ) 25 | 26 | func objcTypeStr(col *core.Column) string { 27 | tp := col.SQLType 28 | name := strings.ToUpper(tp.Name) 29 | switch name { 30 | case core.Bit, core.TinyInt, core.SmallInt, core.MediumInt, core.Int, core.Integer, core.Serial: 31 | return "int" 32 | case core.BigInt, core.BigSerial: 33 | return "long" 34 | case core.Char, core.Varchar, core.TinyText, core.Text, core.MediumText, core.LongText: 35 | return "NSString*" 36 | case core.Date, core.DateTime, core.Time, core.TimeStamp: 37 | return "NSString*" 38 | case core.Decimal, core.Numeric: 39 | return "NSString*" 40 | case core.Real, core.Float: 41 | return "float" 42 | case core.Double: 43 | return "double" 44 | case core.TinyBlob, core.Blob, core.MediumBlob, core.LongBlob, core.Bytea: 45 | return "NSString*" 46 | case core.Bool: 47 | return "BOOL" 48 | default: 49 | return "NSString*" 50 | } 51 | return "" 52 | } 53 | 54 | func genObjcImports(tables []*core.Table) map[string]string { 55 | imports := make(map[string]string) 56 | 57 | for _, table := range tables { 58 | for _, col := range table.Columns() { 59 | switch objcTypeStr(col) { 60 | case "time_t": 61 | imports[``] = `` 62 | case "tstring": 63 | imports[""] = "" 64 | //case "__int64": 65 | // imports[""] = "" 66 | } 67 | } 68 | } 69 | return imports 70 | } 71 | -------------------------------------------------------------------------------- /xorm/source.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package main 6 | 7 | import ( 8 | "fmt" 9 | "os" 10 | 11 | "github.com/go-xorm/core" 12 | "github.com/go-xorm/xorm" 13 | ) 14 | 15 | var CmdSource = &Command{ 16 | UsageLine: "source driverName datasourceName", 17 | Short: "source execute std in to datasourceName", 18 | Long: ` 19 | source from standard std in for sqlite3, mysql, postgres. 20 | 21 | driverName Database driver name, now supported four: mysql mymysql sqlite3 postgres 22 | datasourceName Database connection uri, for detail infomation please visit driver's project page 23 | `, 24 | } 25 | 26 | func init() { 27 | CmdSource.Run = runSource 28 | CmdSource.Flags = map[string]bool{} 29 | } 30 | 31 | func runSource(cmd *Command, args []string) { 32 | if len(args) != 2 { 33 | fmt.Println("params error, please see xorm help source") 34 | return 35 | } 36 | 37 | var err error 38 | engine, err = xorm.NewEngine(args[0], args[1]) 39 | if err != nil { 40 | fmt.Println(err) 41 | return 42 | } 43 | 44 | engine.ShowSQL(false) 45 | engine.Logger().SetLevel(core.LOG_UNKNOWN) 46 | 47 | err = engine.Ping() 48 | if err != nil { 49 | fmt.Println(err) 50 | return 51 | } 52 | 53 | _, err = engine.Import(os.Stdin) 54 | if err.Error() == "not an error" { 55 | err = nil 56 | } 57 | if err != nil { 58 | fmt.Println(err) 59 | return 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /xorm/sqlite3.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build sqlite3 6 | 7 | package main 8 | 9 | import ( 10 | _ "github.com/mattn/go-sqlite3" 11 | ) 12 | 13 | func init() { 14 | supportedDrivers["sqlite3"] = "github.com/mattn/go-sqlite3" 15 | } 16 | -------------------------------------------------------------------------------- /xorm/templates/c++/class.h.tpl: -------------------------------------------------------------------------------- 1 | {{ range .Imports}} 2 | #include {{.}} 3 | {{ end }} 4 | 5 | {{range .Tables}}class {{Mapper .Name}} { 6 | {{$table := .}} 7 | public: 8 | {{range .Columns}}{{$name := Mapper .Name}} {{Type .}} Get{{Mapper .Name}}() { 9 | return this->m_{{UnTitle $name}}; 10 | } 11 | 12 | void Set{{$name}}({{Type .}} {{UnTitle $name}}) { 13 | this->m_{{UnTitle $name}} = {{UnTitle $name}}; 14 | } 15 | 16 | {{end}}private: 17 | {{range .Columns}}{{$name := Mapper .Name}} {{Type .}} m_{{UnTitle $name}}; 18 | {{end}} 19 | } 20 | 21 | {{end}} -------------------------------------------------------------------------------- /xorm/templates/c++/config: -------------------------------------------------------------------------------- 1 | lang=c++ -------------------------------------------------------------------------------- /xorm/templates/dict/config: -------------------------------------------------------------------------------- 1 | lang=go 2 | ignoreColumnsJSON= -------------------------------------------------------------------------------- /xorm/templates/dict/struct.html.tpl: -------------------------------------------------------------------------------- 1 | 2 | {{range .Tables}} 3 | 4 | 5 | 6 | {{range .Columns}} 7 | 8 | 9 | 10 | {{end}} 11 |
{{.Name}}
列名类型长度默认值备注
{{.Name}}{{.SQLType.Name}}{{if .SQLType.DefaultLength}}{{.SQLType.DefaultLength}}{{end}}{{.Default}}{{.Comment}}
12 |
13 | {{end}} -------------------------------------------------------------------------------- /xorm/templates/go/config: -------------------------------------------------------------------------------- 1 | lang=go 2 | ignoreColumnsJSON= -------------------------------------------------------------------------------- /xorm/templates/go/struct.go.tpl: -------------------------------------------------------------------------------- 1 | package {{.Models}} 2 | 3 | import ( 4 | {{range .Imports}}"{{.}}"{{end}} 5 | ) 6 | 7 | {{range .Tables}} 8 | type {{Mapper .Name}} struct { 9 | {{$table := .}} 10 | {{range .Columns}} {{Mapper .Name}} {{Type .}} 11 | {{end}} 12 | } 13 | 14 | {{end}} -------------------------------------------------------------------------------- /xorm/templates/gomeddler/config: -------------------------------------------------------------------------------- 1 | lang=go 2 | -------------------------------------------------------------------------------- /xorm/templates/gomeddler/struct.go.tpl: -------------------------------------------------------------------------------- 1 | package {{.Models}} 2 | 3 | {{$ilen := len .Imports}} 4 | {{if gt $ilen 0}} 5 | import ( 6 | {{range .Imports}}"{{.}}"{{end}} 7 | ) 8 | {{end}} 9 | 10 | {{range .Tables}} 11 | type {{Mapper .Name}} struct { 12 | {{$table := .}} 13 | {{range .ColumnsSeq}}{{$col := $table.GetColumn .}} {{Mapper $col.Name}} {{Type $col}} `meddler:"{{$col.Name}}{{if $col.IsPrimaryKey}},pk{{end}}{{if $col.Nullable}},zeroisnull{{end}}"` 14 | {{end}} 15 | } 16 | 17 | {{end}} 18 | -------------------------------------------------------------------------------- /xorm/templates/goxorm/config: -------------------------------------------------------------------------------- 1 | lang=go 2 | genJson=0 3 | prefix=cos_ 4 | ignoreColumnsJSON= 5 | created= 6 | updated= 7 | deleted= -------------------------------------------------------------------------------- /xorm/templates/goxorm/struct.go.tpl: -------------------------------------------------------------------------------- 1 | package {{.Models}} 2 | 3 | {{$ilen := len .Imports}} 4 | {{if gt $ilen 0}} 5 | import ( 6 | {{range .Imports}}"{{.}}"{{end}} 7 | ) 8 | {{end}} 9 | 10 | {{range .Tables}} 11 | type {{Mapper .Name}} struct { 12 | {{$table := .}} 13 | {{range .ColumnsSeq}}{{$col := $table.GetColumn .}} {{Mapper $col.Name}} {{Type $col}} {{Tag $table $col}} 14 | {{end}} 15 | } 16 | {{end}} 17 | 18 | -------------------------------------------------------------------------------- /xorm/templates/objc/class.h.tpl: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | {{range .Tables}}@interface {{Mapper .Name}} : NSObject 4 | 5 | {{range .Columns}}@property(nonatomic,{{if eq (Type .) "NSString*"}}retain{{else}}assign{{end}}) {{Type .}} {{if eq .Name "id"}}remote_id{{else}}{{Mapper .Name}}{{end}}; 6 | {{end}} 7 | +({{Mapper .Name}} *)paserJson:(NSString *)jsonString; 8 | -(NSString *)toJson; 9 | 10 | @end 11 | {{end}} -------------------------------------------------------------------------------- /xorm/templates/objc/class.m.tpl: -------------------------------------------------------------------------------- 1 | {{range .Tables}} 2 | #import "{{UnTitle (Mapper .Name)}}.h" 3 | #import "../NSDictionary+json.h" 4 | 5 | @implementation {{Mapper .Name}} 6 | {{$name := .Name}} 7 | +({{Mapper .Name}} *)paserJson:(NSString *)jsonString{ 8 | NSError *error = nil; 9 | if (jsonString == nil){ 10 | return nil; 11 | } 12 | id jsonObject = [NSJSONSerialization JSONObjectWithData:[jsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error]; 13 | if (jsonObject != nil && [jsonObject isKindOfClass:[NSDictionary class]]) { 14 | NSDictionary *json = (NSDictionary*)jsonObject; 15 | 16 | {{Mapper .Name}} *{{.Name}} = [[[{{Mapper .Name}} alloc]init] autorelease]; 17 | {{range .Columns}}{{if or (eq (Type .) "int") (eq (Type .) "long")}}{{if eq .Name "id"}}{{$name}}.remote_id = [[json valueForKey:@"{{Mapper .Name}}"] longValue]; 18 | {{else}}{{$name}}.{{Mapper .Name}} = [[json valueForKey:@"{{Mapper .Name}}"] longValue]; 19 | {{end}}{{else if eq (Type .) "BOOL"}}{{$name}}.{{Mapper .Name}} = [[json valueForKey:@"{{Mapper .Name}}"] boolValue]; 20 | {{else if eq (Type .) "float"}}{{$name}}.{{Mapper .Name}} = [[json valueForKey:@"{{Mapper .Name}}"] floatValue]; 21 | {{else if eq (Type .) "double"}}{{$name}}.{{Mapper .Name}} = [[json valueForKey:@"{{Mapper .Name}}"] doubleValue]; 22 | {{else}}{{$name}}.{{Mapper .Name}} = [json valueForKey:@"{{Mapper .Name}}"]; 23 | {{end}}{{end}} 24 | return {{$name}}; 25 | } 26 | 27 | return nil; 28 | } 29 | 30 | -(NSString *)toJson{ 31 | NSMutableDictionary *json = [[NSMutableDictionary alloc]init]; 32 | 33 | {{range .Columns}}{{if or (eq (Type .) "int") (eq (Type .) "long") (eq (Type .) "float") (eq (Type .) "double")}}{{if eq .Name "id"}}[json setValue:[NSNumber numberWithLong:self.remote_id] forKey:@"{{Mapper .Name}}"]; 34 | {{else}}[json setValue:[NSNumber numberWithLong:self.{{Mapper .Name}}] forKey:@"{{Mapper .Name}}"]; 35 | {{end}}{{else}}[json setValue:self.{{Mapper .Name}} forKey:@"{{Mapper .Name}}"]; 36 | {{end}}{{end}} 37 | 38 | NSError *error = nil; 39 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:json options:kNilOptions error:&error]; 40 | [json release]; 41 | if (jsonData == nil){ 42 | return @""; 43 | } 44 | 45 | return [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding]; 46 | } 47 | 48 | -(void)dealloc{ 49 | 50 | {{range .Columns}}{{if eq (Type .) "NSString*"}}[_{{Mapper .Name}} release]; 51 | {{end}}{{end}} 52 | [super dealloc]; 53 | } 54 | 55 | @end 56 | 57 | {{end}} -------------------------------------------------------------------------------- /xorm/templates/objc/config: -------------------------------------------------------------------------------- 1 | lang=objc -------------------------------------------------------------------------------- /xorm/vendor/cloud.google.com/go/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of cloud authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as: 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | Filippo Valsorda 10 | Google Inc. 11 | Ingo Oeser 12 | Palm Stone Games, Inc. 13 | Paweł Knap 14 | Péter Szilágyi 15 | Tyler Treat 16 | -------------------------------------------------------------------------------- /xorm/vendor/cloud.google.com/go/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # People who have agreed to one of the CLAs and can contribute patches. 2 | # The AUTHORS file lists the copyright holders; this file 3 | # lists people. For example, Google employees are listed here 4 | # but not in AUTHORS, because Google holds the copyright. 5 | # 6 | # https://developers.google.com/open-source/cla/individual 7 | # https://developers.google.com/open-source/cla/corporate 8 | # 9 | # Names should be added to this file as: 10 | # Name 11 | 12 | # Keep the list alphabetically sorted. 13 | 14 | Alexis Hunt 15 | Andreas Litt 16 | Andrew Gerrand 17 | Brad Fitzpatrick 18 | Burcu Dogan 19 | Dave Day 20 | David Sansome 21 | David Symonds 22 | Filippo Valsorda 23 | Glenn Lewis 24 | Ingo Oeser 25 | James Hall 26 | Johan Euphrosine 27 | Jonathan Amsterdam 28 | Kunpei Sakai 29 | Luna Duclos 30 | Magnus Hiie 31 | Mario Castro 32 | Michael McGreevy 33 | Omar Jarjur 34 | Paweł Knap 35 | Péter Szilágyi 36 | Sarah Adams 37 | Thanatat Tamtan 38 | Toby Burress 39 | Tuo Shan 40 | Tyler Treat 41 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb 6 | 7 | environment: 8 | GOPATH: c:\gopath 9 | HOST: localhost 10 | SQLUSER: sa 11 | SQLPASSWORD: Password12! 12 | DATABASE: test 13 | GOVERSION: 110 14 | matrix: 15 | - GOVERSION: 18 16 | SQLINSTANCE: SQL2016 17 | - GOVERSION: 19 18 | SQLINSTANCE: SQL2016 19 | - GOVERSION: 110 20 | SQLINSTANCE: SQL2016 21 | - SQLINSTANCE: SQL2014 22 | - SQLINSTANCE: SQL2012SP1 23 | - SQLINSTANCE: SQL2008R2SP2 24 | 25 | install: 26 | - set GOROOT=c:\go%GOVERSION% 27 | - set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH% 28 | - go version 29 | - go env 30 | - go get -u cloud.google.com/go/civil 31 | 32 | build_script: 33 | - go build 34 | 35 | before_test: 36 | # setup SQL Server 37 | - ps: | 38 | $instanceName = $env:SQLINSTANCE 39 | Start-Service "MSSQL`$$instanceName" 40 | Start-Service "SQLBrowser" 41 | - sqlcmd -S "(local)\%SQLINSTANCE%" -Q "Use [master]; CREATE DATABASE test;" 42 | - sqlcmd -S "(local)\%SQLINSTANCE%" -h -1 -Q "set nocount on; Select @@version" 43 | - pip install codecov 44 | 45 | 46 | test_script: 47 | - go test -race -cpu 4 -coverprofile=coverage.txt -covermode=atomic 48 | - codecov -f coverage.txt 49 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/bulkcopy_sql.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "context" 5 | "database/sql/driver" 6 | "encoding/json" 7 | "errors" 8 | ) 9 | 10 | type copyin struct { 11 | cn *Conn 12 | bulkcopy *Bulk 13 | closed bool 14 | } 15 | 16 | type serializableBulkConfig struct { 17 | TableName string 18 | ColumnsName []string 19 | Options BulkOptions 20 | } 21 | 22 | func (d *Driver) OpenConnection(dsn string) (*Conn, error) { 23 | return d.open(context.Background(), dsn) 24 | } 25 | 26 | func (c *Conn) prepareCopyIn(ctx context.Context, query string) (_ driver.Stmt, err error) { 27 | config_json := query[11:] 28 | 29 | bulkconfig := serializableBulkConfig{} 30 | err = json.Unmarshal([]byte(config_json), &bulkconfig) 31 | if err != nil { 32 | return 33 | } 34 | 35 | bulkcopy := c.CreateBulkContext(ctx, bulkconfig.TableName, bulkconfig.ColumnsName) 36 | bulkcopy.Options = bulkconfig.Options 37 | 38 | ci := ©in{ 39 | cn: c, 40 | bulkcopy: bulkcopy, 41 | } 42 | 43 | return ci, nil 44 | } 45 | 46 | func CopyIn(table string, options BulkOptions, columns ...string) string { 47 | bulkconfig := &serializableBulkConfig{TableName: table, Options: options, ColumnsName: columns} 48 | 49 | config_json, err := json.Marshal(bulkconfig) 50 | if err != nil { 51 | panic(err) 52 | } 53 | 54 | stmt := "INSERTBULK " + string(config_json) 55 | 56 | return stmt 57 | } 58 | 59 | func (ci *copyin) NumInput() int { 60 | return -1 61 | } 62 | 63 | func (ci *copyin) Query(v []driver.Value) (r driver.Rows, err error) { 64 | panic("should never be called") 65 | } 66 | 67 | func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) { 68 | if ci.closed { 69 | return nil, errors.New("errCopyInClosed") 70 | } 71 | 72 | if len(v) == 0 { 73 | rowCount, err := ci.bulkcopy.Done() 74 | ci.closed = true 75 | return driver.RowsAffected(rowCount), err 76 | } 77 | 78 | t := make([]interface{}, len(v)) 79 | for i, val := range v { 80 | t[i] = val 81 | } 82 | 83 | err = ci.bulkcopy.AddRow(t) 84 | if err != nil { 85 | return 86 | } 87 | 88 | return driver.RowsAffected(0), nil 89 | } 90 | 91 | func (ci *copyin) Close() (err error) { 92 | return nil 93 | } 94 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/doc.go: -------------------------------------------------------------------------------- 1 | // package mssql implements the TDS protocol used to connect to MS SQL Server (sqlserver) 2 | // database servers. 3 | // 4 | // This package registers the driver: 5 | // sqlserver: uses native "@" parameter placeholder names and does no pre-processing. 6 | // 7 | // If the ordinal position is used for query parameters, identifiers will be named 8 | // "@p1", "@p2", ... "@pN". 9 | // 10 | // Please refer to the README for the format of the DSN. There are multiple DSN 11 | // formats accepted: ADO style, ODBC style, and URL style. The following is an 12 | // example of a URL style DSN: 13 | // sqlserver://sa:mypass@localhost:1234?database=master&connection+timeout=30 14 | package mssql 15 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/error.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Error represents an SQL Server error. This 8 | // type includes methods for reading the contents 9 | // of the struct, which allows calling programs 10 | // to check for specific error conditions without 11 | // having to import this package directly. 12 | type Error struct { 13 | Number int32 14 | State uint8 15 | Class uint8 16 | Message string 17 | ServerName string 18 | ProcName string 19 | LineNo int32 20 | } 21 | 22 | func (e Error) Error() string { 23 | return "mssql: " + e.Message 24 | } 25 | 26 | // SQLErrorNumber returns the SQL Server error number. 27 | func (e Error) SQLErrorNumber() int32 { 28 | return e.Number 29 | } 30 | 31 | func (e Error) SQLErrorState() uint8 { 32 | return e.State 33 | } 34 | 35 | func (e Error) SQLErrorClass() uint8 { 36 | return e.Class 37 | } 38 | 39 | func (e Error) SQLErrorMessage() string { 40 | return e.Message 41 | } 42 | 43 | func (e Error) SQLErrorServerName() string { 44 | return e.ServerName 45 | } 46 | 47 | func (e Error) SQLErrorProcName() string { 48 | return e.ProcName 49 | } 50 | 51 | func (e Error) SQLErrorLineNo() int32 { 52 | return e.LineNo 53 | } 54 | 55 | type StreamError struct { 56 | Message string 57 | } 58 | 59 | func (e StreamError) Error() string { 60 | return e.Message 61 | } 62 | 63 | func streamErrorf(format string, v ...interface{}) StreamError { 64 | return StreamError{"Invalid TDS stream: " + fmt.Sprintf(format, v...)} 65 | } 66 | 67 | func badStreamPanic(err error) { 68 | panic(err) 69 | } 70 | 71 | func badStreamPanicf(format string, v ...interface{}) { 72 | panic(streamErrorf(format, v...)) 73 | } 74 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/internal/cp/collation.go: -------------------------------------------------------------------------------- 1 | package cp 2 | 3 | // http://msdn.microsoft.com/en-us/library/dd340437.aspx 4 | 5 | type Collation struct { 6 | LcidAndFlags uint32 7 | SortId uint8 8 | } 9 | 10 | func (c Collation) getLcid() uint32 { 11 | return c.LcidAndFlags & 0x000fffff 12 | } 13 | 14 | func (c Collation) getFlags() uint32 { 15 | return (c.LcidAndFlags & 0x0ff00000) >> 20 16 | } 17 | 18 | func (c Collation) getVersion() uint32 { 19 | return (c.LcidAndFlags & 0xf0000000) >> 28 20 | } 21 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/log.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "log" 5 | ) 6 | 7 | type Logger interface { 8 | Printf(format string, v ...interface{}) 9 | Println(v ...interface{}) 10 | } 11 | 12 | type optionalLogger struct { 13 | logger Logger 14 | } 15 | 16 | func (o optionalLogger) Printf(format string, v ...interface{}) { 17 | if o.logger != nil { 18 | o.logger.Printf(format, v...) 19 | } else { 20 | log.Printf(format, v...) 21 | } 22 | } 23 | 24 | func (o optionalLogger) Println(v ...interface{}) { 25 | if o.logger != nil { 26 | o.logger.Println(v...) 27 | } else { 28 | log.Println(v...) 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/mssql_go110.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package mssql 4 | 5 | import ( 6 | "context" 7 | "database/sql/driver" 8 | ) 9 | 10 | var _ driver.Connector = &Connector{} 11 | var _ driver.SessionResetter = &Conn{} 12 | 13 | func (c *Conn) ResetSession(ctx context.Context) error { 14 | if !c.connectionGood { 15 | return driver.ErrBadConn 16 | } 17 | c.resetSession = true 18 | 19 | if c.connector == nil || len(c.connector.SessionInitSQL) == 0 { 20 | return nil 21 | } 22 | 23 | s, err := c.prepareContext(ctx, c.connector.SessionInitSQL) 24 | if err != nil { 25 | return driver.ErrBadConn 26 | } 27 | _, err = s.exec(ctx, nil) 28 | if err != nil { 29 | return driver.ErrBadConn 30 | } 31 | 32 | return nil 33 | } 34 | 35 | // Connect to the server and return a TDS connection. 36 | func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) { 37 | conn, err := c.driver.connect(ctx, c.params) 38 | if conn != nil { 39 | conn.connector = c 40 | } 41 | if err == nil { 42 | err = conn.ResetSession(ctx) 43 | } 44 | return conn, err 45 | } 46 | 47 | // Driver underlying the Connector. 48 | func (c *Connector) Driver() driver.Driver { 49 | return c.driver 50 | } 51 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/mssql_go19pre.go: -------------------------------------------------------------------------------- 1 | // +build !go1.9 2 | 3 | package mssql 4 | 5 | import ( 6 | "database/sql/driver" 7 | "fmt" 8 | ) 9 | 10 | func (s *Stmt) makeParamExtra(val driver.Value) (param, error) { 11 | return param{}, fmt.Errorf("mssql: unknown type for %T", val) 12 | } 13 | 14 | func scanIntoOut(name string, fromServer, scanInto interface{}) error { 15 | return fmt.Errorf("mssql: unsupported OUTPUT type, use a newer Go version") 16 | } 17 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/net.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "time" 7 | ) 8 | 9 | type timeoutConn struct { 10 | c net.Conn 11 | timeout time.Duration 12 | buf *tdsBuffer 13 | packetPending bool 14 | continueRead bool 15 | } 16 | 17 | func newTimeoutConn(conn net.Conn, timeout time.Duration) *timeoutConn { 18 | return &timeoutConn{ 19 | c: conn, 20 | timeout: timeout, 21 | } 22 | } 23 | 24 | func (c *timeoutConn) Read(b []byte) (n int, err error) { 25 | if c.buf != nil { 26 | if c.packetPending { 27 | c.packetPending = false 28 | err = c.buf.FinishPacket() 29 | if err != nil { 30 | err = fmt.Errorf("Cannot send handshake packet: %s", err.Error()) 31 | return 32 | } 33 | c.continueRead = false 34 | } 35 | if !c.continueRead { 36 | var packet packetType 37 | packet, err = c.buf.BeginRead() 38 | if err != nil { 39 | err = fmt.Errorf("Cannot read handshake packet: %s", err.Error()) 40 | return 41 | } 42 | if packet != packPrelogin { 43 | err = fmt.Errorf("unexpected packet %d, expecting prelogin", packet) 44 | return 45 | } 46 | c.continueRead = true 47 | } 48 | n, err = c.buf.Read(b) 49 | return 50 | } 51 | if c.timeout > 0 { 52 | err = c.c.SetDeadline(time.Now().Add(c.timeout)) 53 | if err != nil { 54 | return 55 | } 56 | } 57 | return c.c.Read(b) 58 | } 59 | 60 | func (c *timeoutConn) Write(b []byte) (n int, err error) { 61 | if c.buf != nil { 62 | if !c.packetPending { 63 | c.buf.BeginPacket(packPrelogin, false) 64 | c.packetPending = true 65 | } 66 | n, err = c.buf.Write(b) 67 | if err != nil { 68 | return 69 | } 70 | return 71 | } 72 | if c.timeout > 0 { 73 | err = c.c.SetDeadline(time.Now().Add(c.timeout)) 74 | if err != nil { 75 | return 76 | } 77 | } 78 | return c.c.Write(b) 79 | } 80 | 81 | func (c timeoutConn) Close() error { 82 | return c.c.Close() 83 | } 84 | 85 | func (c timeoutConn) LocalAddr() net.Addr { 86 | return c.c.LocalAddr() 87 | } 88 | 89 | func (c timeoutConn) RemoteAddr() net.Addr { 90 | return c.c.RemoteAddr() 91 | } 92 | 93 | func (c timeoutConn) SetDeadline(t time.Time) error { 94 | panic("Not implemented") 95 | } 96 | 97 | func (c timeoutConn) SetReadDeadline(t time.Time) error { 98 | panic("Not implemented") 99 | } 100 | 101 | func (c timeoutConn) SetWriteDeadline(t time.Time) error { 102 | panic("Not implemented") 103 | } 104 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/rpc.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "encoding/binary" 5 | ) 6 | 7 | type procId struct { 8 | id uint16 9 | name string 10 | } 11 | 12 | // parameter flags 13 | const ( 14 | fByRevValue = 1 15 | fDefaultValue = 2 16 | ) 17 | 18 | type param struct { 19 | Name string 20 | Flags uint8 21 | ti typeInfo 22 | buffer []byte 23 | } 24 | 25 | const ( 26 | fWithRecomp = 1 27 | fNoMetaData = 2 28 | fReuseMetaData = 4 29 | ) 30 | 31 | var ( 32 | sp_Cursor = procId{1, ""} 33 | sp_CursorOpen = procId{2, ""} 34 | sp_CursorPrepare = procId{3, ""} 35 | sp_CursorExecute = procId{4, ""} 36 | sp_CursorPrepExec = procId{5, ""} 37 | sp_CursorUnprepare = procId{6, ""} 38 | sp_CursorFetch = procId{7, ""} 39 | sp_CursorOption = procId{8, ""} 40 | sp_CursorClose = procId{9, ""} 41 | sp_ExecuteSql = procId{10, ""} 42 | sp_Prepare = procId{11, ""} 43 | sp_PrepExec = procId{13, ""} 44 | sp_PrepExecRpc = procId{14, ""} 45 | sp_Unprepare = procId{15, ""} 46 | ) 47 | 48 | // http://msdn.microsoft.com/en-us/library/dd357576.aspx 49 | func sendRpc(buf *tdsBuffer, headers []headerStruct, proc procId, flags uint16, params []param, resetSession bool) (err error) { 50 | buf.BeginPacket(packRPCRequest, resetSession) 51 | writeAllHeaders(buf, headers) 52 | if len(proc.name) == 0 { 53 | var idswitch uint16 = 0xffff 54 | err = binary.Write(buf, binary.LittleEndian, &idswitch) 55 | if err != nil { 56 | return 57 | } 58 | err = binary.Write(buf, binary.LittleEndian, &proc.id) 59 | if err != nil { 60 | return 61 | } 62 | } else { 63 | err = writeUsVarChar(buf, proc.name) 64 | if err != nil { 65 | return 66 | } 67 | } 68 | err = binary.Write(buf, binary.LittleEndian, &flags) 69 | if err != nil { 70 | return 71 | } 72 | for _, param := range params { 73 | if err = writeBVarChar(buf, param.Name); err != nil { 74 | return 75 | } 76 | if err = binary.Write(buf, binary.LittleEndian, param.Flags); err != nil { 77 | return 78 | } 79 | err = writeTypeInfo(buf, ¶m.ti) 80 | if err != nil { 81 | return 82 | } 83 | err = param.ti.Writer(buf, param.ti, param.buffer) 84 | if err != nil { 85 | return 86 | } 87 | } 88 | return buf.FinishPacket() 89 | } 90 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/token_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type token"; DO NOT EDIT 2 | 3 | package mssql 4 | 5 | import "fmt" 6 | 7 | const ( 8 | _token_name_0 = "tokenReturnStatus" 9 | _token_name_1 = "tokenColMetadata" 10 | _token_name_2 = "tokenOrdertokenErrortokenInfo" 11 | _token_name_3 = "tokenLoginAck" 12 | _token_name_4 = "tokenRowtokenNbcRow" 13 | _token_name_5 = "tokenEnvChange" 14 | _token_name_6 = "tokenSSPI" 15 | _token_name_7 = "tokenDonetokenDoneProctokenDoneInProc" 16 | ) 17 | 18 | var ( 19 | _token_index_0 = [...]uint8{0, 17} 20 | _token_index_1 = [...]uint8{0, 16} 21 | _token_index_2 = [...]uint8{0, 10, 20, 29} 22 | _token_index_3 = [...]uint8{0, 13} 23 | _token_index_4 = [...]uint8{0, 8, 19} 24 | _token_index_5 = [...]uint8{0, 14} 25 | _token_index_6 = [...]uint8{0, 9} 26 | _token_index_7 = [...]uint8{0, 9, 22, 37} 27 | ) 28 | 29 | func (i token) String() string { 30 | switch { 31 | case i == 121: 32 | return _token_name_0 33 | case i == 129: 34 | return _token_name_1 35 | case 169 <= i && i <= 171: 36 | i -= 169 37 | return _token_name_2[_token_index_2[i]:_token_index_2[i+1]] 38 | case i == 173: 39 | return _token_name_3 40 | case 209 <= i && i <= 210: 41 | i -= 209 42 | return _token_name_4[_token_index_4[i]:_token_index_4[i+1]] 43 | case i == 227: 44 | return _token_name_5 45 | case i == 237: 46 | return _token_name_6 47 | case 253 <= i && i <= 255: 48 | i -= 253 49 | return _token_name_7[_token_index_7[i]:_token_index_7[i+1]] 50 | default: 51 | return fmt.Sprintf("token(%d)", i) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/tran.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | // Transaction Manager requests 4 | // http://msdn.microsoft.com/en-us/library/dd339887.aspx 5 | 6 | import ( 7 | "encoding/binary" 8 | ) 9 | 10 | const ( 11 | tmGetDtcAddr = 0 12 | tmPropagateXact = 1 13 | tmBeginXact = 5 14 | tmPromoteXact = 6 15 | tmCommitXact = 7 16 | tmRollbackXact = 8 17 | tmSaveXact = 9 18 | ) 19 | 20 | type isoLevel uint8 21 | 22 | const ( 23 | isolationUseCurrent isoLevel = 0 24 | isolationReadUncommited = 1 25 | isolationReadCommited = 2 26 | isolationRepeatableRead = 3 27 | isolationSerializable = 4 28 | isolationSnapshot = 5 29 | ) 30 | 31 | func sendBeginXact(buf *tdsBuffer, headers []headerStruct, isolation isoLevel, name string, resetSession bool) (err error) { 32 | buf.BeginPacket(packTransMgrReq, resetSession) 33 | writeAllHeaders(buf, headers) 34 | var rqtype uint16 = tmBeginXact 35 | err = binary.Write(buf, binary.LittleEndian, &rqtype) 36 | if err != nil { 37 | return 38 | } 39 | err = binary.Write(buf, binary.LittleEndian, &isolation) 40 | if err != nil { 41 | return 42 | } 43 | err = writeBVarChar(buf, name) 44 | if err != nil { 45 | return 46 | } 47 | return buf.FinishPacket() 48 | } 49 | 50 | const ( 51 | fBeginXact = 1 52 | ) 53 | 54 | func sendCommitXact(buf *tdsBuffer, headers []headerStruct, name string, flags uint8, isolation uint8, newname string, resetSession bool) error { 55 | buf.BeginPacket(packTransMgrReq, resetSession) 56 | writeAllHeaders(buf, headers) 57 | var rqtype uint16 = tmCommitXact 58 | err := binary.Write(buf, binary.LittleEndian, &rqtype) 59 | if err != nil { 60 | return err 61 | } 62 | err = writeBVarChar(buf, name) 63 | if err != nil { 64 | return err 65 | } 66 | err = binary.Write(buf, binary.LittleEndian, &flags) 67 | if err != nil { 68 | return err 69 | } 70 | if flags&fBeginXact != 0 { 71 | err = binary.Write(buf, binary.LittleEndian, &isolation) 72 | if err != nil { 73 | return err 74 | } 75 | err = writeBVarChar(buf, name) 76 | if err != nil { 77 | return err 78 | } 79 | } 80 | return buf.FinishPacket() 81 | } 82 | 83 | func sendRollbackXact(buf *tdsBuffer, headers []headerStruct, name string, flags uint8, isolation uint8, newname string, resetSession bool) error { 84 | buf.BeginPacket(packTransMgrReq, resetSession) 85 | writeAllHeaders(buf, headers) 86 | var rqtype uint16 = tmRollbackXact 87 | err := binary.Write(buf, binary.LittleEndian, &rqtype) 88 | if err != nil { 89 | return err 90 | } 91 | err = writeBVarChar(buf, name) 92 | if err != nil { 93 | return err 94 | } 95 | err = binary.Write(buf, binary.LittleEndian, &flags) 96 | if err != nil { 97 | return err 98 | } 99 | if flags&fBeginXact != 0 { 100 | err = binary.Write(buf, binary.LittleEndian, &isolation) 101 | if err != nil { 102 | return err 103 | } 104 | err = writeBVarChar(buf, name) 105 | if err != nil { 106 | return err 107 | } 108 | } 109 | return buf.FinishPacket() 110 | } 111 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/denisenkom/go-mssqldb/uniqueidentifier.go: -------------------------------------------------------------------------------- 1 | package mssql 2 | 3 | import ( 4 | "database/sql/driver" 5 | "encoding/hex" 6 | "errors" 7 | "fmt" 8 | ) 9 | 10 | type UniqueIdentifier [16]byte 11 | 12 | func (u *UniqueIdentifier) Scan(v interface{}) error { 13 | reverse := func(b []byte) { 14 | for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 15 | b[i], b[j] = b[j], b[i] 16 | } 17 | } 18 | 19 | switch vt := v.(type) { 20 | case []byte: 21 | if len(vt) != 16 { 22 | return errors.New("mssql: invalid UniqueIdentifier length") 23 | } 24 | 25 | var raw UniqueIdentifier 26 | 27 | copy(raw[:], vt) 28 | 29 | reverse(raw[0:4]) 30 | reverse(raw[4:6]) 31 | reverse(raw[6:8]) 32 | *u = raw 33 | 34 | return nil 35 | case string: 36 | if len(vt) != 36 { 37 | return errors.New("mssql: invalid UniqueIdentifier string length") 38 | } 39 | 40 | b := []byte(vt) 41 | for i, c := range b { 42 | switch c { 43 | case '-': 44 | b = append(b[:i], b[i+1:]...) 45 | } 46 | } 47 | 48 | _, err := hex.Decode(u[:], []byte(b)) 49 | return err 50 | default: 51 | return fmt.Errorf("mssql: cannot convert %T to UniqueIdentifier", v) 52 | } 53 | } 54 | 55 | func (u UniqueIdentifier) Value() (driver.Value, error) { 56 | reverse := func(b []byte) { 57 | for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 { 58 | b[i], b[j] = b[j], b[i] 59 | } 60 | } 61 | 62 | raw := make([]byte, len(u)) 63 | copy(raw, u[:]) 64 | 65 | reverse(raw[0:4]) 66 | reverse(raw[4:6]) 67 | reverse(raw[6:8]) 68 | 69 | return raw, nil 70 | } 71 | 72 | func (u UniqueIdentifier) String() string { 73 | return fmt.Sprintf("%X-%X-%X-%X-%X", u[0:4], u[4:6], u[6:8], u[8:10], u[10:]) 74 | } 75 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-sql-driver/mysql/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .DS_Store? 3 | ._* 4 | .Spotlight-V100 5 | .Trashes 6 | Icon? 7 | ehthumbs.db 8 | Thumbs.db 9 | .idea 10 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-sql-driver/mysql/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | ## Reporting Issues 4 | 5 | Before creating a new Issue, please check first if a similar Issue [already exists](https://github.com/go-sql-driver/mysql/issues?state=open) or was [recently closed](https://github.com/go-sql-driver/mysql/issues?direction=desc&page=1&sort=updated&state=closed). 6 | 7 | ## Contributing Code 8 | 9 | By contributing to this project, you share your code under the Mozilla Public License 2, as specified in the LICENSE file. 10 | Don't forget to add yourself to the AUTHORS file. 11 | 12 | ### Code Review 13 | 14 | Everyone is invited to review and comment on pull requests. 15 | If it looks fine to you, comment with "LGTM" (Looks good to me). 16 | 17 | If changes are required, notice the reviewers with "PTAL" (Please take another look) after committing the fixes. 18 | 19 | Before merging the Pull Request, at least one [team member](https://github.com/go-sql-driver?tab=members) must have commented with "LGTM". 20 | 21 | ## Development Ideas 22 | 23 | If you are looking for ideas for code contributions, please check our [Development Ideas](https://github.com/go-sql-driver/mysql/wiki/Development-Ideas) Wiki page. 24 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-sql-driver/mysql/appengine.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | // +build appengine 10 | 11 | package mysql 12 | 13 | import ( 14 | "google.golang.org/appengine/cloudsql" 15 | ) 16 | 17 | func init() { 18 | RegisterDial("cloudsql", cloudsql.Dial) 19 | } 20 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-sql-driver/mysql/errors.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2013 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | package mysql 10 | 11 | import ( 12 | "errors" 13 | "fmt" 14 | "log" 15 | "os" 16 | ) 17 | 18 | // Various errors the driver might return. Can change between driver versions. 19 | var ( 20 | ErrInvalidConn = errors.New("invalid connection") 21 | ErrMalformPkt = errors.New("malformed packet") 22 | ErrNoTLS = errors.New("TLS requested but server does not support TLS") 23 | ErrCleartextPassword = errors.New("this user requires clear text authentication. If you still want to use it, please add 'allowCleartextPasswords=1' to your DSN") 24 | ErrNativePassword = errors.New("this user requires mysql native password authentication.") 25 | ErrOldPassword = errors.New("this user requires old password authentication. If you still want to use it, please add 'allowOldPasswords=1' to your DSN. See also https://github.com/go-sql-driver/mysql/wiki/old_passwords") 26 | ErrUnknownPlugin = errors.New("this authentication plugin is not supported") 27 | ErrOldProtocol = errors.New("MySQL server does not support required protocol 41+") 28 | ErrPktSync = errors.New("commands out of sync. You can't run this command now") 29 | ErrPktSyncMul = errors.New("commands out of sync. Did you run multiple statements at once?") 30 | ErrPktTooLarge = errors.New("packet for query is too large. Try adjusting the 'max_allowed_packet' variable on the server") 31 | ErrBusyBuffer = errors.New("busy buffer") 32 | 33 | // errBadConnNoWrite is used for connection errors where nothing was sent to the database yet. 34 | // If this happens first in a function starting a database interaction, it should be replaced by driver.ErrBadConn 35 | // to trigger a resend. 36 | // See https://github.com/go-sql-driver/mysql/pull/302 37 | errBadConnNoWrite = errors.New("bad connection") 38 | ) 39 | 40 | var errLog = Logger(log.New(os.Stderr, "[mysql] ", log.Ldate|log.Ltime|log.Lshortfile)) 41 | 42 | // Logger is used to log critical error messages. 43 | type Logger interface { 44 | Print(v ...interface{}) 45 | } 46 | 47 | // SetLogger is used to set the logger for critical errors. 48 | // The initial logger is os.Stderr. 49 | func SetLogger(logger Logger) error { 50 | if logger == nil { 51 | return errors.New("logger is nil") 52 | } 53 | errLog = logger 54 | return nil 55 | } 56 | 57 | // MySQLError is an error type which represents a single MySQL error 58 | type MySQLError struct { 59 | Number uint16 60 | Message string 61 | } 62 | 63 | func (me *MySQLError) Error() string { 64 | return fmt.Sprintf("Error %d: %s", me.Number, me.Message) 65 | } 66 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-sql-driver/mysql/result.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | package mysql 10 | 11 | type mysqlResult struct { 12 | affectedRows int64 13 | insertId int64 14 | } 15 | 16 | func (res *mysqlResult) LastInsertId() (int64, error) { 17 | return res.insertId, nil 18 | } 19 | 20 | func (res *mysqlResult) RowsAffected() (int64, error) { 21 | return res.affectedRows, nil 22 | } 23 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-sql-driver/mysql/transaction.go: -------------------------------------------------------------------------------- 1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package 2 | // 3 | // Copyright 2012 The Go-MySQL-Driver Authors. All rights reserved. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla Public 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this file, 7 | // You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | package mysql 10 | 11 | type mysqlTx struct { 12 | mc *mysqlConn 13 | } 14 | 15 | func (tx *mysqlTx) Commit() (err error) { 16 | if tx.mc == nil || tx.mc.closed.IsSet() { 17 | return ErrInvalidConn 18 | } 19 | err = tx.mc.exec("COMMIT") 20 | tx.mc = nil 21 | return 22 | } 23 | 24 | func (tx *mysqlTx) Rollback() (err error) { 25 | if tx.mc == nil || tx.mc.closed.IsSet() { 26 | return ErrInvalidConn 27 | } 28 | err = tx.mc.exec("ROLLBACK") 29 | tx.mc = nil 30 | return 31 | } 32 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 The Xorm Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/builder_delete.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "fmt" 9 | ) 10 | 11 | // Delete creates a delete Builder 12 | func Delete(conds ...Cond) *Builder { 13 | builder := &Builder{cond: NewCond()} 14 | return builder.Delete(conds...) 15 | } 16 | 17 | func (b *Builder) deleteWriteTo(w Writer) error { 18 | if len(b.tableName) <= 0 { 19 | return ErrNoTableName 20 | } 21 | 22 | if _, err := fmt.Fprintf(w, "DELETE FROM %s WHERE ", b.tableName); err != nil { 23 | return err 24 | } 25 | 26 | return b.cond.WriteTo(w) 27 | } 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/builder_insert.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "bytes" 9 | "fmt" 10 | ) 11 | 12 | // Insert creates an insert Builder 13 | func Insert(eq Eq) *Builder { 14 | builder := &Builder{cond: NewCond()} 15 | return builder.Insert(eq) 16 | } 17 | 18 | func (b *Builder) insertWriteTo(w Writer) error { 19 | if len(b.tableName) <= 0 { 20 | return ErrNoTableName 21 | } 22 | if len(b.inserts) <= 0 { 23 | return ErrNoColumnToInsert 24 | } 25 | 26 | if _, err := fmt.Fprintf(w, "INSERT INTO %s (", b.tableName); err != nil { 27 | return err 28 | } 29 | 30 | var args = make([]interface{}, 0) 31 | var bs []byte 32 | var valBuffer = bytes.NewBuffer(bs) 33 | var i = 0 34 | 35 | for _, col := range b.inserts.sortedKeys() { 36 | value := b.inserts[col] 37 | fmt.Fprint(w, col) 38 | if e, ok := value.(expr); ok { 39 | fmt.Fprintf(valBuffer, "(%s)", e.sql) 40 | args = append(args, e.args...) 41 | } else { 42 | fmt.Fprint(valBuffer, "?") 43 | args = append(args, value) 44 | } 45 | 46 | if i != len(b.inserts)-1 { 47 | if _, err := fmt.Fprint(w, ","); err != nil { 48 | return err 49 | } 50 | if _, err := fmt.Fprint(valBuffer, ","); err != nil { 51 | return err 52 | } 53 | } 54 | i = i + 1 55 | } 56 | 57 | if _, err := fmt.Fprint(w, ") Values ("); err != nil { 58 | return err 59 | } 60 | 61 | if _, err := w.Write(valBuffer.Bytes()); err != nil { 62 | return err 63 | } 64 | if _, err := fmt.Fprint(w, ")"); err != nil { 65 | return err 66 | } 67 | 68 | w.Append(args...) 69 | 70 | return nil 71 | } 72 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/builder_limit.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | func (b *Builder) limitWriteTo(w Writer) error { 13 | if strings.TrimSpace(b.dialect) == "" { 14 | return ErrDialectNotSetUp 15 | } 16 | 17 | if b.limitation != nil { 18 | limit := b.limitation 19 | if limit.offset < 0 || limit.limitN <= 0 { 20 | return ErrInvalidLimitation 21 | } 22 | // erase limit condition 23 | b.limitation = nil 24 | ow := w.(*BytesWriter) 25 | 26 | switch strings.ToLower(strings.TrimSpace(b.dialect)) { 27 | case ORACLE: 28 | if len(b.selects) == 0 { 29 | b.selects = append(b.selects, "*") 30 | } 31 | 32 | var final *Builder 33 | selects := b.selects 34 | b.selects = append(selects, "ROWNUM RN") 35 | 36 | var wb *Builder 37 | if b.optype == unionType { 38 | wb = Dialect(b.dialect).Select("at.*", "ROWNUM RN"). 39 | From(b, "at") 40 | } else { 41 | wb = b 42 | } 43 | 44 | if limit.offset == 0 { 45 | final = Dialect(b.dialect).Select(selects...).From(wb, "at"). 46 | Where(Lte{"at.RN": limit.limitN}) 47 | } else { 48 | sub := Dialect(b.dialect).Select("*"). 49 | From(b, "at").Where(Lte{"at.RN": limit.offset + limit.limitN}) 50 | 51 | final = Dialect(b.dialect).Select(selects...).From(sub, "att"). 52 | Where(Gt{"att.RN": limit.offset}) 53 | } 54 | 55 | return final.WriteTo(ow) 56 | case SQLITE, MYSQL, POSTGRES: 57 | // if type UNION, we need to write previous content back to current writer 58 | if b.optype == unionType { 59 | b.WriteTo(ow) 60 | } 61 | 62 | if limit.offset == 0 { 63 | fmt.Fprint(ow, " LIMIT ", limit.limitN) 64 | } else { 65 | fmt.Fprintf(ow, " LIMIT %v OFFSET %v", limit.limitN, limit.offset) 66 | } 67 | case MSSQL: 68 | if len(b.selects) == 0 { 69 | b.selects = append(b.selects, "*") 70 | } 71 | 72 | var final *Builder 73 | selects := b.selects 74 | b.selects = append(append([]string{fmt.Sprintf("TOP %d %v", limit.limitN+limit.offset, b.selects[0])}, 75 | b.selects[1:]...), "ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS RN") 76 | 77 | var wb *Builder 78 | if b.optype == unionType { 79 | wb = Dialect(b.dialect).Select("*", "ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS RN"). 80 | From(b, "at") 81 | } else { 82 | wb = b 83 | } 84 | 85 | if limit.offset == 0 { 86 | final = Dialect(b.dialect).Select(selects...).From(wb, "at") 87 | } else { 88 | final = Dialect(b.dialect).Select(selects...).From(wb, "at").Where(Gt{"at.RN": limit.offset}) 89 | } 90 | 91 | return final.WriteTo(ow) 92 | default: 93 | return ErrNotSupportType 94 | } 95 | } 96 | 97 | return nil 98 | } 99 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/builder_union.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | func (b *Builder) unionWriteTo(w Writer) error { 13 | if b.limitation != nil || b.cond.IsValid() || 14 | b.orderBy != "" || b.having != "" || b.groupBy != "" { 15 | return ErrNotUnexpectedUnionConditions 16 | } 17 | 18 | for idx, u := range b.unions { 19 | current := u.builder 20 | if current.optype != selectType { 21 | return ErrUnsupportedUnionMembers 22 | } 23 | 24 | if len(b.unions) == 1 { 25 | if err := current.selectWriteTo(w); err != nil { 26 | return err 27 | } 28 | } else { 29 | if b.dialect != "" && b.dialect != current.dialect { 30 | return ErrInconsistentDialect 31 | } 32 | 33 | if idx != 0 { 34 | fmt.Fprint(w, fmt.Sprintf(" UNION %v ", strings.ToUpper(u.unionType))) 35 | } 36 | fmt.Fprint(w, "(") 37 | 38 | if err := current.selectWriteTo(w); err != nil { 39 | return err 40 | } 41 | 42 | fmt.Fprint(w, ")") 43 | } 44 | } 45 | 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/builder_update.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "fmt" 9 | ) 10 | 11 | // Update creates an update Builder 12 | func Update(updates ...Eq) *Builder { 13 | builder := &Builder{cond: NewCond()} 14 | return builder.Update(updates...) 15 | } 16 | 17 | func (b *Builder) updateWriteTo(w Writer) error { 18 | if len(b.tableName) <= 0 { 19 | return ErrNoTableName 20 | } 21 | if len(b.updates) <= 0 { 22 | return ErrNoColumnToUpdate 23 | } 24 | 25 | if _, err := fmt.Fprintf(w, "UPDATE %s SET ", b.tableName); err != nil { 26 | return err 27 | } 28 | 29 | for i, s := range b.updates { 30 | if err := s.opWriteTo(",", w); err != nil { 31 | return err 32 | } 33 | 34 | if i != len(b.updates)-1 { 35 | if _, err := fmt.Fprint(w, ","); err != nil { 36 | return err 37 | } 38 | } 39 | } 40 | 41 | if _, err := fmt.Fprint(w, " WHERE "); err != nil { 42 | return err 43 | } 44 | 45 | return b.cond.WriteTo(w) 46 | } 47 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "io" 9 | ) 10 | 11 | // Writer defines the interface 12 | type Writer interface { 13 | io.Writer 14 | Append(...interface{}) 15 | } 16 | 17 | var _ Writer = NewWriter() 18 | 19 | // BytesWriter implments Writer and save SQL in bytes.Buffer 20 | type BytesWriter struct { 21 | writer *StringBuilder 22 | args []interface{} 23 | } 24 | 25 | // NewWriter creates a new string writer 26 | func NewWriter() *BytesWriter { 27 | w := &BytesWriter{ 28 | writer: &StringBuilder{}, 29 | } 30 | return w 31 | } 32 | 33 | // Write writes data to Writer 34 | func (s *BytesWriter) Write(buf []byte) (int, error) { 35 | return s.writer.Write(buf) 36 | } 37 | 38 | // Append appends args to Writer 39 | func (s *BytesWriter) Append(args ...interface{}) { 40 | s.args = append(s.args, args...) 41 | } 42 | 43 | // Cond defines an interface 44 | type Cond interface { 45 | WriteTo(Writer) error 46 | And(...Cond) Cond 47 | Or(...Cond) Cond 48 | IsValid() bool 49 | } 50 | 51 | type condEmpty struct{} 52 | 53 | var _ Cond = condEmpty{} 54 | 55 | // NewCond creates an empty condition 56 | func NewCond() Cond { 57 | return condEmpty{} 58 | } 59 | 60 | func (condEmpty) WriteTo(w Writer) error { 61 | return nil 62 | } 63 | 64 | func (condEmpty) And(conds ...Cond) Cond { 65 | return And(conds...) 66 | } 67 | 68 | func (condEmpty) Or(conds ...Cond) Cond { 69 | return Or(conds...) 70 | } 71 | 72 | func (condEmpty) IsValid() bool { 73 | return false 74 | } 75 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_and.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "fmt" 8 | 9 | type condAnd []Cond 10 | 11 | var _ Cond = condAnd{} 12 | 13 | // And generates AND conditions 14 | func And(conds ...Cond) Cond { 15 | var result = make(condAnd, 0, len(conds)) 16 | for _, cond := range conds { 17 | if cond == nil || !cond.IsValid() { 18 | continue 19 | } 20 | result = append(result, cond) 21 | } 22 | return result 23 | } 24 | 25 | func (and condAnd) WriteTo(w Writer) error { 26 | for i, cond := range and { 27 | _, isOr := cond.(condOr) 28 | _, isExpr := cond.(expr) 29 | wrap := isOr || isExpr 30 | if wrap { 31 | fmt.Fprint(w, "(") 32 | } 33 | 34 | err := cond.WriteTo(w) 35 | if err != nil { 36 | return err 37 | } 38 | 39 | if wrap { 40 | fmt.Fprint(w, ")") 41 | } 42 | 43 | if i != len(and)-1 { 44 | fmt.Fprint(w, " AND ") 45 | } 46 | } 47 | 48 | return nil 49 | } 50 | 51 | func (and condAnd) And(conds ...Cond) Cond { 52 | return And(and, And(conds...)) 53 | } 54 | 55 | func (and condAnd) Or(conds ...Cond) Cond { 56 | return Or(and, Or(conds...)) 57 | } 58 | 59 | func (and condAnd) IsValid() bool { 60 | return len(and) > 0 61 | } 62 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_between.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "fmt" 8 | 9 | // Between implmentes between condition 10 | type Between struct { 11 | Col string 12 | LessVal interface{} 13 | MoreVal interface{} 14 | } 15 | 16 | var _ Cond = Between{} 17 | 18 | // WriteTo write data to Writer 19 | func (between Between) WriteTo(w Writer) error { 20 | if _, err := fmt.Fprintf(w, "%s BETWEEN ", between.Col); err != nil { 21 | return err 22 | } 23 | if lv, ok := between.LessVal.(expr); ok { 24 | if err := lv.WriteTo(w); err != nil { 25 | return err 26 | } 27 | } else { 28 | if _, err := fmt.Fprint(w, "?"); err != nil { 29 | return err 30 | } 31 | w.Append(between.LessVal) 32 | } 33 | 34 | if _, err := fmt.Fprint(w, " AND "); err != nil { 35 | return err 36 | } 37 | 38 | if mv, ok := between.MoreVal.(expr); ok { 39 | if err := mv.WriteTo(w); err != nil { 40 | return err 41 | } 42 | } else { 43 | if _, err := fmt.Fprint(w, "?"); err != nil { 44 | return err 45 | } 46 | w.Append(between.MoreVal) 47 | } 48 | 49 | return nil 50 | } 51 | 52 | // And implments And with other conditions 53 | func (between Between) And(conds ...Cond) Cond { 54 | return And(between, And(conds...)) 55 | } 56 | 57 | // Or implments Or with other conditions 58 | func (between Between) Or(conds ...Cond) Cond { 59 | return Or(between, Or(conds...)) 60 | } 61 | 62 | // IsValid tests if the condition is valid 63 | func (between Between) IsValid() bool { 64 | return len(between.Col) > 0 65 | } 66 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_eq.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "fmt" 9 | "sort" 10 | ) 11 | 12 | // Incr implements a type used by Eq 13 | type Incr int 14 | 15 | // Decr implements a type used by Eq 16 | type Decr int 17 | 18 | // Eq defines equals conditions 19 | type Eq map[string]interface{} 20 | 21 | var _ Cond = Eq{} 22 | 23 | func (eq Eq) opWriteTo(op string, w Writer) error { 24 | var i = 0 25 | for _, k := range eq.sortedKeys() { 26 | v := eq[k] 27 | switch v.(type) { 28 | case []int, []int64, []string, []int32, []int16, []int8, []uint, []uint64, []uint32, []uint16, []interface{}: 29 | if err := In(k, v).WriteTo(w); err != nil { 30 | return err 31 | } 32 | case expr: 33 | if _, err := fmt.Fprintf(w, "%s=(", k); err != nil { 34 | return err 35 | } 36 | 37 | if err := v.(expr).WriteTo(w); err != nil { 38 | return err 39 | } 40 | 41 | if _, err := fmt.Fprintf(w, ")"); err != nil { 42 | return err 43 | } 44 | case *Builder: 45 | if _, err := fmt.Fprintf(w, "%s=(", k); err != nil { 46 | return err 47 | } 48 | 49 | if err := v.(*Builder).WriteTo(w); err != nil { 50 | return err 51 | } 52 | 53 | if _, err := fmt.Fprintf(w, ")"); err != nil { 54 | return err 55 | } 56 | case Incr: 57 | if _, err := fmt.Fprintf(w, "%s=%s+?", k, k); err != nil { 58 | return err 59 | } 60 | w.Append(int(v.(Incr))) 61 | case Decr: 62 | if _, err := fmt.Fprintf(w, "%s=%s-?", k, k); err != nil { 63 | return err 64 | } 65 | w.Append(int(v.(Decr))) 66 | default: 67 | if _, err := fmt.Fprintf(w, "%s=?", k); err != nil { 68 | return err 69 | } 70 | w.Append(v) 71 | } 72 | if i != len(eq)-1 { 73 | if _, err := fmt.Fprint(w, op); err != nil { 74 | return err 75 | } 76 | } 77 | i = i + 1 78 | } 79 | return nil 80 | } 81 | 82 | // WriteTo writes SQL to Writer 83 | func (eq Eq) WriteTo(w Writer) error { 84 | return eq.opWriteTo(" AND ", w) 85 | } 86 | 87 | // And implements And with other conditions 88 | func (eq Eq) And(conds ...Cond) Cond { 89 | return And(eq, And(conds...)) 90 | } 91 | 92 | // Or implements Or with other conditions 93 | func (eq Eq) Or(conds ...Cond) Cond { 94 | return Or(eq, Or(conds...)) 95 | } 96 | 97 | // IsValid tests if this Eq is valid 98 | func (eq Eq) IsValid() bool { 99 | return len(eq) > 0 100 | } 101 | 102 | // sortedKeys returns all keys of this Eq sorted with sort.Strings. 103 | // It is used internally for consistent ordering when generating 104 | // SQL, see https://github.com/go-xorm/builder/issues/10 105 | func (eq Eq) sortedKeys() []string { 106 | keys := make([]string, 0, len(eq)) 107 | for key := range eq { 108 | keys = append(keys, key) 109 | } 110 | sort.Strings(keys) 111 | return keys 112 | } 113 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_expr.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "fmt" 8 | 9 | type expr struct { 10 | sql string 11 | args []interface{} 12 | } 13 | 14 | var _ Cond = expr{} 15 | 16 | // Expr generate customerize SQL 17 | func Expr(sql string, args ...interface{}) Cond { 18 | return expr{sql, args} 19 | } 20 | 21 | func (expr expr) WriteTo(w Writer) error { 22 | if _, err := fmt.Fprint(w, expr.sql); err != nil { 23 | return err 24 | } 25 | w.Append(expr.args...) 26 | return nil 27 | } 28 | 29 | func (expr expr) And(conds ...Cond) Cond { 30 | return And(expr, And(conds...)) 31 | } 32 | 33 | func (expr expr) Or(conds ...Cond) Cond { 34 | return Or(expr, Or(conds...)) 35 | } 36 | 37 | func (expr expr) IsValid() bool { 38 | return len(expr.sql) > 0 39 | } 40 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_like.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "fmt" 8 | 9 | // Like defines like condition 10 | type Like [2]string 11 | 12 | var _ Cond = Like{"", ""} 13 | 14 | // WriteTo write SQL to Writer 15 | func (like Like) WriteTo(w Writer) error { 16 | if _, err := fmt.Fprintf(w, "%s LIKE ?", like[0]); err != nil { 17 | return err 18 | } 19 | // FIXME: if use other regular express, this will be failed. but for compatible, keep this 20 | if like[1][0] == '%' || like[1][len(like[1])-1] == '%' { 21 | w.Append(like[1]) 22 | } else { 23 | w.Append("%" + like[1] + "%") 24 | } 25 | return nil 26 | } 27 | 28 | // And implements And with other conditions 29 | func (like Like) And(conds ...Cond) Cond { 30 | return And(like, And(conds...)) 31 | } 32 | 33 | // Or implements Or with other conditions 34 | func (like Like) Or(conds ...Cond) Cond { 35 | return Or(like, Or(conds...)) 36 | } 37 | 38 | // IsValid tests if this condition is valid 39 | func (like Like) IsValid() bool { 40 | return len(like[0]) > 0 && len(like[1]) > 0 41 | } 42 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_neq.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import ( 8 | "fmt" 9 | "sort" 10 | ) 11 | 12 | // Neq defines not equal conditions 13 | type Neq map[string]interface{} 14 | 15 | var _ Cond = Neq{} 16 | 17 | // WriteTo writes SQL to Writer 18 | func (neq Neq) WriteTo(w Writer) error { 19 | var args = make([]interface{}, 0, len(neq)) 20 | var i = 0 21 | for _, k := range neq.sortedKeys() { 22 | v := neq[k] 23 | switch v.(type) { 24 | case []int, []int64, []string, []int32, []int16, []int8: 25 | if err := NotIn(k, v).WriteTo(w); err != nil { 26 | return err 27 | } 28 | case expr: 29 | if _, err := fmt.Fprintf(w, "%s<>(", k); err != nil { 30 | return err 31 | } 32 | 33 | if err := v.(expr).WriteTo(w); err != nil { 34 | return err 35 | } 36 | 37 | if _, err := fmt.Fprintf(w, ")"); err != nil { 38 | return err 39 | } 40 | case *Builder: 41 | if _, err := fmt.Fprintf(w, "%s<>(", k); err != nil { 42 | return err 43 | } 44 | 45 | if err := v.(*Builder).WriteTo(w); err != nil { 46 | return err 47 | } 48 | 49 | if _, err := fmt.Fprintf(w, ")"); err != nil { 50 | return err 51 | } 52 | default: 53 | if _, err := fmt.Fprintf(w, "%s<>?", k); err != nil { 54 | return err 55 | } 56 | args = append(args, v) 57 | } 58 | if i != len(neq)-1 { 59 | if _, err := fmt.Fprint(w, " AND "); err != nil { 60 | return err 61 | } 62 | } 63 | i = i + 1 64 | } 65 | w.Append(args...) 66 | return nil 67 | } 68 | 69 | // And implements And with other conditions 70 | func (neq Neq) And(conds ...Cond) Cond { 71 | return And(neq, And(conds...)) 72 | } 73 | 74 | // Or implements Or with other conditions 75 | func (neq Neq) Or(conds ...Cond) Cond { 76 | return Or(neq, Or(conds...)) 77 | } 78 | 79 | // IsValid tests if this condition is valid 80 | func (neq Neq) IsValid() bool { 81 | return len(neq) > 0 82 | } 83 | 84 | // sortedKeys returns all keys of this Neq sorted with sort.Strings. 85 | // It is used internally for consistent ordering when generating 86 | // SQL, see https://github.com/go-xorm/builder/issues/10 87 | func (neq Neq) sortedKeys() []string { 88 | keys := make([]string, 0, len(neq)) 89 | for key := range neq { 90 | keys = append(keys, key) 91 | } 92 | sort.Strings(keys) 93 | return keys 94 | } 95 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_not.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "fmt" 8 | 9 | // Not defines NOT condition 10 | type Not [1]Cond 11 | 12 | var _ Cond = Not{} 13 | 14 | // WriteTo writes SQL to Writer 15 | func (not Not) WriteTo(w Writer) error { 16 | if _, err := fmt.Fprint(w, "NOT "); err != nil { 17 | return err 18 | } 19 | switch not[0].(type) { 20 | case condAnd, condOr: 21 | if _, err := fmt.Fprint(w, "("); err != nil { 22 | return err 23 | } 24 | case Eq: 25 | if len(not[0].(Eq)) > 1 { 26 | if _, err := fmt.Fprint(w, "("); err != nil { 27 | return err 28 | } 29 | } 30 | case Neq: 31 | if len(not[0].(Neq)) > 1 { 32 | if _, err := fmt.Fprint(w, "("); err != nil { 33 | return err 34 | } 35 | } 36 | } 37 | 38 | if err := not[0].WriteTo(w); err != nil { 39 | return err 40 | } 41 | 42 | switch not[0].(type) { 43 | case condAnd, condOr: 44 | if _, err := fmt.Fprint(w, ")"); err != nil { 45 | return err 46 | } 47 | case Eq: 48 | if len(not[0].(Eq)) > 1 { 49 | if _, err := fmt.Fprint(w, ")"); err != nil { 50 | return err 51 | } 52 | } 53 | case Neq: 54 | if len(not[0].(Neq)) > 1 { 55 | if _, err := fmt.Fprint(w, ")"); err != nil { 56 | return err 57 | } 58 | } 59 | } 60 | 61 | return nil 62 | } 63 | 64 | // And implements And with other conditions 65 | func (not Not) And(conds ...Cond) Cond { 66 | return And(not, And(conds...)) 67 | } 68 | 69 | // Or implements Or with other conditions 70 | func (not Not) Or(conds ...Cond) Cond { 71 | return Or(not, Or(conds...)) 72 | } 73 | 74 | // IsValid tests if this condition is valid 75 | func (not Not) IsValid() bool { 76 | return not[0] != nil && not[0].IsValid() 77 | } 78 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_null.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "fmt" 8 | 9 | // IsNull defines IS NULL condition 10 | type IsNull [1]string 11 | 12 | var _ Cond = IsNull{""} 13 | 14 | // WriteTo write SQL to Writer 15 | func (isNull IsNull) WriteTo(w Writer) error { 16 | _, err := fmt.Fprintf(w, "%s IS NULL", isNull[0]) 17 | return err 18 | } 19 | 20 | // And implements And with other conditions 21 | func (isNull IsNull) And(conds ...Cond) Cond { 22 | return And(isNull, And(conds...)) 23 | } 24 | 25 | // Or implements Or with other conditions 26 | func (isNull IsNull) Or(conds ...Cond) Cond { 27 | return Or(isNull, Or(conds...)) 28 | } 29 | 30 | // IsValid tests if this condition is valid 31 | func (isNull IsNull) IsValid() bool { 32 | return len(isNull[0]) > 0 33 | } 34 | 35 | // NotNull defines NOT NULL condition 36 | type NotNull [1]string 37 | 38 | var _ Cond = NotNull{""} 39 | 40 | // WriteTo write SQL to Writer 41 | func (notNull NotNull) WriteTo(w Writer) error { 42 | _, err := fmt.Fprintf(w, "%s IS NOT NULL", notNull[0]) 43 | return err 44 | } 45 | 46 | // And implements And with other conditions 47 | func (notNull NotNull) And(conds ...Cond) Cond { 48 | return And(notNull, And(conds...)) 49 | } 50 | 51 | // Or implements Or with other conditions 52 | func (notNull NotNull) Or(conds ...Cond) Cond { 53 | return Or(notNull, Or(conds...)) 54 | } 55 | 56 | // IsValid tests if this condition is valid 57 | func (notNull NotNull) IsValid() bool { 58 | return len(notNull[0]) > 0 59 | } 60 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/cond_or.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "fmt" 8 | 9 | type condOr []Cond 10 | 11 | var _ Cond = condOr{} 12 | 13 | // Or sets OR conditions 14 | func Or(conds ...Cond) Cond { 15 | var result = make(condOr, 0, len(conds)) 16 | for _, cond := range conds { 17 | if cond == nil || !cond.IsValid() { 18 | continue 19 | } 20 | result = append(result, cond) 21 | } 22 | return result 23 | } 24 | 25 | // WriteTo implments Cond 26 | func (o condOr) WriteTo(w Writer) error { 27 | for i, cond := range o { 28 | var needQuote bool 29 | switch cond.(type) { 30 | case condAnd, expr: 31 | needQuote = true 32 | case Eq: 33 | needQuote = (len(cond.(Eq)) > 1) 34 | case Neq: 35 | needQuote = (len(cond.(Neq)) > 1) 36 | } 37 | 38 | if needQuote { 39 | fmt.Fprint(w, "(") 40 | } 41 | 42 | err := cond.WriteTo(w) 43 | if err != nil { 44 | return err 45 | } 46 | 47 | if needQuote { 48 | fmt.Fprint(w, ")") 49 | } 50 | 51 | if i != len(o)-1 { 52 | fmt.Fprint(w, " OR ") 53 | } 54 | } 55 | 56 | return nil 57 | } 58 | 59 | func (o condOr) And(conds ...Cond) Cond { 60 | return And(o, And(conds...)) 61 | } 62 | 63 | func (o condOr) Or(conds ...Cond) Cond { 64 | return Or(o, Or(conds...)) 65 | } 66 | 67 | func (o condOr) IsValid() bool { 68 | return len(o) > 0 69 | } 70 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package builder 6 | 7 | import "errors" 8 | 9 | var ( 10 | // ErrNotSupportType not supported SQL type error 11 | ErrNotSupportType = errors.New("Not supported SQL type") 12 | // ErrNoNotInConditions no NOT IN params error 13 | ErrNoNotInConditions = errors.New("No NOT IN conditions") 14 | // ErrNoInConditions no IN params error 15 | ErrNoInConditions = errors.New("No IN conditions") 16 | // ErrNeedMoreArguments need more arguments 17 | ErrNeedMoreArguments = errors.New("Need more sql arguments") 18 | // ErrNoTableName no table name 19 | ErrNoTableName = errors.New("No table indicated") 20 | // ErrNoColumnToInsert no column to update 21 | ErrNoColumnToUpdate = errors.New("No column(s) to update") 22 | // ErrNoColumnToInsert no column to update 23 | ErrNoColumnToInsert = errors.New("No column(s) to insert") 24 | // ErrNotSupportDialectType not supported dialect type error 25 | ErrNotSupportDialectType = errors.New("Not supported dialect type") 26 | // ErrNotUnexpectedUnionConditions using union in a wrong way 27 | ErrNotUnexpectedUnionConditions = errors.New("Unexpected conditional fields in UNION query") 28 | // ErrUnsupportedUnionMembers unexpected members in UNION query 29 | ErrUnsupportedUnionMembers = errors.New("Unexpected members in UNION query") 30 | // ErrUnexpectedSubQuery Unexpected sub-query in SELECT query 31 | ErrUnexpectedSubQuery = errors.New("Unexpected sub-query in SELECT query") 32 | // ErrDialectNotSetUp dialect is not setup yet 33 | ErrDialectNotSetUp = errors.New("Dialect is not setup yet, try to use `Dialect(dbType)` at first") 34 | // ErrInvalidLimitation offset or limit is not correct 35 | ErrInvalidLimitation = errors.New("Offset or limit is not correct") 36 | // ErrUnnamedDerivedTable Every derived table must have its own alias 37 | ErrUnnamedDerivedTable = errors.New("Every derived table must have its own alias") 38 | // ErrInconsistentDialect Inconsistent dialect in same builder 39 | ErrInconsistentDialect = errors.New("Inconsistent dialect in same builder") 40 | ) 41 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/builder/go.mod: -------------------------------------------------------------------------------- 1 | module "github.com/go-xorm/builder" 2 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 - 2015 Lunny Xiao 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/README.md: -------------------------------------------------------------------------------- 1 | Core is a lightweight wrapper of sql.DB. 2 | 3 | [![CircleCI](https://circleci.com/gh/go-xorm/core/tree/master.svg?style=svg)](https://circleci.com/gh/go-xorm/core/tree/master) 4 | 5 | # Open 6 | ```Go 7 | db, _ := core.Open(db, connstr) 8 | ``` 9 | 10 | # SetMapper 11 | ```Go 12 | db.SetMapper(SameMapper()) 13 | ``` 14 | 15 | ## Scan usage 16 | 17 | ### Scan 18 | ```Go 19 | rows, _ := db.Query() 20 | for rows.Next() { 21 | rows.Scan() 22 | } 23 | ``` 24 | 25 | ### ScanMap 26 | ```Go 27 | rows, _ := db.Query() 28 | for rows.Next() { 29 | rows.ScanMap() 30 | ``` 31 | 32 | ### ScanSlice 33 | 34 | You can use `[]string`, `[][]byte`, `[]interface{}`, `[]*string`, `[]sql.NullString` to ScanSclice. Notice, slice's length should be equal or less than select columns. 35 | 36 | ```Go 37 | rows, _ := db.Query() 38 | cols, _ := rows.Columns() 39 | for rows.Next() { 40 | var s = make([]string, len(cols)) 41 | rows.ScanSlice(&s) 42 | } 43 | ``` 44 | 45 | ```Go 46 | rows, _ := db.Query() 47 | cols, _ := rows.Columns() 48 | for rows.Next() { 49 | var s = make([]*string, len(cols)) 50 | rows.ScanSlice(&s) 51 | } 52 | ``` 53 | 54 | ### ScanStruct 55 | ```Go 56 | rows, _ := db.Query() 57 | for rows.Next() { 58 | rows.ScanStructByName() 59 | rows.ScanStructByIndex() 60 | } 61 | ``` 62 | 63 | ## Query usage 64 | ```Go 65 | rows, err := db.Query("select * from table where name = ?", name) 66 | 67 | user = User{ 68 | Name:"lunny", 69 | } 70 | rows, err := db.QueryStruct("select * from table where name = ?Name", 71 | &user) 72 | 73 | var user = map[string]interface{}{ 74 | "name": "lunny", 75 | } 76 | rows, err = db.QueryMap("select * from table where name = ?name", 77 | &user) 78 | ``` 79 | 80 | ## QueryRow usage 81 | ```Go 82 | row := db.QueryRow("select * from table where name = ?", name) 83 | 84 | user = User{ 85 | Name:"lunny", 86 | } 87 | row := db.QueryRowStruct("select * from table where name = ?Name", 88 | &user) 89 | 90 | var user = map[string]interface{}{ 91 | "name": "lunny", 92 | } 93 | row = db.QueryRowMap("select * from table where name = ?name", 94 | &user) 95 | ``` 96 | 97 | ## Exec usage 98 | ```Go 99 | db.Exec("insert into user (`name`, title, age, alias, nick_name,created) values (?,?,?,?,?,?)", name, title, age, alias...) 100 | 101 | user = User{ 102 | Name:"lunny", 103 | Title:"test", 104 | Age: 18, 105 | } 106 | result, err = db.ExecStruct("insert into user (`name`, title, age, alias, nick_name,created) values (?Name,?Title,?Age,?Alias,?NickName,?Created)", 107 | &user) 108 | 109 | var user = map[string]interface{}{ 110 | "Name": "lunny", 111 | "Title": "test", 112 | "Age": 18, 113 | } 114 | result, err = db.ExecMap("insert into user (`name`, title, age, alias, nick_name,created) values (?Name,?Title,?Age,?Alias,?NickName,?Created)", 115 | &user) 116 | ``` -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/benchmark.sh: -------------------------------------------------------------------------------- 1 | go test -v -bench=. -run=XXX 2 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/cache.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "bytes" 5 | "encoding/gob" 6 | "errors" 7 | "fmt" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | const ( 13 | // default cache expired time 14 | CacheExpired = 60 * time.Minute 15 | // not use now 16 | CacheMaxMemory = 256 17 | // evey ten minutes to clear all expired nodes 18 | CacheGcInterval = 10 * time.Minute 19 | // each time when gc to removed max nodes 20 | CacheGcMaxRemoved = 20 21 | ) 22 | 23 | var ( 24 | ErrCacheMiss = errors.New("xorm/cache: key not found.") 25 | ErrNotStored = errors.New("xorm/cache: not stored.") 26 | ) 27 | 28 | // CacheStore is a interface to store cache 29 | type CacheStore interface { 30 | // key is primary key or composite primary key 31 | // value is struct's pointer 32 | // key format : -p--... 33 | Put(key string, value interface{}) error 34 | Get(key string) (interface{}, error) 35 | Del(key string) error 36 | } 37 | 38 | // Cacher is an interface to provide cache 39 | // id format : u--... 40 | type Cacher interface { 41 | GetIds(tableName, sql string) interface{} 42 | GetBean(tableName string, id string) interface{} 43 | PutIds(tableName, sql string, ids interface{}) 44 | PutBean(tableName string, id string, obj interface{}) 45 | DelIds(tableName, sql string) 46 | DelBean(tableName string, id string) 47 | ClearIds(tableName string) 48 | ClearBeans(tableName string) 49 | } 50 | 51 | func encodeIds(ids []PK) (string, error) { 52 | buf := new(bytes.Buffer) 53 | enc := gob.NewEncoder(buf) 54 | err := enc.Encode(ids) 55 | 56 | return buf.String(), err 57 | } 58 | 59 | func decodeIds(s string) ([]PK, error) { 60 | pks := make([]PK, 0) 61 | 62 | dec := gob.NewDecoder(strings.NewReader(s)) 63 | err := dec.Decode(&pks) 64 | 65 | return pks, err 66 | } 67 | 68 | func GetCacheSql(m Cacher, tableName, sql string, args interface{}) ([]PK, error) { 69 | bytes := m.GetIds(tableName, GenSqlKey(sql, args)) 70 | if bytes == nil { 71 | return nil, errors.New("Not Exist") 72 | } 73 | return decodeIds(bytes.(string)) 74 | } 75 | 76 | func PutCacheSql(m Cacher, ids []PK, tableName, sql string, args interface{}) error { 77 | bytes, err := encodeIds(ids) 78 | if err != nil { 79 | return err 80 | } 81 | m.PutIds(tableName, GenSqlKey(sql, args), bytes) 82 | return nil 83 | } 84 | 85 | func GenSqlKey(sql string, args interface{}) string { 86 | return fmt.Sprintf("%v-%v", sql, args) 87 | } 88 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/converstion.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | // Conversion is an interface. A type implements Conversion will according 4 | // the custom method to fill into database and retrieve from database. 5 | type Conversion interface { 6 | FromDB([]byte) error 7 | ToDB() ([]byte, error) 8 | } 9 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/driver.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | type Driver interface { 4 | Parse(string, string) (*Uri, error) 5 | } 6 | 7 | var ( 8 | drivers = map[string]Driver{} 9 | ) 10 | 11 | func RegisterDriver(driverName string, driver Driver) { 12 | if driver == nil { 13 | panic("core: Register driver is nil") 14 | } 15 | if _, dup := drivers[driverName]; dup { 16 | panic("core: Register called twice for driver " + driverName) 17 | } 18 | drivers[driverName] = driver 19 | } 20 | 21 | func QueryDriver(driverName string) Driver { 22 | return drivers[driverName] 23 | } 24 | 25 | func RegisteredDriverSize() int { 26 | return len(drivers) 27 | } 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/error.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import "errors" 4 | 5 | var ( 6 | ErrNoMapPointer = errors.New("mp should be a map's pointer") 7 | ErrNoStructPointer = errors.New("mp should be a struct's pointer") 8 | ) 9 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/filter.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | // Filter is an interface to filter SQL 9 | type Filter interface { 10 | Do(sql string, dialect Dialect, table *Table) string 11 | } 12 | 13 | // QuoteFilter filter SQL replace ` to database's own quote character 14 | type QuoteFilter struct { 15 | } 16 | 17 | func (s *QuoteFilter) Do(sql string, dialect Dialect, table *Table) string { 18 | return strings.Replace(sql, "`", dialect.QuoteStr(), -1) 19 | } 20 | 21 | // IdFilter filter SQL replace (id) to primary key column name 22 | type IdFilter struct { 23 | } 24 | 25 | type Quoter struct { 26 | dialect Dialect 27 | } 28 | 29 | func NewQuoter(dialect Dialect) *Quoter { 30 | return &Quoter{dialect} 31 | } 32 | 33 | func (q *Quoter) Quote(content string) string { 34 | return q.dialect.QuoteStr() + content + q.dialect.QuoteStr() 35 | } 36 | 37 | func (i *IdFilter) Do(sql string, dialect Dialect, table *Table) string { 38 | quoter := NewQuoter(dialect) 39 | if table != nil && len(table.PrimaryKeys) == 1 { 40 | sql = strings.Replace(sql, " `(id)` ", " "+quoter.Quote(table.PrimaryKeys[0])+" ", -1) 41 | sql = strings.Replace(sql, " "+quoter.Quote("(id)")+" ", " "+quoter.Quote(table.PrimaryKeys[0])+" ", -1) 42 | return strings.Replace(sql, " (id) ", " "+quoter.Quote(table.PrimaryKeys[0])+" ", -1) 43 | } 44 | return sql 45 | } 46 | 47 | // SeqFilter filter SQL replace ?, ? ... to $1, $2 ... 48 | type SeqFilter struct { 49 | Prefix string 50 | Start int 51 | } 52 | 53 | func (s *SeqFilter) Do(sql string, dialect Dialect, table *Table) string { 54 | segs := strings.Split(sql, "?") 55 | size := len(segs) 56 | res := "" 57 | for i, c := range segs { 58 | if i < size-1 { 59 | res += c + fmt.Sprintf("%s%v", s.Prefix, i+s.Start) 60 | } 61 | } 62 | res += segs[size-1] 63 | return res 64 | } 65 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/go.mod: -------------------------------------------------------------------------------- 1 | module "github.com/go-xorm/core" 2 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/ilogger.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | type LogLevel int 4 | 5 | const ( 6 | // !nashtsai! following level also match syslog.Priority value 7 | LOG_DEBUG LogLevel = iota 8 | LOG_INFO 9 | LOG_WARNING 10 | LOG_ERR 11 | LOG_OFF 12 | LOG_UNKNOWN 13 | ) 14 | 15 | // logger interface 16 | type ILogger interface { 17 | Debug(v ...interface{}) 18 | Debugf(format string, v ...interface{}) 19 | Error(v ...interface{}) 20 | Errorf(format string, v ...interface{}) 21 | Info(v ...interface{}) 22 | Infof(format string, v ...interface{}) 23 | Warn(v ...interface{}) 24 | Warnf(format string, v ...interface{}) 25 | 26 | Level() LogLevel 27 | SetLevel(l LogLevel) 28 | 29 | ShowSQL(show ...bool) 30 | IsShowSQL() bool 31 | } 32 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/index.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | const ( 9 | IndexType = iota + 1 10 | UniqueType 11 | ) 12 | 13 | // database index 14 | type Index struct { 15 | IsRegular bool 16 | Name string 17 | Type int 18 | Cols []string 19 | } 20 | 21 | func (index *Index) XName(tableName string) string { 22 | if !strings.HasPrefix(index.Name, "UQE_") && 23 | !strings.HasPrefix(index.Name, "IDX_") { 24 | tableName = strings.Replace(tableName, `"`, "", -1) 25 | tableName = strings.Replace(tableName, `.`, "_", -1) 26 | if index.Type == UniqueType { 27 | return fmt.Sprintf("UQE_%v_%v", tableName, index.Name) 28 | } 29 | return fmt.Sprintf("IDX_%v_%v", tableName, index.Name) 30 | } 31 | return index.Name 32 | } 33 | 34 | // add columns which will be composite index 35 | func (index *Index) AddColumn(cols ...string) { 36 | for _, col := range cols { 37 | index.Cols = append(index.Cols, col) 38 | } 39 | } 40 | 41 | func (index *Index) Equal(dst *Index) bool { 42 | if index.Type != dst.Type { 43 | return false 44 | } 45 | if len(index.Cols) != len(dst.Cols) { 46 | return false 47 | } 48 | 49 | for i := 0; i < len(index.Cols); i++ { 50 | var found bool 51 | for j := 0; j < len(dst.Cols); j++ { 52 | if index.Cols[i] == dst.Cols[j] { 53 | found = true 54 | break 55 | } 56 | } 57 | if !found { 58 | return false 59 | } 60 | } 61 | return true 62 | } 63 | 64 | // new an index 65 | func NewIndex(name string, indexType int) *Index { 66 | return &Index{true, name, indexType, make([]string, 0)} 67 | } 68 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/pk.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "bytes" 5 | "encoding/gob" 6 | ) 7 | 8 | type PK []interface{} 9 | 10 | func NewPK(pks ...interface{}) *PK { 11 | p := PK(pks) 12 | return &p 13 | } 14 | 15 | func (p *PK) ToString() (string, error) { 16 | buf := new(bytes.Buffer) 17 | enc := gob.NewEncoder(buf) 18 | err := enc.Encode(*p) 19 | return buf.String(), err 20 | } 21 | 22 | func (p *PK) FromString(content string) error { 23 | dec := gob.NewDecoder(bytes.NewBufferString(content)) 24 | err := dec.Decode(p) 25 | return err 26 | } 27 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/core/scan.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "database/sql/driver" 5 | "fmt" 6 | "time" 7 | ) 8 | 9 | type NullTime time.Time 10 | 11 | var ( 12 | _ driver.Valuer = NullTime{} 13 | ) 14 | 15 | func (ns *NullTime) Scan(value interface{}) error { 16 | if value == nil { 17 | return nil 18 | } 19 | return convertTime(ns, value) 20 | } 21 | 22 | // Value implements the driver Valuer interface. 23 | func (ns NullTime) Value() (driver.Value, error) { 24 | if (time.Time)(ns).IsZero() { 25 | return nil, nil 26 | } 27 | return (time.Time)(ns).Format("2006-01-02 15:04:05"), nil 28 | } 29 | 30 | func convertTime(dest *NullTime, src interface{}) error { 31 | // Common cases, without reflect. 32 | switch s := src.(type) { 33 | case string: 34 | t, err := time.Parse("2006-01-02 15:04:05", s) 35 | if err != nil { 36 | return err 37 | } 38 | *dest = NullTime(t) 39 | return nil 40 | case []uint8: 41 | t, err := time.Parse("2006-01-02 15:04:05", string(s)) 42 | if err != nil { 43 | return err 44 | } 45 | *dest = NullTime(t) 46 | return nil 47 | case time.Time: 48 | *dest = NullTime(s) 49 | return nil 50 | case nil: 51 | default: 52 | return fmt.Errorf("unsupported driver -> Scan pair: %T -> %T", src, dest) 53 | } 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | *.db 6 | 7 | # Folders 8 | _obj 9 | _test 10 | 11 | # Architecture specific extensions/prefixes 12 | *.[568vq] 13 | [568vq].out 14 | 15 | *.cgo1.go 16 | *.cgo2.c 17 | _cgo_defun.c 18 | _cgo_gotypes.go 19 | _cgo_export.* 20 | 21 | _testmain.go 22 | 23 | *.exe 24 | 25 | *.log 26 | .vendor 27 | temp_test.go 28 | .vscode 29 | xorm.test 30 | *.sqlite3 31 | test.db.sql 32 | 33 | .idea/ 34 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to xorm 2 | 3 | `xorm` has a backlog of [pull requests](https://help.github.com/articles/using-pull-requests), but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | * [fork a repo](https://help.github.com/articles/fork-a-repo) 10 | * [creating a pull request ](https://help.github.com/articles/creating-a-pull-request) 11 | 12 | ### Language 13 | 14 | Since `xorm` is a world-wide open source project, please describe your issues or code changes in English as soon as possible. 15 | 16 | ### Sign your codes with comments 17 | ``` 18 | // !! your comments 19 | 20 | e.g., 21 | 22 | // !lunny! this is comments made by lunny 23 | ``` 24 | 25 | ### Patch review 26 | 27 | Help review existing open [pull requests](https://help.github.com/articles/using-pull-requests) by commenting on the code or 28 | proposed functionality. 29 | 30 | ### Bug reports 31 | 32 | We appreciate any bug reports, but especially ones with self-contained 33 | (doesn't depend on code outside of xorm), minimal (can't be simplified 34 | further) test cases. It's especially helpful if you can submit a pull 35 | request with just the failing test case(you can find some example test file like [session_get_test.go](https://github.com/go-xorm/xorm/blob/master/session_get_test.go)). 36 | 37 | If you implements a new database interface, you maybe need to add a test_.sh file. 38 | For example, [mysql_test.go](https://github.com/go-xorm/xorm/blob/master/test_mysql.sh) 39 | 40 | ### New functionality 41 | 42 | There are a number of pending patches for new functionality, so 43 | additional feature patches will take a while to merge. Still, patches 44 | are generally reviewed based on usefulness and complexity in addition 45 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 46 | free to open an issue discussion your proposed patch beforehand. 47 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 - 2015 The Xorm Authors 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/cache_memory_store.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "sync" 9 | 10 | "github.com/go-xorm/core" 11 | ) 12 | 13 | var _ core.CacheStore = NewMemoryStore() 14 | 15 | // MemoryStore represents in-memory store 16 | type MemoryStore struct { 17 | store map[interface{}]interface{} 18 | mutex sync.RWMutex 19 | } 20 | 21 | // NewMemoryStore creates a new store in memory 22 | func NewMemoryStore() *MemoryStore { 23 | return &MemoryStore{store: make(map[interface{}]interface{})} 24 | } 25 | 26 | // Put puts object into store 27 | func (s *MemoryStore) Put(key string, value interface{}) error { 28 | s.mutex.Lock() 29 | defer s.mutex.Unlock() 30 | s.store[key] = value 31 | return nil 32 | } 33 | 34 | // Get gets object from store 35 | func (s *MemoryStore) Get(key string) (interface{}, error) { 36 | s.mutex.RLock() 37 | defer s.mutex.RUnlock() 38 | if v, ok := s.store[key]; ok { 39 | return v, nil 40 | } 41 | 42 | return nil, ErrNotExist 43 | } 44 | 45 | // Del deletes object 46 | func (s *MemoryStore) Del(key string) error { 47 | s.mutex.Lock() 48 | defer s.mutex.Unlock() 49 | delete(s.store, key) 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/circle.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | override: 3 | # './...' is a relative pattern which means all subdirectories 4 | - go get -t -d -v ./... 5 | - go get -t -d -v github.com/go-xorm/tests 6 | - go get -u github.com/go-xorm/core 7 | - go get -u github.com/go-xorm/builder 8 | - go build -v 9 | 10 | database: 11 | override: 12 | - mysql -u root -e "CREATE DATABASE xorm_test DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci" 13 | - mysql -u root -e "CREATE DATABASE xorm_test1 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci" 14 | - mysql -u root -e "CREATE DATABASE xorm_test2 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci" 15 | - mysql -u root -e "CREATE DATABASE xorm_test3 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci" 16 | - createdb -p 5432 -e -U postgres xorm_test 17 | - createdb -p 5432 -e -U postgres xorm_test1 18 | - createdb -p 5432 -e -U postgres xorm_test2 19 | - createdb -p 5432 -e -U postgres xorm_test3 20 | - psql xorm_test postgres -c "create schema xorm" 21 | 22 | test: 23 | override: 24 | # './...' is a relative pattern which means all subdirectories 25 | - go get -u github.com/wadey/gocovmerge 26 | - go test -v -race -db="sqlite3" -conn_str="./test.db" -coverprofile=coverage1-1.txt -covermode=atomic 27 | - go test -v -race -db="sqlite3" -conn_str="./test.db" -cache=true -coverprofile=coverage1-2.txt -covermode=atomic 28 | - go test -v -race -db="mysql" -conn_str="root:@/xorm_test" -coverprofile=coverage2-1.txt -covermode=atomic 29 | - go test -v -race -db="mysql" -conn_str="root:@/xorm_test" -cache=true -coverprofile=coverage2-2.txt -covermode=atomic 30 | - go test -v -race -db="mymysql" -conn_str="xorm_test/root/" -coverprofile=coverage3-1.txt -covermode=atomic 31 | - go test -v -race -db="mymysql" -conn_str="xorm_test/root/" -cache=true -coverprofile=coverage3-2.txt -covermode=atomic 32 | - go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -coverprofile=coverage4-1.txt -covermode=atomic 33 | - go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -cache=true -coverprofile=coverage4-2.txt -covermode=atomic 34 | - go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -schema=xorm -coverprofile=coverage5-1.txt -covermode=atomic 35 | - go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -schema=xorm -cache=true -coverprofile=coverage5-2.txt -covermode=atomic 36 | - gocovmerge coverage1-1.txt coverage1-2.txt coverage2-1.txt coverage2-2.txt coverage3-1.txt coverage3-2.txt coverage4-1.txt coverage4-2.txt coverage5-1.txt coverage5-2.txt > coverage.txt 37 | - cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./sqlite3.sh 38 | - cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./mysql.sh 39 | - cd /home/ubuntu/.go_workspace/src/github.com/go-xorm/tests && ./postgres.sh 40 | post: 41 | - bash <(curl -s https://codecov.io/bash) -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/context.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.8 6 | 7 | package xorm 8 | 9 | import "context" 10 | 11 | // PingContext tests if database is alive 12 | func (engine *Engine) PingContext(ctx context.Context) error { 13 | session := engine.NewSession() 14 | defer session.Close() 15 | return session.PingContext(ctx) 16 | } 17 | 18 | // PingContext test if database is ok 19 | func (session *Session) PingContext(ctx context.Context) error { 20 | if session.isAutoClose { 21 | defer session.Close() 22 | } 23 | 24 | session.engine.logger.Infof("PING DATABASE %v", session.engine.DriverName()) 25 | return session.DB().PingContext(ctx) 26 | } 27 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/context_cache.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | // ContextCache is the interface that operates the cache data. 8 | type ContextCache interface { 9 | // Put puts value into cache with key. 10 | Put(key string, val interface{}) 11 | // Get gets cached value by given key. 12 | Get(key string) interface{} 13 | } 14 | 15 | type memoryContextCache map[string]interface{} 16 | 17 | // NewMemoryContextCache return memoryContextCache 18 | func NewMemoryContextCache() memoryContextCache { 19 | return make(map[string]interface{}) 20 | } 21 | 22 | // Put puts value into cache with key. 23 | func (m memoryContextCache) Put(key string, val interface{}) { 24 | m[key] = val 25 | } 26 | 27 | // Get gets cached value by given key. 28 | func (m memoryContextCache) Get(key string) interface{} { 29 | return m[key] 30 | } 31 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | ) 11 | 12 | var ( 13 | // ErrParamsType params error 14 | ErrParamsType = errors.New("Params type error") 15 | // ErrTableNotFound table not found error 16 | ErrTableNotFound = errors.New("Table not found") 17 | // ErrUnSupportedType unsupported error 18 | ErrUnSupportedType = errors.New("Unsupported type error") 19 | // ErrNotExist record does not exist error 20 | ErrNotExist = errors.New("Record does not exist") 21 | // ErrCacheFailed cache failed error 22 | ErrCacheFailed = errors.New("Cache failed") 23 | // ErrNeedDeletedCond delete needs less one condition error 24 | ErrNeedDeletedCond = errors.New("Delete action needs at least one condition") 25 | // ErrNotImplemented not implemented 26 | ErrNotImplemented = errors.New("Not implemented") 27 | // ErrConditionType condition type unsupported 28 | ErrConditionType = errors.New("Unsupported condition type") 29 | ) 30 | 31 | // ErrFieldIsNotExist columns does not exist 32 | type ErrFieldIsNotExist struct { 33 | FieldName string 34 | TableName string 35 | } 36 | 37 | func (e ErrFieldIsNotExist) Error() string { 38 | return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName) 39 | } 40 | 41 | // ErrFieldIsNotValid is not valid 42 | type ErrFieldIsNotValid struct { 43 | FieldName string 44 | TableName string 45 | } 46 | 47 | func (e ErrFieldIsNotValid) Error() string { 48 | return fmt.Sprintf("field %s is not valid on table %s", e.FieldName, e.TableName) 49 | } 50 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/gen_reserved.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ -f $1 ];then 3 | cat $1| awk '{printf("\""$1"\":true,\n")}' 4 | else 5 | echo "argument $1 if not a file!" 6 | fi 7 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/go.mod: -------------------------------------------------------------------------------- 1 | module "github.com/go-xorm/xorm" 2 | 3 | require ( 4 | "github.com/go-xorm/builder" v0.0.0-20180322150003-a9b7ffcca3f0 5 | "github.com/go-xorm/core" v0.0.0-20180322150003-0177c08cee88 6 | ) 7 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/helpler_time.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import "time" 8 | 9 | const ( 10 | zeroTime0 = "0000-00-00 00:00:00" 11 | zeroTime1 = "0001-01-01 00:00:00" 12 | ) 13 | 14 | func formatTime(t time.Time) string { 15 | return t.Format("2006-01-02 15:04:05") 16 | } 17 | 18 | func isTimeZero(t time.Time) bool { 19 | return t.IsZero() || formatTime(t) == zeroTime0 || 20 | formatTime(t) == zeroTime1 21 | } 22 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/processors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | // BeforeInsertProcessor executed before an object is initially persisted to the database 8 | type BeforeInsertProcessor interface { 9 | BeforeInsert() 10 | } 11 | 12 | // BeforeUpdateProcessor executed before an object is updated 13 | type BeforeUpdateProcessor interface { 14 | BeforeUpdate() 15 | } 16 | 17 | // BeforeDeleteProcessor executed before an object is deleted 18 | type BeforeDeleteProcessor interface { 19 | BeforeDelete() 20 | } 21 | 22 | // BeforeSetProcessor executed before data set to the struct fields 23 | type BeforeSetProcessor interface { 24 | BeforeSet(string, Cell) 25 | } 26 | 27 | // AfterSetProcessor executed after data set to the struct fields 28 | type AfterSetProcessor interface { 29 | AfterSet(string, Cell) 30 | } 31 | 32 | // AfterInsertProcessor executed after an object is persisted to the database 33 | type AfterInsertProcessor interface { 34 | AfterInsert() 35 | } 36 | 37 | // AfterUpdateProcessor executed after an object has been updated 38 | type AfterUpdateProcessor interface { 39 | AfterUpdate() 40 | } 41 | 42 | // AfterDeleteProcessor executed after an object has been deleted 43 | type AfterDeleteProcessor interface { 44 | AfterDelete() 45 | } 46 | 47 | // AfterLoadProcessor executed after an ojbect has been loaded from database 48 | type AfterLoadProcessor interface { 49 | AfterLoad() 50 | } 51 | 52 | // AfterLoadSessionProcessor executed after an ojbect has been loaded from database with session parameter 53 | type AfterLoadSessionProcessor interface { 54 | AfterLoad(*Session) 55 | } 56 | 57 | type executedProcessorFunc func(*Session, interface{}) error 58 | 59 | type executedProcessor struct { 60 | fun executedProcessorFunc 61 | session *Session 62 | bean interface{} 63 | } 64 | 65 | func (executor *executedProcessor) execute() error { 66 | return executor.fun(executor.session, executor.bean) 67 | } 68 | 69 | func (session *Session) executeProcessors() error { 70 | processors := session.afterProcessors 71 | session.afterProcessors = make([]executedProcessor, 0) 72 | for _, processor := range processors { 73 | if err := processor.execute(); err != nil { 74 | return err 75 | } 76 | } 77 | return nil 78 | } 79 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/session_cond.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import "github.com/go-xorm/builder" 8 | 9 | // Sql provides raw sql input parameter. When you have a complex SQL statement 10 | // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL. 11 | // 12 | // Deprecated: use SQL instead. 13 | func (session *Session) Sql(query string, args ...interface{}) *Session { 14 | return session.SQL(query, args...) 15 | } 16 | 17 | // SQL provides raw sql input parameter. When you have a complex SQL statement 18 | // and cannot use Where, Id, In and etc. Methods to describe, you can use SQL. 19 | func (session *Session) SQL(query interface{}, args ...interface{}) *Session { 20 | session.statement.SQL(query, args...) 21 | return session 22 | } 23 | 24 | // Where provides custom query condition. 25 | func (session *Session) Where(query interface{}, args ...interface{}) *Session { 26 | session.statement.Where(query, args...) 27 | return session 28 | } 29 | 30 | // And provides custom query condition. 31 | func (session *Session) And(query interface{}, args ...interface{}) *Session { 32 | session.statement.And(query, args...) 33 | return session 34 | } 35 | 36 | // Or provides custom query condition. 37 | func (session *Session) Or(query interface{}, args ...interface{}) *Session { 38 | session.statement.Or(query, args...) 39 | return session 40 | } 41 | 42 | // Id provides converting id as a query condition 43 | // 44 | // Deprecated: use ID instead 45 | func (session *Session) Id(id interface{}) *Session { 46 | return session.ID(id) 47 | } 48 | 49 | // ID provides converting id as a query condition 50 | func (session *Session) ID(id interface{}) *Session { 51 | session.statement.ID(id) 52 | return session 53 | } 54 | 55 | // In provides a query string like "id in (1, 2, 3)" 56 | func (session *Session) In(column string, args ...interface{}) *Session { 57 | session.statement.In(column, args...) 58 | return session 59 | } 60 | 61 | // NotIn provides a query string like "id in (1, 2, 3)" 62 | func (session *Session) NotIn(column string, args ...interface{}) *Session { 63 | session.statement.NotIn(column, args...) 64 | return session 65 | } 66 | 67 | // Conds returns session query conditions except auto bean conditions 68 | func (session *Session) Conds() builder.Cond { 69 | return session.statement.cond 70 | } 71 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/session_exist.go: -------------------------------------------------------------------------------- 1 | // Copyright 2017 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import ( 8 | "errors" 9 | "fmt" 10 | "reflect" 11 | 12 | "github.com/go-xorm/builder" 13 | "github.com/go-xorm/core" 14 | ) 15 | 16 | // Exist returns true if the record exist otherwise return false 17 | func (session *Session) Exist(bean ...interface{}) (bool, error) { 18 | if session.isAutoClose { 19 | defer session.Close() 20 | } 21 | 22 | var sqlStr string 23 | var args []interface{} 24 | var err error 25 | 26 | if session.statement.RawSQL == "" { 27 | if len(bean) == 0 { 28 | tableName := session.statement.TableName() 29 | if len(tableName) <= 0 { 30 | return false, ErrTableNotFound 31 | } 32 | 33 | if session.statement.cond.IsValid() { 34 | condSQL, condArgs, err := builder.ToSQL(session.statement.cond) 35 | if err != nil { 36 | return false, err 37 | } 38 | 39 | if session.engine.dialect.DBType() == core.MSSQL { 40 | sqlStr = fmt.Sprintf("SELECT top 1 * FROM %s WHERE %s", tableName, condSQL) 41 | } else { 42 | sqlStr = fmt.Sprintf("SELECT * FROM %s WHERE %s LIMIT 1", tableName, condSQL) 43 | } 44 | args = condArgs 45 | } else { 46 | if session.engine.dialect.DBType() == core.MSSQL { 47 | sqlStr = fmt.Sprintf("SELECT top 1 * FROM %s", tableName) 48 | } else { 49 | sqlStr = fmt.Sprintf("SELECT * FROM %s LIMIT 1", tableName) 50 | } 51 | args = []interface{}{} 52 | } 53 | } else { 54 | beanValue := reflect.ValueOf(bean[0]) 55 | if beanValue.Kind() != reflect.Ptr { 56 | return false, errors.New("needs a pointer") 57 | } 58 | 59 | if beanValue.Elem().Kind() == reflect.Struct { 60 | if err := session.statement.setRefBean(bean[0]); err != nil { 61 | return false, err 62 | } 63 | } 64 | 65 | if len(session.statement.TableName()) <= 0 { 66 | return false, ErrTableNotFound 67 | } 68 | session.statement.Limit(1) 69 | sqlStr, args, err = session.statement.genGetSQL(bean[0]) 70 | if err != nil { 71 | return false, err 72 | } 73 | } 74 | } else { 75 | sqlStr = session.statement.RawSQL 76 | args = session.statement.RawParams 77 | } 78 | 79 | rows, err := session.queryRows(sqlStr, args...) 80 | if err != nil { 81 | return false, err 82 | } 83 | defer rows.Close() 84 | 85 | return rows.Next(), nil 86 | } 87 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/session_iterate.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | import "reflect" 8 | 9 | // IterFunc only use by Iterate 10 | type IterFunc func(idx int, bean interface{}) error 11 | 12 | // Rows return sql.Rows compatible Rows obj, as a forward Iterator object for iterating record by record, bean's non-empty fields 13 | // are conditions. 14 | func (session *Session) Rows(bean interface{}) (*Rows, error) { 15 | return newRows(session, bean) 16 | } 17 | 18 | // Iterate record by record handle records from table, condiBeans's non-empty fields 19 | // are conditions. beans could be []Struct, []*Struct, map[int64]Struct 20 | // map[int64]*Struct 21 | func (session *Session) Iterate(bean interface{}, fun IterFunc) error { 22 | if session.isAutoClose { 23 | defer session.Close() 24 | } 25 | 26 | if session.statement.bufferSize > 0 { 27 | return session.bufferIterate(bean, fun) 28 | } 29 | 30 | rows, err := session.Rows(bean) 31 | if err != nil { 32 | return err 33 | } 34 | defer rows.Close() 35 | 36 | i := 0 37 | for rows.Next() { 38 | b := reflect.New(rows.beanType).Interface() 39 | err = rows.Scan(b) 40 | if err != nil { 41 | return err 42 | } 43 | err = fun(i, b) 44 | if err != nil { 45 | return err 46 | } 47 | i++ 48 | } 49 | return err 50 | } 51 | 52 | // BufferSize sets the buffersize for iterate 53 | func (session *Session) BufferSize(size int) *Session { 54 | session.statement.bufferSize = size 55 | return session 56 | } 57 | 58 | func (session *Session) bufferIterate(bean interface{}, fun IterFunc) error { 59 | if session.isAutoClose { 60 | defer session.Close() 61 | } 62 | 63 | var bufferSize = session.statement.bufferSize 64 | var limit = session.statement.LimitN 65 | if limit > 0 && bufferSize > limit { 66 | bufferSize = limit 67 | } 68 | var start = session.statement.Start 69 | v := rValue(bean) 70 | sliceType := reflect.SliceOf(v.Type()) 71 | var idx = 0 72 | for { 73 | slice := reflect.New(sliceType) 74 | if err := session.Limit(bufferSize, start).find(slice.Interface(), bean); err != nil { 75 | return err 76 | } 77 | 78 | for i := 0; i < slice.Elem().Len(); i++ { 79 | if err := fun(idx, slice.Elem().Index(i).Addr().Interface()); err != nil { 80 | return err 81 | } 82 | idx++ 83 | } 84 | 85 | start = start + slice.Elem().Len() 86 | if limit > 0 && idx+bufferSize > limit { 87 | bufferSize = limit - idx 88 | } 89 | 90 | if bufferSize <= 0 || slice.Elem().Len() < bufferSize || idx == limit { 91 | break 92 | } 93 | } 94 | 95 | return nil 96 | } 97 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/session_tx.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | // Begin a transaction 8 | func (session *Session) Begin() error { 9 | if session.isAutoCommit { 10 | tx, err := session.DB().Begin() 11 | if err != nil { 12 | return err 13 | } 14 | session.isAutoCommit = false 15 | session.isCommitedOrRollbacked = false 16 | session.tx = tx 17 | session.saveLastSQL("BEGIN TRANSACTION") 18 | } 19 | return nil 20 | } 21 | 22 | // Rollback When using transaction, you can rollback if any error 23 | func (session *Session) Rollback() error { 24 | if !session.isAutoCommit && !session.isCommitedOrRollbacked { 25 | session.saveLastSQL(session.engine.dialect.RollBackStr()) 26 | session.isCommitedOrRollbacked = true 27 | session.isAutoCommit = true 28 | return session.tx.Rollback() 29 | } 30 | return nil 31 | } 32 | 33 | // Commit When using transaction, Commit will commit all operations. 34 | func (session *Session) Commit() error { 35 | if !session.isAutoCommit && !session.isCommitedOrRollbacked { 36 | session.saveLastSQL("COMMIT") 37 | session.isCommitedOrRollbacked = true 38 | session.isAutoCommit = true 39 | var err error 40 | if err = session.tx.Commit(); err == nil { 41 | // handle processors after tx committed 42 | closureCallFunc := func(closuresPtr *[]func(interface{}), bean interface{}) { 43 | if closuresPtr != nil { 44 | for _, closure := range *closuresPtr { 45 | closure(bean) 46 | } 47 | } 48 | } 49 | 50 | for bean, closuresPtr := range session.afterInsertBeans { 51 | closureCallFunc(closuresPtr, bean) 52 | 53 | if processor, ok := interface{}(bean).(AfterInsertProcessor); ok { 54 | processor.AfterInsert() 55 | } 56 | } 57 | for bean, closuresPtr := range session.afterUpdateBeans { 58 | closureCallFunc(closuresPtr, bean) 59 | 60 | if processor, ok := interface{}(bean).(AfterUpdateProcessor); ok { 61 | processor.AfterUpdate() 62 | } 63 | } 64 | for bean, closuresPtr := range session.afterDeleteBeans { 65 | closureCallFunc(closuresPtr, bean) 66 | 67 | if processor, ok := interface{}(bean).(AfterDeleteProcessor); ok { 68 | processor.AfterDelete() 69 | } 70 | } 71 | cleanUpFunc := func(slices *map[interface{}]*[]func(interface{})) { 72 | if len(*slices) > 0 { 73 | *slices = make(map[interface{}]*[]func(interface{}), 0) 74 | } 75 | } 76 | cleanUpFunc(&session.afterInsertBeans) 77 | cleanUpFunc(&session.afterUpdateBeans) 78 | cleanUpFunc(&session.afterDeleteBeans) 79 | } 80 | return err 81 | } 82 | return nil 83 | } 84 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/syslogger.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !windows,!nacl,!plan9 6 | 7 | package xorm 8 | 9 | import ( 10 | "fmt" 11 | "log/syslog" 12 | 13 | "github.com/go-xorm/core" 14 | ) 15 | 16 | var _ core.ILogger = &SyslogLogger{} 17 | 18 | // SyslogLogger will be depricated 19 | type SyslogLogger struct { 20 | w *syslog.Writer 21 | showSQL bool 22 | } 23 | 24 | // NewSyslogLogger implements core.ILogger 25 | func NewSyslogLogger(w *syslog.Writer) *SyslogLogger { 26 | return &SyslogLogger{w: w} 27 | } 28 | 29 | // Debug log content as Debug 30 | func (s *SyslogLogger) Debug(v ...interface{}) { 31 | s.w.Debug(fmt.Sprint(v...)) 32 | } 33 | 34 | // Debugf log content as Debug and format 35 | func (s *SyslogLogger) Debugf(format string, v ...interface{}) { 36 | s.w.Debug(fmt.Sprintf(format, v...)) 37 | } 38 | 39 | // Error log content as Error 40 | func (s *SyslogLogger) Error(v ...interface{}) { 41 | s.w.Err(fmt.Sprint(v...)) 42 | } 43 | 44 | // Errorf log content as Errorf and format 45 | func (s *SyslogLogger) Errorf(format string, v ...interface{}) { 46 | s.w.Err(fmt.Sprintf(format, v...)) 47 | } 48 | 49 | // Info log content as Info 50 | func (s *SyslogLogger) Info(v ...interface{}) { 51 | s.w.Info(fmt.Sprint(v...)) 52 | } 53 | 54 | // Infof log content as Infof and format 55 | func (s *SyslogLogger) Infof(format string, v ...interface{}) { 56 | s.w.Info(fmt.Sprintf(format, v...)) 57 | } 58 | 59 | // Warn log content as Warn 60 | func (s *SyslogLogger) Warn(v ...interface{}) { 61 | s.w.Warning(fmt.Sprint(v...)) 62 | } 63 | 64 | // Warnf log content as Warnf and format 65 | func (s *SyslogLogger) Warnf(format string, v ...interface{}) { 66 | s.w.Warning(fmt.Sprintf(format, v...)) 67 | } 68 | 69 | // Level shows log level 70 | func (s *SyslogLogger) Level() core.LogLevel { 71 | return core.LOG_UNKNOWN 72 | } 73 | 74 | // SetLevel always return error, as current log/syslog package doesn't allow to set priority level after syslog.Writer created 75 | func (s *SyslogLogger) SetLevel(l core.LogLevel) {} 76 | 77 | // ShowSQL set if logging SQL 78 | func (s *SyslogLogger) ShowSQL(show ...bool) { 79 | if len(show) == 0 { 80 | s.showSQL = true 81 | return 82 | } 83 | s.showSQL = show[0] 84 | } 85 | 86 | // IsShowSQL if logging SQL 87 | func (s *SyslogLogger) IsShowSQL() bool { 88 | return s.showSQL 89 | } 90 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_mssql.sh: -------------------------------------------------------------------------------- 1 | go test -db=mssql -conn_str="server=192.168.1.58;user id=sa;password=123456;database=xorm_test" -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_mssql_cache.sh: -------------------------------------------------------------------------------- 1 | go test -db=mssql -conn_str="server=192.168.1.58;user id=sa;password=123456;database=xorm_test" -cache=true -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_mymysql.sh: -------------------------------------------------------------------------------- 1 | go test -db=mymysql -conn_str="xorm_test/root/" -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_mymysql_cache.sh: -------------------------------------------------------------------------------- 1 | go test -db=mymysql -conn_str="xorm_test/root/" -cache=true -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_mysql.sh: -------------------------------------------------------------------------------- 1 | go test -db=mysql -conn_str="root:@/xorm_test" -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_mysql_cache.sh: -------------------------------------------------------------------------------- 1 | go test -db=mysql -conn_str="root:@/xorm_test" -cache=true -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_postgres.sh: -------------------------------------------------------------------------------- 1 | go test -db=postgres -conn_str="dbname=xorm_test sslmode=disable" -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_postgres_cache.sh: -------------------------------------------------------------------------------- 1 | go test -db=postgres -conn_str="dbname=xorm_test sslmode=disable" -cache=true -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_sqlite.sh: -------------------------------------------------------------------------------- 1 | go test -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/test_sqlite_cache.sh: -------------------------------------------------------------------------------- 1 | go test -db=sqlite3 -conn_str="./test.db?cache=shared&mode=rwc" -cache=true -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/transaction.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 The Xorm Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package xorm 6 | 7 | // Transaction Execute sql wrapped in a transaction(abbr as tx), tx will automatic commit if no errors occurred 8 | func (engine *Engine) Transaction(f func(*Session) (interface{}, error)) (interface{}, error) { 9 | session := engine.NewSession() 10 | defer session.Close() 11 | 12 | if err := session.Begin(); err != nil { 13 | return nil, err 14 | } 15 | 16 | result, err := f(session) 17 | if err != nil { 18 | return nil, err 19 | } 20 | 21 | if err := session.Commit(); err != nil { 22 | return nil, err 23 | } 24 | 25 | return result, nil 26 | } 27 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/go-xorm/xorm/types.go: -------------------------------------------------------------------------------- 1 | package xorm 2 | 3 | import ( 4 | "reflect" 5 | 6 | "github.com/go-xorm/core" 7 | ) 8 | 9 | var ( 10 | ptrPkType = reflect.TypeOf(&core.PK{}) 11 | pkType = reflect.TypeOf(core.PK{}) 12 | ) 13 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/.gitignore: -------------------------------------------------------------------------------- 1 | .db 2 | *.test 3 | *~ 4 | *.swp 5 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/.travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -eu 4 | 5 | client_configure() { 6 | sudo chmod 600 $PQSSLCERTTEST_PATH/postgresql.key 7 | } 8 | 9 | pgdg_repository() { 10 | local sourcelist='sources.list.d/postgresql.list' 11 | 12 | curl -sS 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' | sudo apt-key add - 13 | echo deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main $PGVERSION | sudo tee "/etc/apt/$sourcelist" 14 | sudo apt-get -o Dir::Etc::sourcelist="$sourcelist" -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0' update 15 | } 16 | 17 | postgresql_configure() { 18 | sudo tee /etc/postgresql/$PGVERSION/main/pg_hba.conf > /dev/null <<-config 19 | local all all trust 20 | hostnossl all pqgossltest 127.0.0.1/32 reject 21 | hostnossl all pqgosslcert 127.0.0.1/32 reject 22 | hostssl all pqgossltest 127.0.0.1/32 trust 23 | hostssl all pqgosslcert 127.0.0.1/32 cert 24 | host all all 127.0.0.1/32 trust 25 | hostnossl all pqgossltest ::1/128 reject 26 | hostnossl all pqgosslcert ::1/128 reject 27 | hostssl all pqgossltest ::1/128 trust 28 | hostssl all pqgosslcert ::1/128 cert 29 | host all all ::1/128 trust 30 | config 31 | 32 | xargs sudo install -o postgres -g postgres -m 600 -t /var/lib/postgresql/$PGVERSION/main/ <<-certificates 33 | certs/root.crt 34 | certs/server.crt 35 | certs/server.key 36 | certificates 37 | 38 | sort -VCu <<-versions || 39 | $PGVERSION 40 | 9.2 41 | versions 42 | sudo tee -a /etc/postgresql/$PGVERSION/main/postgresql.conf > /dev/null <<-config 43 | ssl_ca_file = 'root.crt' 44 | ssl_cert_file = 'server.crt' 45 | ssl_key_file = 'server.key' 46 | config 47 | 48 | echo 127.0.0.1 postgres | sudo tee -a /etc/hosts > /dev/null 49 | 50 | sudo service postgresql restart 51 | } 52 | 53 | postgresql_install() { 54 | xargs sudo apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confnew' install <<-packages 55 | postgresql-$PGVERSION 56 | postgresql-server-dev-$PGVERSION 57 | postgresql-contrib-$PGVERSION 58 | packages 59 | } 60 | 61 | postgresql_uninstall() { 62 | sudo service postgresql stop 63 | xargs sudo apt-get -y --purge remove <<-packages 64 | libpq-dev 65 | libpq5 66 | postgresql 67 | postgresql-client-common 68 | postgresql-common 69 | packages 70 | sudo rm -rf /var/lib/postgresql 71 | } 72 | 73 | megacheck_install() { 74 | # Lock megacheck version at $MEGACHECK_VERSION to prevent spontaneous 75 | # new error messages in old code. 76 | go get -d honnef.co/go/tools/... 77 | git -C $GOPATH/src/honnef.co/go/tools/ checkout $MEGACHECK_VERSION 78 | go install honnef.co/go/tools/cmd/megacheck 79 | megacheck --version 80 | } 81 | 82 | golint_install() { 83 | go get github.com/golang/lint/golint 84 | } 85 | 86 | $1 87 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.8.x 5 | - 1.9.x 6 | - 1.10.x 7 | - master 8 | 9 | sudo: true 10 | 11 | env: 12 | global: 13 | - PGUSER=postgres 14 | - PQGOSSLTESTS=1 15 | - PQSSLCERTTEST_PATH=$PWD/certs 16 | - PGHOST=127.0.0.1 17 | - MEGACHECK_VERSION=2017.2.2 18 | matrix: 19 | - PGVERSION=10 20 | - PGVERSION=9.6 21 | - PGVERSION=9.5 22 | - PGVERSION=9.4 23 | - PGVERSION=9.3 24 | - PGVERSION=9.2 25 | - PGVERSION=9.1 26 | - PGVERSION=9.0 27 | 28 | before_install: 29 | - ./.travis.sh postgresql_uninstall 30 | - ./.travis.sh pgdg_repository 31 | - ./.travis.sh postgresql_install 32 | - ./.travis.sh postgresql_configure 33 | - ./.travis.sh client_configure 34 | - ./.travis.sh megacheck_install 35 | - ./.travis.sh golint_install 36 | - go get golang.org/x/tools/cmd/goimports 37 | 38 | before_script: 39 | - createdb pqgotest 40 | - createuser -DRS pqgossltest 41 | - createuser -DRS pqgosslcert 42 | 43 | script: 44 | - > 45 | goimports -d -e $(find -name '*.go') | awk '{ print } END { exit NR == 0 ? 0 : 1 }' 46 | - go vet ./... 47 | - megacheck -go 1.8 ./... 48 | - golint ./... 49 | - PQTEST_BINARY_PARAMETERS=no go test -race -v ./... 50 | - PQTEST_BINARY_PARAMETERS=yes go test -race -v ./... 51 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing to pq 2 | 3 | `pq` has a backlog of pull requests, but contributions are still very 4 | much welcome. You can help with patch review, submitting bug reports, 5 | or adding new functionality. There is no formal style guide, but 6 | please conform to the style of existing code and general Go formatting 7 | conventions when submitting patches. 8 | 9 | ### Patch review 10 | 11 | Help review existing open pull requests by commenting on the code or 12 | proposed functionality. 13 | 14 | ### Bug reports 15 | 16 | We appreciate any bug reports, but especially ones with self-contained 17 | (doesn't depend on code outside of pq), minimal (can't be simplified 18 | further) test cases. It's especially helpful if you can submit a pull 19 | request with just the failing test case (you'll probably want to 20 | pattern it after the tests in 21 | [conn_test.go](https://github.com/lib/pq/blob/master/conn_test.go). 22 | 23 | ### New functionality 24 | 25 | There are a number of pending patches for new functionality, so 26 | additional feature patches will take a while to merge. Still, patches 27 | are generally reviewed based on usefulness and complexity in addition 28 | to time-in-queue, so if you have a knockout idea, take a shot. Feel 29 | free to open an issue discussion your proposed patch beforehand. 30 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011-2013, 'pq' Contributors 2 | Portions Copyright (C) 2011 Blake Mizerany 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 9 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/README.md: -------------------------------------------------------------------------------- 1 | # pq - A pure Go postgres driver for Go's database/sql package 2 | 3 | [![GoDoc](https://godoc.org/github.com/lib/pq?status.svg)](https://godoc.org/github.com/lib/pq) 4 | [![Build Status](https://travis-ci.org/lib/pq.svg?branch=master)](https://travis-ci.org/lib/pq) 5 | 6 | ## Install 7 | 8 | go get github.com/lib/pq 9 | 10 | ## Docs 11 | 12 | For detailed documentation and basic usage examples, please see the package 13 | documentation at . 14 | 15 | ## Tests 16 | 17 | `go test` is used for testing. See [TESTS.md](TESTS.md) for more details. 18 | 19 | ## Features 20 | 21 | * SSL 22 | * Handles bad connections for `database/sql` 23 | * Scan `time.Time` correctly (i.e. `timestamp[tz]`, `time[tz]`, `date`) 24 | * Scan binary blobs correctly (i.e. `bytea`) 25 | * Package for `hstore` support 26 | * COPY FROM support 27 | * pq.ParseURL for converting urls to connection strings for sql.Open. 28 | * Many libpq compatible environment variables 29 | * Unix socket support 30 | * Notifications: `LISTEN`/`NOTIFY` 31 | * pgpass support 32 | 33 | ## Future / Things you can help with 34 | 35 | * Better COPY FROM / COPY TO (see discussion in #181) 36 | 37 | ## Thank you (alphabetical) 38 | 39 | Some of these contributors are from the original library `bmizerany/pq.go` whose 40 | code still exists in here. 41 | 42 | * Andy Balholm (andybalholm) 43 | * Ben Berkert (benburkert) 44 | * Benjamin Heatwole (bheatwole) 45 | * Bill Mill (llimllib) 46 | * Bjørn Madsen (aeons) 47 | * Blake Gentry (bgentry) 48 | * Brad Fitzpatrick (bradfitz) 49 | * Charlie Melbye (cmelbye) 50 | * Chris Bandy (cbandy) 51 | * Chris Gilling (cgilling) 52 | * Chris Walsh (cwds) 53 | * Dan Sosedoff (sosedoff) 54 | * Daniel Farina (fdr) 55 | * Eric Chlebek (echlebek) 56 | * Eric Garrido (minusnine) 57 | * Eric Urban (hydrogen18) 58 | * Everyone at The Go Team 59 | * Evan Shaw (edsrzf) 60 | * Ewan Chou (coocood) 61 | * Fazal Majid (fazalmajid) 62 | * Federico Romero (federomero) 63 | * Fumin (fumin) 64 | * Gary Burd (garyburd) 65 | * Heroku (heroku) 66 | * James Pozdena (jpoz) 67 | * Jason McVetta (jmcvetta) 68 | * Jeremy Jay (pbnjay) 69 | * Joakim Sernbrant (serbaut) 70 | * John Gallagher (jgallagher) 71 | * Jonathan Rudenberg (titanous) 72 | * Joël Stemmer (jstemmer) 73 | * Kamil Kisiel (kisielk) 74 | * Kelly Dunn (kellydunn) 75 | * Keith Rarick (kr) 76 | * Kir Shatrov (kirs) 77 | * Lann Martin (lann) 78 | * Maciek Sakrejda (uhoh-itsmaciek) 79 | * Marc Brinkmann (mbr) 80 | * Marko Tiikkaja (johto) 81 | * Matt Newberry (MattNewberry) 82 | * Matt Robenolt (mattrobenolt) 83 | * Martin Olsen (martinolsen) 84 | * Mike Lewis (mikelikespie) 85 | * Nicolas Patry (Narsil) 86 | * Oliver Tonnhofer (olt) 87 | * Patrick Hayes (phayes) 88 | * Paul Hammond (paulhammond) 89 | * Ryan Smith (ryandotsmith) 90 | * Samuel Stauffer (samuel) 91 | * Timothée Peignier (cyberdelia) 92 | * Travis Cline (tmc) 93 | * TruongSinh Tran-Nguyen (truongsinh) 94 | * Yaismel Miranda (ympons) 95 | * notedit (notedit) 96 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/TESTS.md: -------------------------------------------------------------------------------- 1 | # Tests 2 | 3 | ## Running Tests 4 | 5 | `go test` is used for testing. A running PostgreSQL 6 | server is required, with the ability to log in. The 7 | database to connect to test with is "pqgotest," on 8 | "localhost" but these can be overridden using [environment 9 | variables](https://www.postgresql.org/docs/9.3/static/libpq-envars.html). 10 | 11 | Example: 12 | 13 | PGHOST=/run/postgresql go test 14 | 15 | ## Benchmarks 16 | 17 | A benchmark suite can be run as part of the tests: 18 | 19 | go test -bench . 20 | 21 | ## Example setup (Docker) 22 | 23 | Run a postgres container: 24 | 25 | ``` 26 | docker run --expose 5432:5432 postgres 27 | ``` 28 | 29 | Run tests: 30 | 31 | ``` 32 | PGHOST=localhost PGPORT=5432 PGUSER=postgres PGSSLMODE=disable PGDATABASE=postgres go test 33 | ``` 34 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/buf.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "bytes" 5 | "encoding/binary" 6 | 7 | "github.com/lib/pq/oid" 8 | ) 9 | 10 | type readBuf []byte 11 | 12 | func (b *readBuf) int32() (n int) { 13 | n = int(int32(binary.BigEndian.Uint32(*b))) 14 | *b = (*b)[4:] 15 | return 16 | } 17 | 18 | func (b *readBuf) oid() (n oid.Oid) { 19 | n = oid.Oid(binary.BigEndian.Uint32(*b)) 20 | *b = (*b)[4:] 21 | return 22 | } 23 | 24 | // N.B: this is actually an unsigned 16-bit integer, unlike int32 25 | func (b *readBuf) int16() (n int) { 26 | n = int(binary.BigEndian.Uint16(*b)) 27 | *b = (*b)[2:] 28 | return 29 | } 30 | 31 | func (b *readBuf) string() string { 32 | i := bytes.IndexByte(*b, 0) 33 | if i < 0 { 34 | errorf("invalid message format; expected string terminator") 35 | } 36 | s := (*b)[:i] 37 | *b = (*b)[i+1:] 38 | return string(s) 39 | } 40 | 41 | func (b *readBuf) next(n int) (v []byte) { 42 | v = (*b)[:n] 43 | *b = (*b)[n:] 44 | return 45 | } 46 | 47 | func (b *readBuf) byte() byte { 48 | return b.next(1)[0] 49 | } 50 | 51 | type writeBuf struct { 52 | buf []byte 53 | pos int 54 | } 55 | 56 | func (b *writeBuf) int32(n int) { 57 | x := make([]byte, 4) 58 | binary.BigEndian.PutUint32(x, uint32(n)) 59 | b.buf = append(b.buf, x...) 60 | } 61 | 62 | func (b *writeBuf) int16(n int) { 63 | x := make([]byte, 2) 64 | binary.BigEndian.PutUint16(x, uint16(n)) 65 | b.buf = append(b.buf, x...) 66 | } 67 | 68 | func (b *writeBuf) string(s string) { 69 | b.buf = append(b.buf, (s + "\000")...) 70 | } 71 | 72 | func (b *writeBuf) byte(c byte) { 73 | b.buf = append(b.buf, c) 74 | } 75 | 76 | func (b *writeBuf) bytes(v []byte) { 77 | b.buf = append(b.buf, v...) 78 | } 79 | 80 | func (b *writeBuf) wrap() []byte { 81 | p := b.buf[b.pos:] 82 | binary.BigEndian.PutUint32(p, uint32(len(p))) 83 | return b.buf 84 | } 85 | 86 | func (b *writeBuf) next(c byte) { 87 | p := b.buf[b.pos:] 88 | binary.BigEndian.PutUint32(p, uint32(len(p))) 89 | b.pos = len(b.buf) + 1 90 | b.buf = append(b.buf, c, 0, 0, 0, 0) 91 | } 92 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/connector.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package pq 4 | 5 | import ( 6 | "context" 7 | "database/sql/driver" 8 | ) 9 | 10 | // Connector represents a fixed configuration for the pq driver with a given 11 | // name. Connector satisfies the database/sql/driver Connector interface and 12 | // can be used to create any number of DB Conn's via the database/sql OpenDB 13 | // function. 14 | // 15 | // See https://golang.org/pkg/database/sql/driver/#Connector. 16 | // See https://golang.org/pkg/database/sql/#OpenDB. 17 | type connector struct { 18 | name string 19 | } 20 | 21 | // Connect returns a connection to the database using the fixed configuration 22 | // of this Connector. Context is not used. 23 | func (c *connector) Connect(_ context.Context) (driver.Conn, error) { 24 | return (&Driver{}).Open(c.name) 25 | } 26 | 27 | // Driver returnst the underlying driver of this Connector. 28 | func (c *connector) Driver() driver.Driver { 29 | return &Driver{} 30 | } 31 | 32 | var _ driver.Connector = &connector{} 33 | 34 | // NewConnector returns a connector for the pq driver in a fixed configuration 35 | // with the given name. The returned connector can be used to create any number 36 | // of equivalent Conn's. The returned connector is intended to be used with 37 | // database/sql.OpenDB. 38 | // 39 | // See https://golang.org/pkg/database/sql/driver/#Connector. 40 | // See https://golang.org/pkg/database/sql/#OpenDB. 41 | func NewConnector(name string) (driver.Connector, error) { 42 | return &connector{name: name}, nil 43 | } 44 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/oid/doc.go: -------------------------------------------------------------------------------- 1 | // Package oid contains OID constants 2 | // as defined by the Postgres server. 3 | package oid 4 | 5 | // Oid is a Postgres Object ID. 6 | type Oid uint32 7 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/oid/gen.go: -------------------------------------------------------------------------------- 1 | // +build ignore 2 | 3 | // Generate the table of OID values 4 | // Run with 'go run gen.go'. 5 | package main 6 | 7 | import ( 8 | "database/sql" 9 | "fmt" 10 | "log" 11 | "os" 12 | "os/exec" 13 | "strings" 14 | 15 | _ "github.com/lib/pq" 16 | ) 17 | 18 | // OID represent a postgres Object Identifier Type. 19 | type OID struct { 20 | ID int 21 | Type string 22 | } 23 | 24 | // Name returns an upper case version of the oid type. 25 | func (o OID) Name() string { 26 | return strings.ToUpper(o.Type) 27 | } 28 | 29 | func main() { 30 | datname := os.Getenv("PGDATABASE") 31 | sslmode := os.Getenv("PGSSLMODE") 32 | 33 | if datname == "" { 34 | os.Setenv("PGDATABASE", "pqgotest") 35 | } 36 | 37 | if sslmode == "" { 38 | os.Setenv("PGSSLMODE", "disable") 39 | } 40 | 41 | db, err := sql.Open("postgres", "") 42 | if err != nil { 43 | log.Fatal(err) 44 | } 45 | rows, err := db.Query(` 46 | SELECT typname, oid 47 | FROM pg_type WHERE oid < 10000 48 | ORDER BY oid; 49 | `) 50 | if err != nil { 51 | log.Fatal(err) 52 | } 53 | oids := make([]*OID, 0) 54 | for rows.Next() { 55 | var oid OID 56 | if err = rows.Scan(&oid.Type, &oid.ID); err != nil { 57 | log.Fatal(err) 58 | } 59 | oids = append(oids, &oid) 60 | } 61 | if err = rows.Err(); err != nil { 62 | log.Fatal(err) 63 | } 64 | cmd := exec.Command("gofmt") 65 | cmd.Stderr = os.Stderr 66 | w, err := cmd.StdinPipe() 67 | if err != nil { 68 | log.Fatal(err) 69 | } 70 | f, err := os.Create("types.go") 71 | if err != nil { 72 | log.Fatal(err) 73 | } 74 | cmd.Stdout = f 75 | err = cmd.Start() 76 | if err != nil { 77 | log.Fatal(err) 78 | } 79 | fmt.Fprintln(w, "// Code generated by gen.go. DO NOT EDIT.") 80 | fmt.Fprintln(w, "\npackage oid") 81 | fmt.Fprintln(w, "const (") 82 | for _, oid := range oids { 83 | fmt.Fprintf(w, "T_%s Oid = %d\n", oid.Type, oid.ID) 84 | } 85 | fmt.Fprintln(w, ")") 86 | fmt.Fprintln(w, "var TypeName = map[Oid]string{") 87 | for _, oid := range oids { 88 | fmt.Fprintf(w, "T_%s: \"%s\",\n", oid.Type, oid.Name()) 89 | } 90 | fmt.Fprintln(w, "}") 91 | w.Close() 92 | cmd.Wait() 93 | } 94 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/rows.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "math" 5 | "reflect" 6 | "time" 7 | 8 | "github.com/lib/pq/oid" 9 | ) 10 | 11 | const headerSize = 4 12 | 13 | type fieldDesc struct { 14 | // The object ID of the data type. 15 | OID oid.Oid 16 | // The data type size (see pg_type.typlen). 17 | // Note that negative values denote variable-width types. 18 | Len int 19 | // The type modifier (see pg_attribute.atttypmod). 20 | // The meaning of the modifier is type-specific. 21 | Mod int 22 | } 23 | 24 | func (fd fieldDesc) Type() reflect.Type { 25 | switch fd.OID { 26 | case oid.T_int8: 27 | return reflect.TypeOf(int64(0)) 28 | case oid.T_int4: 29 | return reflect.TypeOf(int32(0)) 30 | case oid.T_int2: 31 | return reflect.TypeOf(int16(0)) 32 | case oid.T_varchar, oid.T_text: 33 | return reflect.TypeOf("") 34 | case oid.T_bool: 35 | return reflect.TypeOf(false) 36 | case oid.T_date, oid.T_time, oid.T_timetz, oid.T_timestamp, oid.T_timestamptz: 37 | return reflect.TypeOf(time.Time{}) 38 | case oid.T_bytea: 39 | return reflect.TypeOf([]byte(nil)) 40 | default: 41 | return reflect.TypeOf(new(interface{})).Elem() 42 | } 43 | } 44 | 45 | func (fd fieldDesc) Name() string { 46 | return oid.TypeName[fd.OID] 47 | } 48 | 49 | func (fd fieldDesc) Length() (length int64, ok bool) { 50 | switch fd.OID { 51 | case oid.T_text, oid.T_bytea: 52 | return math.MaxInt64, true 53 | case oid.T_varchar, oid.T_bpchar: 54 | return int64(fd.Mod - headerSize), true 55 | default: 56 | return 0, false 57 | } 58 | } 59 | 60 | func (fd fieldDesc) PrecisionScale() (precision, scale int64, ok bool) { 61 | switch fd.OID { 62 | case oid.T_numeric, oid.T__numeric: 63 | mod := fd.Mod - headerSize 64 | precision = int64((mod >> 16) & 0xffff) 65 | scale = int64(mod & 0xffff) 66 | return precision, scale, true 67 | default: 68 | return 0, 0, false 69 | } 70 | } 71 | 72 | // ColumnTypeScanType returns the value type that can be used to scan types into. 73 | func (rs *rows) ColumnTypeScanType(index int) reflect.Type { 74 | return rs.colTyps[index].Type() 75 | } 76 | 77 | // ColumnTypeDatabaseTypeName return the database system type name. 78 | func (rs *rows) ColumnTypeDatabaseTypeName(index int) string { 79 | return rs.colTyps[index].Name() 80 | } 81 | 82 | // ColumnTypeLength returns the length of the column type if the column is a 83 | // variable length type. If the column is not a variable length type ok 84 | // should return false. 85 | func (rs *rows) ColumnTypeLength(index int) (length int64, ok bool) { 86 | return rs.colTyps[index].Length() 87 | } 88 | 89 | // ColumnTypePrecisionScale should return the precision and scale for decimal 90 | // types. If not applicable, ok should be false. 91 | func (rs *rows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { 92 | return rs.colTyps[index].PrecisionScale() 93 | } 94 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/ssl_go1.7.go: -------------------------------------------------------------------------------- 1 | // +build go1.7 2 | 3 | package pq 4 | 5 | import "crypto/tls" 6 | 7 | // Accept renegotiation requests initiated by the backend. 8 | // 9 | // Renegotiation was deprecated then removed from PostgreSQL 9.5, but 10 | // the default configuration of older versions has it enabled. Redshift 11 | // also initiates renegotiations and cannot be reconfigured. 12 | func sslRenegotiation(conf *tls.Config) { 13 | conf.Renegotiation = tls.RenegotiateFreelyAsClient 14 | } 15 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/ssl_permissions.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | package pq 4 | 5 | import "os" 6 | 7 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 8 | // The key file should have very little access. 9 | // 10 | // libpq does not check key file permissions on Windows. 11 | func sslKeyPermissions(sslkey string) error { 12 | info, err := os.Stat(sslkey) 13 | if err != nil { 14 | return err 15 | } 16 | if info.Mode().Perm()&0077 != 0 { 17 | return ErrSSLKeyHasWorldPermissions 18 | } 19 | return nil 20 | } 21 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/ssl_renegotiation.go: -------------------------------------------------------------------------------- 1 | // +build !go1.7 2 | 3 | package pq 4 | 5 | import "crypto/tls" 6 | 7 | // Renegotiation is not supported by crypto/tls until Go 1.7. 8 | func sslRenegotiation(*tls.Config) {} 9 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/ssl_windows.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package pq 4 | 5 | // sslKeyPermissions checks the permissions on user-supplied ssl key files. 6 | // The key file should have very little access. 7 | // 8 | // libpq does not check key file permissions on Windows. 9 | func sslKeyPermissions(string) error { return nil } 10 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/url.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | nurl "net/url" 7 | "sort" 8 | "strings" 9 | ) 10 | 11 | // ParseURL no longer needs to be used by clients of this library since supplying a URL as a 12 | // connection string to sql.Open() is now supported: 13 | // 14 | // sql.Open("postgres", "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full") 15 | // 16 | // It remains exported here for backwards-compatibility. 17 | // 18 | // ParseURL converts a url to a connection string for driver.Open. 19 | // Example: 20 | // 21 | // "postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full" 22 | // 23 | // converts to: 24 | // 25 | // "user=bob password=secret host=1.2.3.4 port=5432 dbname=mydb sslmode=verify-full" 26 | // 27 | // A minimal example: 28 | // 29 | // "postgres://" 30 | // 31 | // This will be blank, causing driver.Open to use all of the defaults 32 | func ParseURL(url string) (string, error) { 33 | u, err := nurl.Parse(url) 34 | if err != nil { 35 | return "", err 36 | } 37 | 38 | if u.Scheme != "postgres" && u.Scheme != "postgresql" { 39 | return "", fmt.Errorf("invalid connection protocol: %s", u.Scheme) 40 | } 41 | 42 | var kvs []string 43 | escaper := strings.NewReplacer(` `, `\ `, `'`, `\'`, `\`, `\\`) 44 | accrue := func(k, v string) { 45 | if v != "" { 46 | kvs = append(kvs, k+"="+escaper.Replace(v)) 47 | } 48 | } 49 | 50 | if u.User != nil { 51 | v := u.User.Username() 52 | accrue("user", v) 53 | 54 | v, _ = u.User.Password() 55 | accrue("password", v) 56 | } 57 | 58 | if host, port, err := net.SplitHostPort(u.Host); err != nil { 59 | accrue("host", u.Host) 60 | } else { 61 | accrue("host", host) 62 | accrue("port", port) 63 | } 64 | 65 | if u.Path != "" { 66 | accrue("dbname", u.Path[1:]) 67 | } 68 | 69 | q := u.Query() 70 | for k := range q { 71 | accrue(k, q.Get(k)) 72 | } 73 | 74 | sort.Strings(kvs) // Makes testing easier (not a performance concern) 75 | return strings.Join(kvs, " "), nil 76 | } 77 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/user_posix.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | 3 | // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris rumprun 4 | 5 | package pq 6 | 7 | import ( 8 | "os" 9 | "os/user" 10 | ) 11 | 12 | func userCurrent() (string, error) { 13 | u, err := user.Current() 14 | if err == nil { 15 | return u.Username, nil 16 | } 17 | 18 | name := os.Getenv("USER") 19 | if name != "" { 20 | return name, nil 21 | } 22 | 23 | return "", ErrCouldNotDetectUsername 24 | } 25 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/user_windows.go: -------------------------------------------------------------------------------- 1 | // Package pq is a pure Go Postgres driver for the database/sql package. 2 | package pq 3 | 4 | import ( 5 | "path/filepath" 6 | "syscall" 7 | ) 8 | 9 | // Perform Windows user name lookup identically to libpq. 10 | // 11 | // The PostgreSQL code makes use of the legacy Win32 function 12 | // GetUserName, and that function has not been imported into stock Go. 13 | // GetUserNameEx is available though, the difference being that a 14 | // wider range of names are available. To get the output to be the 15 | // same as GetUserName, only the base (or last) component of the 16 | // result is returned. 17 | func userCurrent() (string, error) { 18 | pw_name := make([]uint16, 128) 19 | pwname_size := uint32(len(pw_name)) - 1 20 | err := syscall.GetUserNameEx(syscall.NameSamCompatible, &pw_name[0], &pwname_size) 21 | if err != nil { 22 | return "", ErrCouldNotDetectUsername 23 | } 24 | s := syscall.UTF16ToString(pw_name) 25 | u := filepath.Base(s) 26 | return u, nil 27 | } 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lib/pq/uuid.go: -------------------------------------------------------------------------------- 1 | package pq 2 | 3 | import ( 4 | "encoding/hex" 5 | "fmt" 6 | ) 7 | 8 | // decodeUUIDBinary interprets the binary format of a uuid, returning it in text format. 9 | func decodeUUIDBinary(src []byte) ([]byte, error) { 10 | if len(src) != 16 { 11 | return nil, fmt.Errorf("pq: unable to decode uuid; bad length: %d", len(src)) 12 | } 13 | 14 | dst := make([]byte, 36) 15 | dst[8], dst[13], dst[18], dst[23] = '-', '-', '-', '-' 16 | hex.Encode(dst[0:], src[0:4]) 17 | hex.Encode(dst[9:], src[4:6]) 18 | hex.Encode(dst[14:], src[6:8]) 19 | hex.Encode(dst[19:], src[8:10]) 20 | hex.Encode(dst[24:], src[10:16]) 21 | 22 | return dst, nil 23 | } 24 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lunny/log/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | log.db 24 | *.log 25 | logs 26 | .vscode -------------------------------------------------------------------------------- /xorm/vendor/github.com/lunny/log/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 - 2016 lunny 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of the {organization} nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lunny/log/README.md: -------------------------------------------------------------------------------- 1 | ## log 2 | [![GoDoc](https://godoc.org/github.com/lunny/log?status.png)](https://godoc.org/github.com/lunny/log) 3 | 4 | [简体中文](https://github.com/lunny/log/blob/master/README_CN.md) 5 | 6 | # Installation 7 | 8 | ``` 9 | go get github.com/lunny/log 10 | ``` 11 | 12 | # Features 13 | 14 | * Add color support for unix console 15 | * Implemented dbwriter to save log to database 16 | * Implemented FileWriter to save log to file by date or time. 17 | * Location configuration 18 | 19 | # Example 20 | 21 | For Single File: 22 | ```Go 23 | f, _ := os.Create("my.log") 24 | log.Std.SetOutput(f) 25 | ``` 26 | 27 | For Multiple Writer: 28 | ```Go 29 | f, _ := os.Create("my.log") 30 | log.Std.SetOutput(io.MultiWriter(f, os.Stdout)) 31 | ``` 32 | 33 | For log files by date or time: 34 | ```Go 35 | w := log.NewFileWriter(log.FileOptions{ 36 | ByType:log.ByDay, 37 | Dir:"./logs", 38 | }) 39 | log.Std.SetOutput(w) 40 | ``` 41 | 42 | # About 43 | 44 | This repo is an extension of Golang log. 45 | 46 | # LICENSE 47 | 48 | BSD License 49 | [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) 50 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lunny/log/README_CN.md: -------------------------------------------------------------------------------- 1 | ## log 2 | [![GoDoc](https://godoc.org/github.com/lunny/log?status.png)](https://godoc.org/github.com/lunny/log) 3 | 4 | [English](https://github.com/lunny/log/blob/master/README.md) 5 | 6 | # 安装 7 | 8 | ``` 9 | go get github.com/lunny/log 10 | ``` 11 | 12 | # 特性 13 | 14 | * 对unix增加控制台颜色支持 15 | * 实现了保存log到数据库支持 16 | * 实现了保存log到按日期的文件支持 17 | * 实现了设置日期的地区 18 | 19 | # 例子 20 | 21 | 保存到单个文件: 22 | 23 | ```Go 24 | f, _ := os.Create("my.log") 25 | log.Std.SetOutput(f) 26 | ``` 27 | 28 | 保存到数据库: 29 | 30 | ```Go 31 | f, _ := os.Create("my.log") 32 | log.Std.SetOutput(io.MultiWriter(f, os.Stdout)) 33 | ``` 34 | 35 | 保存到按时间分隔的文件: 36 | 37 | ```Go 38 | w := log.NewFileWriter(log.FileOptions{ 39 | ByType:log.ByDay, 40 | Dir:"./logs", 41 | }) 42 | log.Std.SetOutput(w) 43 | ``` 44 | 45 | # 关于 46 | 47 | 本 Log 是在 golang 的 log 之上的扩展 48 | 49 | # LICENSE 50 | 51 | BSD License 52 | [http://creativecommons.org/licenses/BSD/](http://creativecommons.org/licenses/BSD/) 53 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lunny/log/dbwriter.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "database/sql" 5 | "time" 6 | ) 7 | 8 | type DBWriter struct { 9 | db *sql.DB 10 | stmt *sql.Stmt 11 | content chan []byte 12 | } 13 | 14 | func NewDBWriter(db *sql.DB) (*DBWriter, error) { 15 | _, err := db.Exec("CREATE TABLE IF NOT EXISTS log (id int, content text, created datetime)") 16 | if err != nil { 17 | return nil, err 18 | } 19 | stmt, err := db.Prepare("INSERT INTO log (content, created) values (?, ?)") 20 | if err != nil { 21 | return nil, err 22 | } 23 | return &DBWriter{db, stmt, make(chan []byte, 1000)}, nil 24 | } 25 | 26 | func (w *DBWriter) Write(p []byte) (n int, err error) { 27 | _, err = w.stmt.Exec(string(p), time.Now()) 28 | if err == nil { 29 | n = len(p) 30 | } 31 | return 32 | } 33 | 34 | func (w *DBWriter) Close() { 35 | w.stmt.Close() 36 | } 37 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/lunny/log/filewriter.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "io" 5 | "os" 6 | "path/filepath" 7 | "sync" 8 | "time" 9 | ) 10 | 11 | var _ io.Writer = &Files{} 12 | 13 | type ByType int 14 | 15 | const ( 16 | ByDay ByType = iota 17 | ByHour 18 | ByMonth 19 | ) 20 | 21 | var ( 22 | formats = map[ByType]string{ 23 | ByDay: "2006-01-02", 24 | ByHour: "2006-01-02-15", 25 | ByMonth: "2006-01", 26 | } 27 | ) 28 | 29 | func SetFileFormat(t ByType, format string) { 30 | formats[t] = format 31 | } 32 | 33 | func (b ByType) Format() string { 34 | return formats[b] 35 | } 36 | 37 | type Files struct { 38 | FileOptions 39 | f *os.File 40 | lastFormat string 41 | lock sync.Mutex 42 | } 43 | 44 | type FileOptions struct { 45 | Dir string 46 | ByType ByType 47 | Loc *time.Location 48 | } 49 | 50 | func prepareFileOption(opts []FileOptions) FileOptions { 51 | var opt FileOptions 52 | if len(opts) > 0 { 53 | opt = opts[0] 54 | } 55 | if opt.Dir == "" { 56 | opt.Dir = "./" 57 | } 58 | err := os.MkdirAll(opt.Dir, os.ModePerm) 59 | if err != nil { 60 | panic(err.Error()) 61 | } 62 | 63 | if opt.Loc == nil { 64 | opt.Loc = time.Local 65 | } 66 | return opt 67 | } 68 | 69 | func NewFileWriter(opts ...FileOptions) *Files { 70 | opt := prepareFileOption(opts) 71 | return &Files{ 72 | FileOptions: opt, 73 | } 74 | } 75 | 76 | func (f *Files) getFile() (*os.File, error) { 77 | var err error 78 | t := time.Now().In(f.Loc) 79 | if f.f == nil { 80 | f.lastFormat = t.Format(f.ByType.Format()) 81 | f.f, err = os.OpenFile(filepath.Join(f.Dir, f.lastFormat+".log"), 82 | os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) 83 | return f.f, err 84 | } 85 | if f.lastFormat != t.Format(f.ByType.Format()) { 86 | f.f.Close() 87 | f.lastFormat = t.Format(f.ByType.Format()) 88 | f.f, err = os.OpenFile(filepath.Join(f.Dir, f.lastFormat+".log"), 89 | os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600) 90 | return f.f, err 91 | } 92 | return f.f, nil 93 | } 94 | 95 | func (f *Files) Write(bs []byte) (int, error) { 96 | f.lock.Lock() 97 | defer f.lock.Unlock() 98 | 99 | w, err := f.getFile() 100 | if err != nil { 101 | return 0, err 102 | } 103 | return w.Write(bs) 104 | } 105 | 106 | func (f *Files) Close() { 107 | if f.f != nil { 108 | f.f.Close() 109 | f.f = nil 110 | } 111 | f.lastFormat = "" 112 | } 113 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/.gitignore: -------------------------------------------------------------------------------- 1 | *.db 2 | *.exe 3 | *.dll 4 | *.o 5 | 6 | # VSCode 7 | .vscode 8 | 9 | # Exclude from upgrade 10 | upgrade/*.c 11 | upgrade/*.h 12 | 13 | # Exclude upgrade binary 14 | upgrade/upgrade 15 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | os: 4 | - linux 5 | - osx 6 | 7 | addons: 8 | apt: 9 | update: true 10 | 11 | env: 12 | matrix: 13 | - GOTAGS= 14 | - GOTAGS=libsqlite3 15 | - GOTAGS="sqlite_allow_uri_authority sqlite_app_armor sqlite_foreign_keys sqlite_fts5 sqlite_icu sqlite_introspect sqlite_json sqlite_secure_delete sqlite_see sqlite_stat4 sqlite_trace sqlite_userauth sqlite_vacuum_incr sqlite_vtable" 16 | - GOTAGS=sqlite_vacuum_full 17 | 18 | go: 19 | - 1.9.x 20 | - 1.10.x 21 | 22 | before_install: 23 | - | 24 | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 25 | brew update 26 | brew upgrade icu4c 27 | fi 28 | - | 29 | go get github.com/smartystreets/goconvey 30 | if [[ "${GOOS}" != "windows" ]]; then 31 | go get github.com/mattn/goveralls 32 | go get golang.org/x/tools/cmd/cover 33 | fi 34 | 35 | script: 36 | - GOOS=$(go env GOOS) GOARCH=$(go env GOARCH) go build -v -tags "${GOTAGS}" . 37 | - | 38 | if [[ "${GOOS}" != "windows" ]]; then 39 | $HOME/gopath/bin/goveralls -repotoken 3qJVUE0iQwqnCbmNcDsjYu1nh4J4KIFXx 40 | go test -race -v . -tags "${GOTAGS}" 41 | fi 42 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Yasuhiro Matsumoto 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/backup.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package sqlite3 7 | 8 | /* 9 | #ifndef USE_LIBSQLITE3 10 | #include 11 | #else 12 | #include 13 | #endif 14 | #include 15 | */ 16 | import "C" 17 | import ( 18 | "runtime" 19 | "unsafe" 20 | ) 21 | 22 | // SQLiteBackup implement interface of Backup. 23 | type SQLiteBackup struct { 24 | b *C.sqlite3_backup 25 | } 26 | 27 | // Backup make backup from src to dest. 28 | func (c *SQLiteConn) Backup(dest string, conn *SQLiteConn, src string) (*SQLiteBackup, error) { 29 | destptr := C.CString(dest) 30 | defer C.free(unsafe.Pointer(destptr)) 31 | srcptr := C.CString(src) 32 | defer C.free(unsafe.Pointer(srcptr)) 33 | 34 | if b := C.sqlite3_backup_init(c.db, destptr, conn.db, srcptr); b != nil { 35 | bb := &SQLiteBackup{b: b} 36 | runtime.SetFinalizer(bb, (*SQLiteBackup).Finish) 37 | return bb, nil 38 | } 39 | return nil, c.lastError() 40 | } 41 | 42 | // Step to backs up for one step. Calls the underlying `sqlite3_backup_step` 43 | // function. This function returns a boolean indicating if the backup is done 44 | // and an error signalling any other error. Done is returned if the underlying 45 | // C function returns SQLITE_DONE (Code 101) 46 | func (b *SQLiteBackup) Step(p int) (bool, error) { 47 | ret := C.sqlite3_backup_step(b.b, C.int(p)) 48 | if ret == C.SQLITE_DONE { 49 | return true, nil 50 | } else if ret != 0 && ret != C.SQLITE_LOCKED && ret != C.SQLITE_BUSY { 51 | return false, Error{Code: ErrNo(ret)} 52 | } 53 | return false, nil 54 | } 55 | 56 | // Remaining return whether have the rest for backup. 57 | func (b *SQLiteBackup) Remaining() int { 58 | return int(C.sqlite3_backup_remaining(b.b)) 59 | } 60 | 61 | // PageCount return count of pages. 62 | func (b *SQLiteBackup) PageCount() int { 63 | return int(C.sqlite3_backup_pagecount(b.b)) 64 | } 65 | 66 | // Finish close backup. 67 | func (b *SQLiteBackup) Finish() error { 68 | return b.Close() 69 | } 70 | 71 | // Close close backup. 72 | func (b *SQLiteBackup) Close() error { 73 | ret := C.sqlite3_backup_finish(b.b) 74 | 75 | // sqlite3_backup_finish() never fails, it just returns the 76 | // error code from previous operations, so clean up before 77 | // checking and returning an error 78 | b.b = nil 79 | runtime.SetFinalizer(b, nil) 80 | 81 | if ret != 0 { 82 | return Error{Code: ErrNo(ret)} 83 | } 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_go18.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build cgo 7 | // +build go1.8 8 | 9 | package sqlite3 10 | 11 | import ( 12 | "database/sql/driver" 13 | "errors" 14 | 15 | "context" 16 | ) 17 | 18 | // Ping implement Pinger. 19 | func (c *SQLiteConn) Ping(ctx context.Context) error { 20 | if c.db == nil { 21 | return errors.New("Connection was closed") 22 | } 23 | return nil 24 | } 25 | 26 | // QueryContext implement QueryerContext. 27 | func (c *SQLiteConn) QueryContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Rows, error) { 28 | list := make([]namedValue, len(args)) 29 | for i, nv := range args { 30 | list[i] = namedValue(nv) 31 | } 32 | return c.query(ctx, query, list) 33 | } 34 | 35 | // ExecContext implement ExecerContext. 36 | func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) { 37 | list := make([]namedValue, len(args)) 38 | for i, nv := range args { 39 | list[i] = namedValue(nv) 40 | } 41 | return c.exec(ctx, query, list) 42 | } 43 | 44 | // PrepareContext implement ConnPrepareContext. 45 | func (c *SQLiteConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) { 46 | return c.prepare(ctx, query) 47 | } 48 | 49 | // BeginTx implement ConnBeginTx. 50 | func (c *SQLiteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) { 51 | return c.begin(ctx) 52 | } 53 | 54 | // QueryContext implement QueryerContext. 55 | func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) { 56 | list := make([]namedValue, len(args)) 57 | for i, nv := range args { 58 | list[i] = namedValue(nv) 59 | } 60 | return s.query(ctx, list) 61 | } 62 | 63 | // ExecContext implement ExecerContext. 64 | func (s *SQLiteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) { 65 | list := make([]namedValue, len(args)) 66 | for i, nv := range args { 67 | list[i] = namedValue(nv) 68 | } 69 | return s.exec(ctx, list) 70 | } 71 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build libsqlite3 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo CFLAGS: -DUSE_LIBSQLITE3 12 | #cgo linux LDFLAGS: -lsqlite3 13 | #cgo darwin LDFLAGS: -L/usr/local/opt/sqlite/lib -lsqlite3 14 | #cgo openbsd LDFLAGS: -lsqlite3 15 | #cgo solaris LDFLAGS: -lsqlite3 16 | */ 17 | import "C" 18 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !sqlite_omit_load_extension 7 | 8 | package sqlite3 9 | 10 | /* 11 | #ifndef USE_LIBSQLITE3 12 | #include 13 | #else 14 | #include 15 | #endif 16 | #include 17 | */ 18 | import "C" 19 | import ( 20 | "errors" 21 | "unsafe" 22 | ) 23 | 24 | func (c *SQLiteConn) loadExtensions(extensions []string) error { 25 | rv := C.sqlite3_enable_load_extension(c.db, 1) 26 | if rv != C.SQLITE_OK { 27 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 28 | } 29 | 30 | for _, extension := range extensions { 31 | cext := C.CString(extension) 32 | defer C.free(unsafe.Pointer(cext)) 33 | rv = C.sqlite3_load_extension(c.db, cext, nil, nil) 34 | if rv != C.SQLITE_OK { 35 | C.sqlite3_enable_load_extension(c.db, 0) 36 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 37 | } 38 | } 39 | 40 | rv = C.sqlite3_enable_load_extension(c.db, 0) 41 | if rv != C.SQLITE_OK { 42 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 43 | } 44 | return nil 45 | } 46 | 47 | // LoadExtension load the sqlite3 extension. 48 | func (c *SQLiteConn) LoadExtension(lib string, entry string) error { 49 | rv := C.sqlite3_enable_load_extension(c.db, 1) 50 | if rv != C.SQLITE_OK { 51 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 52 | } 53 | 54 | clib := C.CString(lib) 55 | defer C.free(unsafe.Pointer(clib)) 56 | centry := C.CString(entry) 57 | defer C.free(unsafe.Pointer(centry)) 58 | 59 | rv = C.sqlite3_load_extension(c.db, clib, centry, nil) 60 | if rv != C.SQLITE_OK { 61 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 62 | } 63 | 64 | rv = C.sqlite3_enable_load_extension(c.db, 0) 65 | if rv != C.SQLITE_OK { 66 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db))) 67 | } 68 | 69 | return nil 70 | } 71 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension_omit.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build sqlite_omit_load_extension 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo CFLAGS: -DSQLITE_OMIT_LOAD_EXTENSION 12 | */ 13 | import "C" 14 | import ( 15 | "errors" 16 | ) 17 | 18 | func (c *SQLiteConn) loadExtensions(extensions []string) error { 19 | return errors.New("Extensions have been disabled for static builds") 20 | } 21 | 22 | func (c *SQLiteConn) LoadExtension(lib string, entry string) error { 23 | return errors.New("Extensions have been disabled for static builds") 24 | } 25 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_allow_uri_authority.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | // 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_allow_uri_authority 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_ALLOW_URI_AUTHORITY 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_app_armor.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build !windows 8 | // +build sqlite_app_armor 9 | 10 | package sqlite3 11 | 12 | /* 13 | #cgo CFLAGS: -DSQLITE_ENABLE_API_ARMOR 14 | #cgo LDFLAGS: -lm 15 | */ 16 | import "C" 17 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_foreign_keys.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | // 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_foreign_keys 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_DEFAULT_FOREIGN_KEYS=1 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_fts5.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build sqlite_fts5 fts5 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo CFLAGS: -DSQLITE_ENABLE_FTS5 12 | #cgo LDFLAGS: -lm 13 | */ 14 | import "C" 15 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_icu.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build sqlite_icu icu 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo LDFLAGS: -licuuc -licui18n 12 | #cgo CFLAGS: -DSQLITE_ENABLE_ICU 13 | #cgo darwin CFLAGS: -I/usr/local/opt/icu4c/include 14 | #cgo darwin LDFLAGS: -L/usr/local/opt/icu4c/lib 15 | #cgo openbsd LDFLAGS: -lsqlite3 16 | */ 17 | import "C" 18 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_introspect.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_introspect 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_INTROSPECTION_PRAGMAS 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_json1.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build sqlite_json sqlite_json1 json1 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo CFLAGS: -DSQLITE_ENABLE_JSON1 12 | */ 13 | import "C" 14 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_secure_delete.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | // 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_secure_delete 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_SECURE_DELETE=1 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_secure_delete_fast.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | // 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_secure_delete_fast 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_SECURE_DELETE=FAST 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_stat4.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | // 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_stat4 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_ENABLE_STAT4 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_vacuum_full.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | // 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_vacuum_full 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_DEFAULT_AUTOVACUUM=1 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_vacuum_incr.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // Copyright (C) 2018 G.J.R. Timmer . 3 | // 4 | // Use of this source code is governed by an MIT-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build sqlite_vacuum_incr 8 | 9 | package sqlite3 10 | 11 | /* 12 | #cgo CFLAGS: -DSQLITE_DEFAULT_AUTOVACUUM=2 13 | #cgo LDFLAGS: -lm 14 | */ 15 | import "C" 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_other.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build !windows 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo CFLAGS: -I. 12 | #cgo linux LDFLAGS: -ldl 13 | */ 14 | import "C" 15 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_solaris.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build solaris 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo CFLAGS: -D__EXTENSIONS__=1 12 | #cgo LDFLAGS: -lc 13 | */ 14 | import "C" 15 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_type.go: -------------------------------------------------------------------------------- 1 | package sqlite3 2 | 3 | /* 4 | #ifndef USE_LIBSQLITE3 5 | #include 6 | #else 7 | #include 8 | #endif 9 | */ 10 | import "C" 11 | import ( 12 | "reflect" 13 | "time" 14 | ) 15 | 16 | // ColumnTypeDatabaseTypeName implement RowsColumnTypeDatabaseTypeName. 17 | func (rc *SQLiteRows) ColumnTypeDatabaseTypeName(i int) string { 18 | return C.GoString(C.sqlite3_column_decltype(rc.s.s, C.int(i))) 19 | } 20 | 21 | /* 22 | func (rc *SQLiteRows) ColumnTypeLength(index int) (length int64, ok bool) { 23 | return 0, false 24 | } 25 | 26 | func (rc *SQLiteRows) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) { 27 | return 0, 0, false 28 | } 29 | */ 30 | 31 | // ColumnTypeNullable implement RowsColumnTypeNullable. 32 | func (rc *SQLiteRows) ColumnTypeNullable(i int) (nullable, ok bool) { 33 | return true, true 34 | } 35 | 36 | // ColumnTypeScanType implement RowsColumnTypeScanType. 37 | func (rc *SQLiteRows) ColumnTypeScanType(i int) reflect.Type { 38 | switch C.sqlite3_column_type(rc.s.s, C.int(i)) { 39 | case C.SQLITE_INTEGER: 40 | switch C.GoString(C.sqlite3_column_decltype(rc.s.s, C.int(i))) { 41 | case "timestamp", "datetime", "date": 42 | return reflect.TypeOf(time.Time{}) 43 | case "boolean": 44 | return reflect.TypeOf(false) 45 | } 46 | return reflect.TypeOf(int64(0)) 47 | case C.SQLITE_FLOAT: 48 | return reflect.TypeOf(float64(0)) 49 | case C.SQLITE_BLOB: 50 | return reflect.SliceOf(reflect.TypeOf(byte(0))) 51 | case C.SQLITE_NULL: 52 | return reflect.TypeOf(nil) 53 | case C.SQLITE_TEXT: 54 | return reflect.TypeOf("") 55 | } 56 | return reflect.SliceOf(reflect.TypeOf(byte(0))) 57 | } 58 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_usleep_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2018 G.J.R. Timmer . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build cgo 7 | 8 | package sqlite3 9 | 10 | // usleep is a function available on *nix based systems. 11 | // This function is not present in Windows. 12 | // Windows has a sleep function but this works with seconds 13 | // and not with microseconds as usleep. 14 | // 15 | // This code should improve performance on windows because 16 | // without the presence of usleep SQLite waits 1 second. 17 | // 18 | // 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 19 | 20 | /* 21 | #include 22 | 23 | void usleep(__int64 usec) 24 | { 25 | HANDLE timer; 26 | LARGE_INTEGER ft; 27 | 28 | // Convert to 100 nanosecond interval, negative value indicates relative time 29 | ft.QuadPart = -(10*usec); 30 | 31 | timer = CreateWaitableTimer(NULL, TRUE, NULL); 32 | SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0); 33 | WaitForSingleObject(timer, INFINITE); 34 | CloseHandle(timer); 35 | } 36 | */ 37 | import "C" 38 | 39 | // EOF 40 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/sqlite3_windows.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Yasuhiro Matsumoto . 2 | // 3 | // Use of this source code is governed by an MIT-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package sqlite3 9 | 10 | /* 11 | #cgo CFLAGS: -I. 12 | #cgo CFLAGS: -fno-stack-check 13 | #cgo CFLAGS: -fno-stack-protector 14 | #cgo CFLAGS: -mno-stack-arg-probe 15 | #cgo LDFLAGS: -lmingwex -lmingw32 16 | #cgo windows,386 CFLAGS: -D_USE_32BIT_TIME_T 17 | */ 18 | import "C" 19 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/mattn/go-sqlite3/static_mock.go: -------------------------------------------------------------------------------- 1 | // +build !cgo 2 | 3 | package sqlite3 4 | 5 | import ( 6 | "database/sql" 7 | "database/sql/driver" 8 | "errors" 9 | ) 10 | 11 | func init() { 12 | sql.Register("sqlite3", &SQLiteDriverMock{}) 13 | } 14 | 15 | type SQLiteDriverMock struct{} 16 | 17 | var errorMsg = errors.New("Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub") 18 | 19 | func (SQLiteDriverMock) Open(s string) (driver.Conn, error) { 20 | return nil, errorMsg 21 | } 22 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Michal Derkacz 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 3. The name of the author may not be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/godrv/appengine.go: -------------------------------------------------------------------------------- 1 | // +build appengine 2 | 3 | package godrv 4 | 5 | import ( 6 | "net" 7 | "time" 8 | 9 | "appengine/cloudsql" 10 | ) 11 | 12 | func init() { 13 | SetDialer(func(proto, laddr, raddr, user, dbname string, timeout time.Duration) (net.Conn, error) { 14 | return cloudsql.Dial(raddr) 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/mysql/field.go: -------------------------------------------------------------------------------- 1 | package mysql 2 | 3 | type Field struct { 4 | Catalog string 5 | Db string 6 | Table string 7 | OrgTable string 8 | Name string 9 | OrgName string 10 | DispLen uint32 11 | // Charset uint16 12 | Flags uint16 13 | Type byte 14 | Scale byte 15 | } 16 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/mysql/status.go: -------------------------------------------------------------------------------- 1 | package mysql 2 | 3 | type ConnStatus uint16 4 | 5 | // Status of server connection 6 | const ( 7 | SERVER_STATUS_IN_TRANS ConnStatus = 0x01 // Transaction has started 8 | SERVER_STATUS_AUTOCOMMIT ConnStatus = 0x02 // Server in auto_commit mode 9 | SERVER_STATUS_MORE_RESULTS ConnStatus = 0x04 10 | SERVER_MORE_RESULTS_EXISTS ConnStatus = 0x08 // Multi query - next query exists 11 | SERVER_QUERY_NO_GOOD_INDEX_USED ConnStatus = 0x10 12 | SERVER_QUERY_NO_INDEX_USED ConnStatus = 0x20 13 | SERVER_STATUS_CURSOR_EXISTS ConnStatus = 0x40 // Server opened a read-only non-scrollable cursor for a query 14 | SERVER_STATUS_LAST_ROW_SENT ConnStatus = 0x80 15 | 16 | SERVER_STATUS_DB_DROPPED ConnStatus = 0x100 17 | SERVER_STATUS_NO_BACKSLASH_ESCAPES ConnStatus = 0x200 18 | ) 19 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/native/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010, Michal Derkacz 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 1. Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | 3. The name of the author may not be used to endorse or promote products 13 | derived from this software without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/native/addons.go: -------------------------------------------------------------------------------- 1 | package native 2 | 3 | func NbinToNstr(nbin *[]byte) *string { 4 | if nbin == nil { 5 | return nil 6 | } 7 | str := string(*nbin) 8 | return &str 9 | } 10 | 11 | func NstrToNbin(nstr *string) *[]byte { 12 | if nstr == nil { 13 | return nil 14 | } 15 | bin := []byte(*nstr) 16 | return &bin 17 | } 18 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/native/common.go: -------------------------------------------------------------------------------- 1 | package native 2 | 3 | import ( 4 | "io" 5 | "runtime" 6 | ) 7 | 8 | var tab8s = " " 9 | 10 | func catchError(err *error) { 11 | if pv := recover(); pv != nil { 12 | switch e := pv.(type) { 13 | case runtime.Error: 14 | panic(pv) 15 | case error: 16 | if e == io.EOF { 17 | *err = io.ErrUnexpectedEOF 18 | } else { 19 | *err = e 20 | } 21 | default: 22 | panic(pv) 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/native/init.go: -------------------------------------------------------------------------------- 1 | package native 2 | 3 | import ( 4 | "github.com/ziutek/mymysql/mysql" 5 | "log" 6 | ) 7 | 8 | func (my *Conn) init() { 9 | my.seq = 0 // Reset sequence number, mainly for reconnect 10 | if my.Debug { 11 | log.Printf("[%2d ->] Init packet:", my.seq) 12 | } 13 | pr := my.newPktReader() 14 | 15 | my.info.prot_ver = pr.readByte() 16 | my.info.serv_ver = pr.readNTB() 17 | my.info.thr_id = pr.readU32() 18 | pr.readFull(my.info.scramble[0:8]) 19 | pr.skipN(1) 20 | my.info.caps = pr.readU16() 21 | my.info.lang = pr.readByte() 22 | my.status = mysql.ConnStatus(pr.readU16()) 23 | pr.skipN(13) 24 | if my.info.caps&_CLIENT_PROTOCOL_41 != 0 { 25 | pr.readFull(my.info.scramble[8:]) 26 | } 27 | pr.skipAll() // Skip other information 28 | if my.Debug { 29 | log.Printf(tab8s+"ProtVer=%d, ServVer=\"%s\" Status=0x%x", 30 | my.info.prot_ver, my.info.serv_ver, my.status, 31 | ) 32 | } 33 | if my.info.caps&_CLIENT_PROTOCOL_41 == 0 { 34 | panic(mysql.ErrOldProtocol) 35 | } 36 | } 37 | 38 | func (my *Conn) auth() { 39 | if my.Debug { 40 | log.Printf("[%2d <-] Authentication packet", my.seq) 41 | } 42 | flags := uint32( 43 | _CLIENT_PROTOCOL_41 | 44 | _CLIENT_LONG_PASSWORD | 45 | _CLIENT_LONG_FLAG | 46 | _CLIENT_TRANSACTIONS | 47 | _CLIENT_SECURE_CONN | 48 | _CLIENT_LOCAL_FILES | 49 | _CLIENT_MULTI_STATEMENTS | 50 | _CLIENT_MULTI_RESULTS) 51 | // Reset flags not supported by server 52 | flags &= uint32(my.info.caps) | 0xffff0000 53 | scrPasswd := encryptedPasswd(my.passwd, my.info.scramble[:]) 54 | pay_len := 4 + 4 + 1 + 23 + len(my.user) + 1 + 1 + len(scrPasswd) 55 | if len(my.dbname) > 0 { 56 | pay_len += len(my.dbname) + 1 57 | flags |= _CLIENT_CONNECT_WITH_DB 58 | } 59 | pw := my.newPktWriter(pay_len) 60 | pw.writeU32(flags) 61 | pw.writeU32(uint32(my.max_pkt_size)) 62 | pw.writeByte(my.info.lang) // Charset number 63 | pw.writeZeros(23) // Filler 64 | pw.writeNTB([]byte(my.user)) // Username 65 | pw.writeBin(scrPasswd) // Encrypted password 66 | if len(my.dbname) > 0 { 67 | pw.writeNTB([]byte(my.dbname)) 68 | } 69 | if len(my.dbname) > 0 { 70 | pay_len += len(my.dbname) + 1 71 | flags |= _CLIENT_CONNECT_WITH_DB 72 | } 73 | return 74 | } 75 | 76 | func (my *Conn) oldPasswd() { 77 | if my.Debug { 78 | log.Printf("[%2d <-] Password packet", my.seq) 79 | } 80 | scrPasswd := encryptedOldPassword(my.passwd, my.info.scramble[:]) 81 | pw := my.newPktWriter(len(scrPasswd) + 1) 82 | pw.write(scrPasswd) 83 | pw.writeByte(0) 84 | } 85 | -------------------------------------------------------------------------------- /xorm/vendor/github.com/ziutek/mymysql/native/unsafe.go-disabled: -------------------------------------------------------------------------------- 1 | package native 2 | 3 | import ( 4 | "github.com/ziutek/mymysql/mysql" 5 | "time" 6 | "unsafe" 7 | ) 8 | 9 | type paramValue struct { 10 | typ uint16 11 | addr unsafe.Pointer 12 | raw bool 13 | length int // >=0 - length of value, <0 - unknown length 14 | } 15 | 16 | func (pv *paramValue) SetAddr(addr uintptr) { 17 | pv.addr = unsafe.Pointer(addr) 18 | } 19 | 20 | func (val *paramValue) Len() int { 21 | if val.addr == nil { 22 | // Invalid Value was binded 23 | return 0 24 | } 25 | // val.addr always points to the pointer - lets dereference it 26 | ptr := *(*unsafe.Pointer)(val.addr) 27 | if ptr == nil { 28 | // Binded Ptr Value is nil 29 | return 0 30 | } 31 | 32 | if val.length >= 0 { 33 | return val.length 34 | } 35 | 36 | switch val.typ { 37 | case MYSQL_TYPE_STRING: 38 | return lenStr(*(*string)(ptr)) 39 | 40 | case MYSQL_TYPE_DATE: 41 | return lenDate(*(*mysql.Date)(ptr)) 42 | 43 | case MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_DATETIME: 44 | return lenTime(*(*time.Time)(ptr)) 45 | 46 | case MYSQL_TYPE_TIME: 47 | return lenDuration(*(*time.Duration)(ptr)) 48 | 49 | case MYSQL_TYPE_TINY: // val.length < 0 so this is bool 50 | return 1 51 | } 52 | // MYSQL_TYPE_VAR_STRING, MYSQL_TYPE_BLOB and type of Raw value 53 | return lenBin(*(*[]byte)(ptr)) 54 | } 55 | 56 | func (pw *pktWriter) writeValue(val *paramValue) { 57 | if val.addr == nil { 58 | // Invalid Value was binded 59 | return 60 | } 61 | // val.addr always points to the pointer - lets dereference it 62 | ptr := *(*unsafe.Pointer)(val.addr) 63 | if ptr == nil { 64 | // Binded Ptr Value is nil 65 | return 66 | } 67 | 68 | if val.raw || val.typ == MYSQL_TYPE_VAR_STRING || 69 | val.typ == MYSQL_TYPE_BLOB { 70 | pw.writeBin(*(*[]byte)(ptr)) 71 | return 72 | } 73 | // We don't need unsigned bit to check type 74 | switch val.typ & ^MYSQL_UNSIGNED_MASK { 75 | case MYSQL_TYPE_NULL: 76 | // Don't write null values 77 | 78 | case MYSQL_TYPE_STRING: 79 | s := *(*string)(ptr) 80 | pw.writeBin([]byte(s)) 81 | 82 | case MYSQL_TYPE_LONG, MYSQL_TYPE_FLOAT: 83 | pw.writeU32(*(*uint32)(ptr)) 84 | 85 | case MYSQL_TYPE_SHORT: 86 | pw.writeU16(*(*uint16)(ptr)) 87 | 88 | case MYSQL_TYPE_TINY: 89 | if val.length == -1 { 90 | // Translate bool value to MySQL tiny 91 | if *(*bool)(ptr) { 92 | pw.writeByte(1) 93 | } else { 94 | pw.writeByte(0) 95 | } 96 | } else { 97 | pw.writeByte(*(*byte)(ptr)) 98 | } 99 | 100 | case MYSQL_TYPE_LONGLONG, MYSQL_TYPE_DOUBLE: 101 | pw.writeU64(*(*uint64)(ptr)) 102 | 103 | case MYSQL_TYPE_DATE: 104 | pw.writeDate(*(*mysql.Date)(ptr)) 105 | 106 | case MYSQL_TYPE_TIMESTAMP, MYSQL_TYPE_DATETIME: 107 | pw.writeTime(*(*time.Time)(ptr)) 108 | 109 | case MYSQL_TYPE_TIME: 110 | pw.writeDuration(*(*time.Duration)(ptr)) 111 | 112 | default: 113 | panic(mysql.ErrBindUnkType) 114 | } 115 | return 116 | } 117 | -------------------------------------------------------------------------------- /xorm/vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /xorm/vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /xorm/vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /xorm/vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /xorm/vendor/golang.org/x/crypto/md4/md4.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // Package md4 implements the MD4 hash algorithm as defined in RFC 1320. 6 | // 7 | // Deprecated: MD4 is cryptographically broken and should should only be used 8 | // where compatibility with legacy systems, not security, is the goal. Instead, 9 | // use a secure hash like SHA-256 (from crypto/sha256). 10 | package md4 // import "golang.org/x/crypto/md4" 11 | 12 | import ( 13 | "crypto" 14 | "hash" 15 | ) 16 | 17 | func init() { 18 | crypto.RegisterHash(crypto.MD4, New) 19 | } 20 | 21 | // The size of an MD4 checksum in bytes. 22 | const Size = 16 23 | 24 | // The blocksize of MD4 in bytes. 25 | const BlockSize = 64 26 | 27 | const ( 28 | _Chunk = 64 29 | _Init0 = 0x67452301 30 | _Init1 = 0xEFCDAB89 31 | _Init2 = 0x98BADCFE 32 | _Init3 = 0x10325476 33 | ) 34 | 35 | // digest represents the partial evaluation of a checksum. 36 | type digest struct { 37 | s [4]uint32 38 | x [_Chunk]byte 39 | nx int 40 | len uint64 41 | } 42 | 43 | func (d *digest) Reset() { 44 | d.s[0] = _Init0 45 | d.s[1] = _Init1 46 | d.s[2] = _Init2 47 | d.s[3] = _Init3 48 | d.nx = 0 49 | d.len = 0 50 | } 51 | 52 | // New returns a new hash.Hash computing the MD4 checksum. 53 | func New() hash.Hash { 54 | d := new(digest) 55 | d.Reset() 56 | return d 57 | } 58 | 59 | func (d *digest) Size() int { return Size } 60 | 61 | func (d *digest) BlockSize() int { return BlockSize } 62 | 63 | func (d *digest) Write(p []byte) (nn int, err error) { 64 | nn = len(p) 65 | d.len += uint64(nn) 66 | if d.nx > 0 { 67 | n := len(p) 68 | if n > _Chunk-d.nx { 69 | n = _Chunk - d.nx 70 | } 71 | for i := 0; i < n; i++ { 72 | d.x[d.nx+i] = p[i] 73 | } 74 | d.nx += n 75 | if d.nx == _Chunk { 76 | _Block(d, d.x[0:]) 77 | d.nx = 0 78 | } 79 | p = p[n:] 80 | } 81 | n := _Block(d, p) 82 | p = p[n:] 83 | if len(p) > 0 { 84 | d.nx = copy(d.x[:], p) 85 | } 86 | return 87 | } 88 | 89 | func (d0 *digest) Sum(in []byte) []byte { 90 | // Make a copy of d0, so that caller can keep writing and summing. 91 | d := new(digest) 92 | *d = *d0 93 | 94 | // Padding. Add a 1 bit and 0 bits until 56 bytes mod 64. 95 | len := d.len 96 | var tmp [64]byte 97 | tmp[0] = 0x80 98 | if len%64 < 56 { 99 | d.Write(tmp[0 : 56-len%64]) 100 | } else { 101 | d.Write(tmp[0 : 64+56-len%64]) 102 | } 103 | 104 | // Length in bits. 105 | len <<= 3 106 | for i := uint(0); i < 8; i++ { 107 | tmp[i] = byte(len >> (8 * i)) 108 | } 109 | d.Write(tmp[0:8]) 110 | 111 | if d.nx != 0 { 112 | panic("d.nx != 0") 113 | } 114 | 115 | for _, s := range d.s { 116 | in = append(in, byte(s>>0)) 117 | in = append(in, byte(s>>8)) 118 | in = append(in, byte(s>>16)) 119 | in = append(in, byte(s>>24)) 120 | } 121 | return in 122 | } 123 | -------------------------------------------------------------------------------- /xorm/vendor/golang.org/x/crypto/md4/md4block.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // MD4 block step. 6 | // In its own file so that a faster assembly or C version 7 | // can be substituted easily. 8 | 9 | package md4 10 | 11 | var shift1 = []uint{3, 7, 11, 19} 12 | var shift2 = []uint{3, 5, 9, 13} 13 | var shift3 = []uint{3, 9, 11, 15} 14 | 15 | var xIndex2 = []uint{0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15} 16 | var xIndex3 = []uint{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15} 17 | 18 | func _Block(dig *digest, p []byte) int { 19 | a := dig.s[0] 20 | b := dig.s[1] 21 | c := dig.s[2] 22 | d := dig.s[3] 23 | n := 0 24 | var X [16]uint32 25 | for len(p) >= _Chunk { 26 | aa, bb, cc, dd := a, b, c, d 27 | 28 | j := 0 29 | for i := 0; i < 16; i++ { 30 | X[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24 31 | j += 4 32 | } 33 | 34 | // If this needs to be made faster in the future, 35 | // the usual trick is to unroll each of these 36 | // loops by a factor of 4; that lets you replace 37 | // the shift[] lookups with constants and, 38 | // with suitable variable renaming in each 39 | // unrolled body, delete the a, b, c, d = d, a, b, c 40 | // (or you can let the optimizer do the renaming). 41 | // 42 | // The index variables are uint so that % by a power 43 | // of two can be optimized easily by a compiler. 44 | 45 | // Round 1. 46 | for i := uint(0); i < 16; i++ { 47 | x := i 48 | s := shift1[i%4] 49 | f := ((c ^ d) & b) ^ d 50 | a += f + X[x] 51 | a = a<>(32-s) 52 | a, b, c, d = d, a, b, c 53 | } 54 | 55 | // Round 2. 56 | for i := uint(0); i < 16; i++ { 57 | x := xIndex2[i] 58 | s := shift2[i%4] 59 | g := (b & c) | (b & d) | (c & d) 60 | a += g + X[x] + 0x5a827999 61 | a = a<>(32-s) 62 | a, b, c, d = d, a, b, c 63 | } 64 | 65 | // Round 3. 66 | for i := uint(0); i < 16; i++ { 67 | x := xIndex3[i] 68 | s := shift3[i%4] 69 | h := b ^ c ^ d 70 | a += h + X[x] + 0x6ed9eba1 71 | a = a<>(32-s) 72 | a, b, c, d = d, a, b, c 73 | } 74 | 75 | a += aa 76 | b += bb 77 | c += cc 78 | d += dd 79 | 80 | p = p[_Chunk:] 81 | n += _Chunk 82 | } 83 | 84 | dig.s[0] = a 85 | dig.s[1] = b 86 | dig.s[2] = c 87 | dig.s[3] = d 88 | return n 89 | } 90 | -------------------------------------------------------------------------------- /xorm/vendor/google.golang.org/appengine/cloudsql/cloudsql.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package cloudsql exposes access to Google Cloud SQL databases. 7 | 8 | This package does not work in App Engine "flexible environment". 9 | 10 | This package is intended for MySQL drivers to make App Engine-specific 11 | connections. Applications should use this package through database/sql: 12 | Select a pure Go MySQL driver that supports this package, and use sql.Open 13 | with protocol "cloudsql" and an address of the Cloud SQL instance. 14 | 15 | A Go MySQL driver that has been tested to work well with Cloud SQL 16 | is the go-sql-driver: 17 | import "database/sql" 18 | import _ "github.com/go-sql-driver/mysql" 19 | 20 | db, err := sql.Open("mysql", "user@cloudsql(project-id:instance-name)/dbname") 21 | 22 | 23 | Another driver that works well with Cloud SQL is the mymysql driver: 24 | import "database/sql" 25 | import _ "github.com/ziutek/mymysql/godrv" 26 | 27 | db, err := sql.Open("mymysql", "cloudsql:instance-name*dbname/user/password") 28 | 29 | 30 | Using either of these drivers, you can perform a standard SQL query. 31 | This example assumes there is a table named 'users' with 32 | columns 'first_name' and 'last_name': 33 | 34 | rows, err := db.Query("SELECT first_name, last_name FROM users") 35 | if err != nil { 36 | log.Errorf(ctx, "db.Query: %v", err) 37 | } 38 | defer rows.Close() 39 | 40 | for rows.Next() { 41 | var firstName string 42 | var lastName string 43 | if err := rows.Scan(&firstName, &lastName); err != nil { 44 | log.Errorf(ctx, "rows.Scan: %v", err) 45 | continue 46 | } 47 | log.Infof(ctx, "First: %v - Last: %v", firstName, lastName) 48 | } 49 | if err := rows.Err(); err != nil { 50 | log.Errorf(ctx, "Row error: %v", err) 51 | } 52 | */ 53 | package cloudsql 54 | 55 | import ( 56 | "net" 57 | ) 58 | 59 | // Dial connects to the named Cloud SQL instance. 60 | func Dial(instance string) (net.Conn, error) { 61 | return connect(instance) 62 | } 63 | -------------------------------------------------------------------------------- /xorm/vendor/google.golang.org/appengine/cloudsql/cloudsql_classic.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build appengine 6 | 7 | package cloudsql 8 | 9 | import ( 10 | "net" 11 | 12 | "appengine/cloudsql" 13 | ) 14 | 15 | func connect(instance string) (net.Conn, error) { 16 | return cloudsql.Dial(instance) 17 | } 18 | -------------------------------------------------------------------------------- /xorm/vendor/google.golang.org/appengine/cloudsql/cloudsql_vm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 Google Inc. All rights reserved. 2 | // Use of this source code is governed by the Apache 2.0 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | 7 | package cloudsql 8 | 9 | import ( 10 | "errors" 11 | "net" 12 | ) 13 | 14 | func connect(instance string) (net.Conn, error) { 15 | return nil, errors.New(`cloudsql: not supported in App Engine "flexible environment"`) 16 | } 17 | -------------------------------------------------------------------------------- /xorm/vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # cloud.google.com/go v0.37.0 2 | cloud.google.com/go/civil 3 | # github.com/denisenkom/go-mssqldb v0.0.0-20180707235734-242fa5aa1b45 4 | github.com/denisenkom/go-mssqldb 5 | github.com/denisenkom/go-mssqldb/internal/cp 6 | # github.com/go-sql-driver/mysql v0.0.0-20180719071942-99ff426eb706 7 | github.com/go-sql-driver/mysql 8 | # github.com/go-xorm/builder v0.0.0-20180826070321-377feedb49e3 9 | github.com/go-xorm/builder 10 | # github.com/go-xorm/core v0.6.1-0.20181008132326-6bc9412b1c4d 11 | github.com/go-xorm/core 12 | # github.com/go-xorm/xorm v0.0.0-20180925133144-7a9249de3324 13 | github.com/go-xorm/xorm 14 | # github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 15 | github.com/lib/pq 16 | github.com/lib/pq/oid 17 | # github.com/lunny/log v0.0.0-20160921050905-7887c61bf0de 18 | github.com/lunny/log 19 | # github.com/mattn/go-sqlite3 v1.9.0 20 | github.com/mattn/go-sqlite3 21 | # github.com/ziutek/mymysql v0.0.0-20171217234033-ff6cc86d3d93 22 | github.com/ziutek/mymysql/godrv 23 | github.com/ziutek/mymysql/mysql 24 | github.com/ziutek/mymysql/native 25 | # golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a 26 | golang.org/x/crypto/md4 27 | # google.golang.org/appengine v1.4.0 28 | google.golang.org/appengine/cloudsql 29 | --------------------------------------------------------------------------------