├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ ├── go.yml
│ └── golangci-lint.yml
├── .gitignore
├── .golangci.yml
├── .run
├── docker-compose.yml[postgres, mysql, sqlserver]_ Compose Deployment.run.xml
└── go test goqu.run.xml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── HISTORY.md
├── LICENSE
├── Makefile
├── README.md
├── _config.yml
├── codecov.yml
├── database.go
├── database_example_test.go
├── database_test.go
├── delete_dataset.go
├── delete_dataset_example_test.go
├── delete_dataset_test.go
├── dialect
├── mysql
│ ├── mysql.go
│ ├── mysql_dialect_test.go
│ └── mysql_test.go
├── postgres
│ ├── postgres.go
│ └── postgres_test.go
├── sqlite3
│ ├── sqlite3.go
│ ├── sqlite3_dialect_test.go
│ └── sqlite3_test.go
└── sqlserver
│ ├── sqlserver.go
│ ├── sqlserver_dialect_test.go
│ └── sqlserver_test.go
├── docker-compose.yml
├── docs
├── database.md
├── deleting.md
├── dialect.md
├── expressions.md
├── inserting.md
├── interpolation.md
├── selecting.md
├── time.md
├── updating.md
└── version_migration.md
├── exec
├── query_executor.go
├── query_executor_internal_test.go
├── query_factory.go
├── scanner.go
└── scanner_internal_test.go
├── exp
├── alias.go
├── alias_test.go
├── bitwise.go
├── bitwise_test.go
├── bool.go
├── case.go
├── case_test.go
├── cast.go
├── cast_test.go
├── col.go
├── compound.go
├── conflict.go
├── cte.go
├── delete_clauses.go
├── delete_clauses_test.go
├── exp.go
├── exp_list.go
├── exp_map.go
├── exp_map_test.go
├── func.go
├── func_test.go
├── ident.go
├── ident_test.go
├── insert.go
├── insert_clauses.go
├── insert_clauses_test.go
├── insert_test.go
├── join.go
├── lateral.go
├── lateral_test.go
├── literal.go
├── literal_test.go
├── lock.go
├── order.go
├── range.go
├── record.go
├── select_clauses.go
├── select_clauses_test.go
├── truncate.go
├── truncate_clauses.go
├── truncate_clauses_test.go
├── update.go
├── update_clauses.go
├── update_clauses_test.go
├── update_test.go
├── window.go
├── window_func.go
├── window_func_test.go
└── window_test.go
├── expressions.go
├── expressions_example_test.go
├── expressions_test.go
├── go.coverage.sh
├── go.mod
├── go.sum
├── go.test.sh
├── goqu.go
├── goqu_example_test.go
├── goqu_test.go
├── insert_dataset.go
├── insert_dataset_example_test.go
├── insert_dataset_test.go
├── internal
├── errors
│ └── error.go
├── sb
│ └── sql_builder.go
├── tag
│ └── tags.go
└── util
│ ├── column_map.go
│ ├── reflect.go
│ ├── reflect_test.go
│ └── value_slice.go
├── issues_test.go
├── mocks
└── SQLDialect.go
├── prepared.go
├── select_dataset.go
├── select_dataset_example_test.go
├── select_dataset_test.go
├── sql_dialect.go
├── sql_dialect_example_test.go
├── sql_dialect_internal_test.go
├── sqlgen
├── base_test.go
├── common_sql_generator.go
├── common_sql_generator_test.go
├── delete_sql_generator.go
├── delete_sql_generator_test.go
├── expression_sql_generator.go
├── expression_sql_generator_test.go
├── insert_sql_generator.go
├── insert_sql_generator_test.go
├── mocks
│ ├── DeleteSQLGenerator.go
│ ├── InsertSQLGenerator.go
│ ├── SelectSQLGenerator.go
│ ├── TruncateSQLGenerator.go
│ └── UpdateSQLGenerator.go
├── select_sql_generator.go
├── select_sql_generator_test.go
├── sql_dialect_options.go
├── sql_dialect_options_test.go
├── sqlgen.go
├── truncate_sql_generator.go
├── truncate_sql_generator_test.go
├── update_sql_generator.go
└── update_sql_generator_test.go
├── truncate_dataset.go
├── truncate_dataset_test.go
├── update_dataset.go
├── update_dataset_example_test.go
├── update_dataset_test.go
├── vendor
├── github.com
│ ├── DATA-DOG
│ │ └── go-sqlmock
│ │ │ ├── .gitignore
│ │ │ ├── .travis.yml
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── argument.go
│ │ │ ├── column.go
│ │ │ ├── driver.go
│ │ │ ├── expectations.go
│ │ │ ├── expectations_before_go18.go
│ │ │ ├── expectations_go18.go
│ │ │ ├── options.go
│ │ │ ├── query.go
│ │ │ ├── result.go
│ │ │ ├── rows.go
│ │ │ ├── rows_go18.go
│ │ │ ├── sqlmock.go
│ │ │ ├── sqlmock_before_go18.go
│ │ │ ├── sqlmock_go18.go
│ │ │ ├── sqlmock_go18_19.go
│ │ │ ├── sqlmock_go19.go
│ │ │ ├── statement.go
│ │ │ ├── statement_before_go18.go
│ │ │ └── statement_go18.go
│ ├── davecgh
│ │ └── go-spew
│ │ │ ├── LICENSE
│ │ │ └── spew
│ │ │ ├── bypass.go
│ │ │ ├── bypasssafe.go
│ │ │ ├── common.go
│ │ │ ├── config.go
│ │ │ ├── doc.go
│ │ │ ├── dump.go
│ │ │ ├── format.go
│ │ │ └── spew.go
│ ├── denisenkom
│ │ └── go-mssqldb
│ │ │ ├── .gitignore
│ │ │ ├── .golangci.yml
│ │ │ ├── LICENSE.txt
│ │ │ ├── README.md
│ │ │ ├── accesstokenconnector.go
│ │ │ ├── appveyor.yml
│ │ │ ├── buf.go
│ │ │ ├── bulkcopy.go
│ │ │ ├── bulkcopy_sql.go
│ │ │ ├── convert.go
│ │ │ ├── doc.go
│ │ │ ├── error.go
│ │ │ ├── fedauth.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
│ │ │ ├── decimal
│ │ │ │ └── decimal.go
│ │ │ └── querytext
│ │ │ │ └── parser.go
│ │ │ ├── log.go
│ │ │ ├── msdsn
│ │ │ ├── conn_str.go
│ │ │ ├── conn_str_go115.go
│ │ │ ├── conn_str_go115pre.go
│ │ │ ├── conn_str_go118.go
│ │ │ └── conn_str_go118pre.go
│ │ │ ├── mssql.go
│ │ │ ├── mssql_go110.go
│ │ │ ├── mssql_go110pre.go
│ │ │ ├── mssql_go118.go
│ │ │ ├── mssql_go118pre.go
│ │ │ ├── mssql_go19.go
│ │ │ ├── mssql_go19pre.go
│ │ │ ├── net.go
│ │ │ ├── ntlm.go
│ │ │ ├── rpc.go
│ │ │ ├── sspi_windows.go
│ │ │ ├── tds.go
│ │ │ ├── token.go
│ │ │ ├── token_string.go
│ │ │ ├── tran.go
│ │ │ ├── tvp_go19.go
│ │ │ ├── types.go
│ │ │ └── uniqueidentifier.go
│ ├── go-sql-driver
│ │ └── mysql
│ │ │ ├── .gitignore
│ │ │ ├── AUTHORS
│ │ │ ├── CHANGELOG.md
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── atomic_bool.go
│ │ │ ├── atomic_bool_go118.go
│ │ │ ├── auth.go
│ │ │ ├── buffer.go
│ │ │ ├── collations.go
│ │ │ ├── conncheck.go
│ │ │ ├── conncheck_dummy.go
│ │ │ ├── connection.go
│ │ │ ├── connector.go
│ │ │ ├── const.go
│ │ │ ├── driver.go
│ │ │ ├── dsn.go
│ │ │ ├── errors.go
│ │ │ ├── fields.go
│ │ │ ├── fuzz.go
│ │ │ ├── infile.go
│ │ │ ├── nulltime.go
│ │ │ ├── packets.go
│ │ │ ├── result.go
│ │ │ ├── rows.go
│ │ │ ├── statement.go
│ │ │ ├── transaction.go
│ │ │ └── utils.go
│ ├── golang-sql
│ │ ├── civil
│ │ │ ├── CONTRIBUTING.md
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ └── civil.go
│ │ └── sqlexp
│ │ │ ├── LICENSE
│ │ │ ├── PATENTS
│ │ │ ├── README.md
│ │ │ ├── doc.go
│ │ │ ├── messages.go
│ │ │ ├── mssql.go
│ │ │ ├── namer.go
│ │ │ ├── pg.go
│ │ │ ├── querier.go
│ │ │ ├── quoter.go
│ │ │ ├── registry.go
│ │ │ └── savepoint.go
│ ├── lib
│ │ └── pq
│ │ │ ├── .gitignore
│ │ │ ├── LICENSE.md
│ │ │ ├── README.md
│ │ │ ├── TESTS.md
│ │ │ ├── array.go
│ │ │ ├── buf.go
│ │ │ ├── conn.go
│ │ │ ├── conn_go115.go
│ │ │ ├── conn_go18.go
│ │ │ ├── connector.go
│ │ │ ├── copy.go
│ │ │ ├── doc.go
│ │ │ ├── encode.go
│ │ │ ├── error.go
│ │ │ ├── krb.go
│ │ │ ├── notice.go
│ │ │ ├── notify.go
│ │ │ ├── oid
│ │ │ ├── doc.go
│ │ │ └── types.go
│ │ │ ├── rows.go
│ │ │ ├── scram
│ │ │ └── scram.go
│ │ │ ├── ssl.go
│ │ │ ├── ssl_permissions.go
│ │ │ ├── ssl_windows.go
│ │ │ ├── url.go
│ │ │ ├── user_other.go
│ │ │ ├── user_posix.go
│ │ │ ├── user_windows.go
│ │ │ └── uuid.go
│ ├── mattn
│ │ └── go-sqlite3
│ │ │ ├── .codecov.yml
│ │ │ ├── .gitignore
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── backup.go
│ │ │ ├── callback.go
│ │ │ ├── convert.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_column_metadata.go
│ │ │ ├── sqlite3_opt_foreign_keys.go
│ │ │ ├── sqlite3_opt_fts5.go
│ │ │ ├── sqlite3_opt_icu.go
│ │ │ ├── sqlite3_opt_introspect.go
│ │ │ ├── sqlite3_opt_math_functions.go
│ │ │ ├── sqlite3_opt_os_trace.go
│ │ │ ├── sqlite3_opt_preupdate.go
│ │ │ ├── sqlite3_opt_preupdate_hook.go
│ │ │ ├── sqlite3_opt_preupdate_omit.go
│ │ │ ├── sqlite3_opt_secure_delete.go
│ │ │ ├── sqlite3_opt_secure_delete_fast.go
│ │ │ ├── sqlite3_opt_serialize.go
│ │ │ ├── sqlite3_opt_serialize_omit.go
│ │ │ ├── sqlite3_opt_stat4.go
│ │ │ ├── sqlite3_opt_unlock_notify.c
│ │ │ ├── sqlite3_opt_unlock_notify.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
│ ├── pmezard
│ │ └── go-difflib
│ │ │ ├── LICENSE
│ │ │ └── difflib
│ │ │ └── difflib.go
│ └── stretchr
│ │ ├── objx
│ │ ├── .codeclimate.yml
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── Taskfile.yml
│ │ ├── accessors.go
│ │ ├── conversions.go
│ │ ├── doc.go
│ │ ├── map.go
│ │ ├── mutations.go
│ │ ├── security.go
│ │ ├── tests.go
│ │ ├── type_specific.go
│ │ ├── type_specific_codegen.go
│ │ └── value.go
│ │ └── testify
│ │ ├── LICENSE
│ │ ├── assert
│ │ ├── assertion_compare.go
│ │ ├── assertion_compare_can_convert.go
│ │ ├── assertion_compare_legacy.go
│ │ ├── assertion_format.go
│ │ ├── assertion_format.go.tmpl
│ │ ├── assertion_forward.go
│ │ ├── assertion_forward.go.tmpl
│ │ ├── assertion_order.go
│ │ ├── assertions.go
│ │ ├── doc.go
│ │ ├── errors.go
│ │ ├── forward_assertions.go
│ │ └── http_assertions.go
│ │ ├── mock
│ │ ├── doc.go
│ │ └── mock.go
│ │ ├── require
│ │ ├── doc.go
│ │ ├── forward_requirements.go
│ │ ├── require.go
│ │ ├── require.go.tmpl
│ │ ├── require_forward.go
│ │ ├── require_forward.go.tmpl
│ │ └── requirements.go
│ │ └── suite
│ │ ├── doc.go
│ │ ├── interfaces.go
│ │ ├── stats.go
│ │ └── suite.go
├── golang.org
│ └── x
│ │ └── crypto
│ │ ├── LICENSE
│ │ ├── PATENTS
│ │ └── md4
│ │ ├── md4.go
│ │ └── md4block.go
├── gopkg.in
│ └── yaml.v3
│ │ ├── LICENSE
│ │ ├── NOTICE
│ │ ├── README.md
│ │ ├── apic.go
│ │ ├── decode.go
│ │ ├── emitterc.go
│ │ ├── encode.go
│ │ ├── parserc.go
│ │ ├── readerc.go
│ │ ├── resolve.go
│ │ ├── scannerc.go
│ │ ├── sorter.go
│ │ ├── writerc.go
│ │ ├── yaml.go
│ │ ├── yamlh.go
│ │ └── yamlprivateh.go
└── modules.txt
└── wait-for-it.sh
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | If applicable provide a small code snippet to reproduce the issue:
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen.
18 |
19 | **Dialect:**
20 |
21 | - [ ] postgres
22 | - [ ] mysql
23 | - [ ] sqlite3
24 |
25 | **Additional context**
26 | Add any other context about the problem here.
27 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: doug-martin
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Dialect**
20 | - [ ] postgres
21 | - [ ] mysql
22 | - [ ] sqlite3
23 |
24 | **Additional context**
25 | Add any other context or screenshots about the feature request here.
26 |
--------------------------------------------------------------------------------
/.github/workflows/go.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 | on:
3 | push:
4 | branches: # Array of patterns that match refs/heads
5 | - master # Push events on master branch
6 | - releases/* # Push events to branches matching refs/heads/releases/*
7 | pull_request: # Specify a second event with pattern matching
8 | jobs:
9 | test:
10 | name: Test go - ${{ matrix.go_version }} mysql - ${{ matrix.db_versions.mysql_version}} postgres - ${{ matrix.db_versions.postgres_version}} sqlserver- ${{ matrix.db_versions.sqlserver_version}}
11 | runs-on: ubuntu-latest
12 | strategy:
13 | matrix:
14 | go_version: ["1.19", "latest"]
15 | db_versions:
16 | - mysql_version: 5.7
17 | postgres_version: 9
18 | sqlserver_version: "2017-latest"
19 | - mysql_version: "8.0"
20 | postgres_version: 10
21 | sqlserver_version: "2019-latest"
22 | - mysql_version: 8
23 | postgres_version: 11
24 | sqlserver_version: "2022-latest"
25 | - mysql_version: 8
26 | postgres_version: 15
27 | sqlserver_version: "2022-latest"
28 | env:
29 | GO_VERSION: ${{ matrix.go_version }}
30 | MYSQL_VERSION: ${{ matrix.db_versions.mysql_version }}
31 | POSTGRES_VERSION: ${{ matrix.db_versions.postgres_version }}
32 | SQLSERVER_VERSION: ${{ matrix.db_versions.sqlserver_version }}
33 | steps:
34 | - name: checkout
35 | uses: actions/checkout@v3
36 | - name: Test
37 | run: docker-compose run goqu-coverage
38 | - name: Upload coverage to Codecov
39 | uses: codecov/codecov-action@v1
40 | with:
41 | token: ${{ secrets.CODECOV_TOKEN }}
42 | flags: unittests
43 | env_vars: OS,MYSQL_VERSION,POSTGRES_VERSION,SQLSERVER_VERSION
44 | name: codecov-umbrella
45 | fail_ci_if_error: true
46 | verbose: true
47 |
--------------------------------------------------------------------------------
/.github/workflows/golangci-lint.yml:
--------------------------------------------------------------------------------
1 | name: golangci-lint
2 | on:
3 | push:
4 | tags:
5 | - v*
6 | branches:
7 | - master
8 | - main
9 | pull_request:
10 | jobs:
11 | golangci:
12 | name: lint
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v3
16 | - uses: actions/setup-go@v4
17 | with:
18 | go-version: '1.20'
19 | cache: false
20 | - name: golangci-lint
21 | uses: golangci/golangci-lint-action@v3
22 | with:
23 | # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
24 | version: latest
25 |
26 | # Optional: working directory, useful for monorepos
27 | # working-directory: somedir
28 |
29 | # Optional: golangci-lint command line arguments.
30 | # args: --issues-exit-code=0
31 | args: --timeout 3m0s
32 | # Optional: show only new issues if it's a pull request. The default value is `false`.
33 | # only-new-issues: true
34 |
35 | # Optional: if set to true then the action will use pre-installed Go.
36 | # skip-go-installation: true
37 |
38 | # Optional: if set to true then the action don't cache or restore ~/go/pkg.
39 | # skip-pkg-cache: true
40 |
41 | # Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
42 | # skip-build-cache: true
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | src
3 | *.iml
4 | coverage.*
--------------------------------------------------------------------------------
/.run/docker-compose.yml[postgres, mysql, sqlserver]_ Compose Deployment.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/.run/go test goqu.run.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributions
2 |
3 | I am always welcoming contributions of any type. Please open an issue or create a PR if you find an issue with any of the following.
4 |
5 | * An issue with Documentation
6 | * You found the documentation lacking in some way
7 |
8 | If you have an issue with the package please include the following
9 |
10 | * The dialect you are using
11 | * A description of the problem
12 | * A short example of how to reproduce (if applicable)
13 |
14 | Without those basics it can be difficult to reproduce your issue locally. You may be asked for more information but that is a good starting point.
15 |
16 | ### New Features
17 |
18 | New features and/or enhancements are great and I encourage you to either submit a PR or create an issue. In both cases include the following as the need/requirement may not be readily apparent.
19 |
20 | 1. The use case
21 | 2. A short example
22 |
23 | If you are issuing a PR also also include the following
24 |
25 | 1. Tests - otherwise the PR will not be merged
26 | 2. Documentation - otherwise the PR will not be merged
27 | 3. Examples - [If applicable] see example_test.go for examples
28 |
29 | If you find an issue you want to work on please comment on it letting other people know you are looking at it and I will assign the issue to you.
30 |
31 | If want to work on an issue but dont know where to start just leave a comment and I'll be more than happy to point you in the right direction.
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Doug Martin
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 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #phony dependency task that does nothing
2 | #"make executable" does not run if there is a ./executable directory, unless the task has a dependency
3 | phony:
4 |
5 | lint:
6 | docker run --rm -v ${CURDIR}:/app -w /app golangci/golangci-lint:v1.53.3 golangci-lint run -v
7 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/codecov.yml:
--------------------------------------------------------------------------------
1 | ignore:
2 | - "**/mocks/**" # glob accepted
3 | - "mocks/**" # glob accepted
--------------------------------------------------------------------------------
/dialect/postgres/postgres.go:
--------------------------------------------------------------------------------
1 | package postgres
2 |
3 | import (
4 | "github.com/doug-martin/goqu/v9"
5 | )
6 |
7 | func DialectOptions() *goqu.SQLDialectOptions {
8 | do := goqu.DefaultDialectOptions()
9 | do.PlaceHolderFragment = []byte("$")
10 | do.IncludePlaceholderNum = true
11 | return do
12 | }
13 |
14 | func init() {
15 | goqu.RegisterDialect("postgres", DialectOptions())
16 | }
17 |
--------------------------------------------------------------------------------
/dialect/sqlserver/sqlserver_dialect_test.go:
--------------------------------------------------------------------------------
1 | package sqlserver_test
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/doug-martin/goqu/v9"
7 | "github.com/doug-martin/goqu/v9/exp"
8 | "github.com/stretchr/testify/suite"
9 | )
10 |
11 | type (
12 | sqlserverDialectSuite struct {
13 | suite.Suite
14 | }
15 | sqlTestCase struct {
16 | ds exp.SQLExpression
17 | sql string
18 | err string
19 | isPrepared bool
20 | args []interface{}
21 | }
22 | )
23 |
24 | func (sds *sqlserverDialectSuite) GetDs(table string) *goqu.SelectDataset {
25 | return goqu.Dialect("sqlserver").From(table)
26 | }
27 |
28 | func (sds *sqlserverDialectSuite) assertSQL(cases ...sqlTestCase) {
29 | for i, c := range cases {
30 | actualSQL, actualArgs, err := c.ds.ToSQL()
31 | if c.err == "" {
32 | sds.NoError(err, "test case %d failed", i)
33 | } else {
34 | sds.EqualError(err, c.err, "test case %d failed", i)
35 | }
36 | sds.Equal(c.sql, actualSQL, "test case %d failed", i)
37 | if c.isPrepared && c.args != nil || len(c.args) > 0 {
38 | sds.Equal(c.args, actualArgs, "test case %d failed", i)
39 | } else {
40 | sds.Empty(actualArgs, "test case %d failed", i)
41 | }
42 | }
43 | }
44 |
45 | func (sds *sqlserverDialectSuite) TestBitwiseOperations() {
46 | col := goqu.C("a")
47 | ds := sds.GetDs("test")
48 | sds.assertSQL(
49 | sqlTestCase{ds: ds.Where(col.BitwiseInversion()), sql: "SELECT * FROM \"test\" WHERE (~ \"a\")"},
50 | sqlTestCase{ds: ds.Where(col.BitwiseAnd(1)), sql: "SELECT * FROM \"test\" WHERE (\"a\" & 1)"},
51 | sqlTestCase{ds: ds.Where(col.BitwiseOr(1)), sql: "SELECT * FROM \"test\" WHERE (\"a\" | 1)"},
52 | sqlTestCase{ds: ds.Where(col.BitwiseXor(1)), sql: "SELECT * FROM \"test\" WHERE (\"a\" ^ 1)"},
53 | sqlTestCase{ds: ds.Where(col.BitwiseLeftShift(1)), err: "goqu: bitwise operator 'Left Shift' not supported"},
54 | sqlTestCase{ds: ds.Where(col.BitwiseRightShift(1)), err: "goqu: bitwise operator 'Right Shift' not supported"},
55 | )
56 | }
57 |
58 | func TestDatasetAdapterSuite(t *testing.T) {
59 | suite.Run(t, new(sqlserverDialectSuite))
60 | }
61 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "2"
2 |
3 | services:
4 | postgres:
5 | image: "postgres:${POSTGRES_VERSION}"
6 | environment:
7 | - "POSTGRES_USER=postgres"
8 | - "POSTGRES_DB=goqupostgres"
9 | - "POSTGRES_HOST_AUTH_METHOD=trust"
10 | expose:
11 | - "5432"
12 | ports:
13 | - "5432:5432"
14 |
15 | mysql:
16 | image: "mysql:${MYSQL_VERSION}"
17 | environment:
18 | - "MYSQL_DATABASE=goqumysql"
19 | - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
20 | expose:
21 | - "3306"
22 | ports:
23 | - "3306:3306"
24 |
25 | sqlserver:
26 | image: "mcr.microsoft.com/mssql/server:${SQLSERVER_VERSION}"
27 | environment:
28 | - "ACCEPT_EULA=Y"
29 | - "SA_PASSWORD=qwe123QWE"
30 | expose:
31 | - "1433"
32 | ports:
33 | - "1433:1433"
34 |
35 | goqu:
36 | image: "golang:${GO_VERSION}"
37 | command: ["./wait-for-it.sh", "postgres:5432", "--", "./wait-for-it.sh", "mysql:3306", "--", "./wait-for-it.sh", "sqlserver:1433", "--", "./go.test.sh"]
38 | working_dir: /go/src/github.com/doug-martin/goqu
39 | volumes:
40 | - "./:/go/src/github.com/doug-martin/goqu"
41 | environment:
42 | MYSQL_URI: 'root@tcp(mysql:3306)/goqumysql?parseTime=true'
43 | PG_URI: 'postgres://postgres:@postgres:5432/goqupostgres?sslmode=disable'
44 | SQLSERVER_URI: 'sqlserver://sa:qwe123QWE@sqlserver:1433?database=master&connection+timeout=30'
45 | depends_on:
46 | - postgres
47 | - mysql
48 | - sqlserver
49 | goqu-coverage:
50 | image: "golang:${GO_VERSION}"
51 | command: ["./wait-for-it.sh", "postgres:5432", "--", "./wait-for-it.sh", "mysql:3306", "--", "./wait-for-it.sh", "sqlserver:1433", "--", "./go.coverage.sh"]
52 | working_dir: /go/src/github.com/doug-martin/goqu
53 | volumes:
54 | - "./:/go/src/github.com/doug-martin/goqu"
55 | environment:
56 | MYSQL_URI: 'root@tcp(mysql:3306)/goqumysql?parseTime=true'
57 | PG_URI: 'postgres://postgres:@postgres:5432/goqupostgres?sslmode=disable'
58 | SQLSERVER_URI: 'sqlserver://sa:qwe123QWE@sqlserver:1433?database=master&connection+timeout=30'
59 | depends_on:
60 | - postgres
61 | - mysql
62 | - sqlserver
63 |
--------------------------------------------------------------------------------
/docs/interpolation.md:
--------------------------------------------------------------------------------
1 | # Prepared Statements
2 |
3 | By default the `goqu` will interpolate all parameters, if you do not want to have values interpolated you can use the [`Prepared`](http://godoc.org/github.com/doug-martin/goqu#SelectDataset.Prepared) method to prevent this.
4 |
5 | **Note** For the examples all placeholders are `?` this will be dialect specific when using other examples (e.g. Postgres `$1, $2...`)
6 |
7 | ```go
8 |
9 | preparedDs := db.From("items").Prepared(true)
10 |
11 | sql, args, _ := preparedDs.Where(goqu.Ex{
12 | "col1": "a",
13 | "col2": 1,
14 | "col3": true,
15 | "col4": false,
16 | "col5": []string{"a", "b", "c"},
17 | }).ToSQL()
18 | fmt.Println(sql, args)
19 |
20 | sql, args, _ = preparedDs.Insert().Rows(
21 | goqu.Record{"name": "Test1", "address": "111 Test Addr"},
22 | goqu.Record{"name": "Test2", "address": "112 Test Addr"},
23 | ).ToSQL()
24 | fmt.Println(sql, args)
25 |
26 | sql, args, _ = preparedDs.Update().Set(
27 | goqu.Record{"name": "Test", "address": "111 Test Addr"},
28 | ).ToSQL()
29 | fmt.Println(sql, args)
30 |
31 | sql, args, _ = preparedDs.
32 | Delete().
33 | Where(goqu.Ex{"id": goqu.Op{"gt": 10}}).
34 | ToSQL()
35 | fmt.Println(sql, args)
36 |
37 | // Output:
38 | // SELECT * FROM "items" WHERE (("col1" = ?) AND ("col2" = ?) AND ("col3" IS TRUE) AND ("col4" IS FALSE) AND ("col5" IN (?, ?, ?))) [a 1 a b c]
39 | // INSERT INTO "items" ("address", "name") VALUES (?, ?), (?, ?) [111 Test Addr Test1 112 Test Addr Test2]
40 | // UPDATE "items" SET "address"=?,"name"=? [111 Test Addr Test]
41 | // DELETE FROM "items" WHERE ("id" > ?) [10]
42 | ```
43 |
44 | When setting prepared to true executing the SQL using the different querying methods will also use the non-interpolated SQL also.
45 |
46 | ```go
47 | var items []Item
48 | sql, args, _ := db.From("items").Prepared(true).Where(goqu.Ex{
49 | "col1": "a",
50 | "col2": 1,
51 | }).ScanStructs(&items)
52 |
53 | //Is the same as
54 | db.ScanStructs(&items, `SELECT * FROM "items" WHERE (("col1" = ?) AND ("col2" = ?))`, "a", 1)
55 | ```
56 |
57 |
--------------------------------------------------------------------------------
/docs/time.md:
--------------------------------------------------------------------------------
1 | # Working with time.Time
2 |
3 | By default when interpolating `time.Time` (and `*time.Time`) `goqu` will convert it `UTC` before interpolating.
4 |
5 | ## Why?
6 |
7 | For most use cases `UTC` should be preferred, if a timezone is specified it is usually ignored silently by `postgres` and `mysql` unless you configure your DB to run in a different timezone, leading to unexpected behavior.
8 |
9 | ## How to use a different default timezone?
10 | `goqu` provides a **_global_** configuration settings to set the [location](https://golang.org/pkg/time/#Location) to convert all timestamps to.
11 |
12 | To change the default timezone to covert time instances to you can use [`goqu.SetTimeLocation`](https://godoc.org/github.com/doug-martin/goqu#SetTimeLocation) to change the default timezone.
13 |
14 | In the following example the default value `UTC` is used.
15 |
16 | ```go
17 | created, err := time.Parse(time.RFC3339, "2019-10-01T15:01:00Z")
18 | if err != nil {
19 | panic(err)
20 | }
21 |
22 | ds := goqu.Insert("test").Rows(goqu.Record{
23 | "address": "111 Address",
24 | "name": "Bob Yukon",
25 | "created": created,
26 | })
27 | ```
28 |
29 | Output:
30 | ```
31 | INSERT INTO "test" ("address", "created", "name") VALUES ('111 Address', '2019-10-01T15:01:00Z', 'Bob Yukon')
32 | ```
33 |
34 | In the following example `UTC` is overridden to `Asia/Shanghai`
35 |
36 | ```go
37 | loc, err := time.LoadLocation("Asia/Shanghai")
38 | if err != nil {
39 | panic(err)
40 | }
41 |
42 | goqu.SetTimeLocation(loc)
43 |
44 | created, err := time.Parse(time.RFC3339, "2019-10-01T15:01:00Z")
45 | if err != nil {
46 | panic(err)
47 | }
48 |
49 | ds := goqu.Insert("test").Rows(goqu.Record{
50 | "address": "111 Address",
51 | "name": "Bob Yukon",
52 | "created": created,
53 | })
54 | ```
55 |
56 | Output:
57 | ```
58 | INSERT INTO "test" ("address", "created", "name") VALUES ('111 Address', '2019-10-01T23:01:00+08:00', 'Bob Yukon')
59 | ```
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/exec/query_factory.go:
--------------------------------------------------------------------------------
1 | package exec
2 |
3 | import (
4 | "context"
5 | "database/sql"
6 |
7 | "github.com/doug-martin/goqu/v9/internal/sb"
8 | )
9 |
10 | type (
11 | //nolint:stylecheck // keep name for backwards compatibility
12 | DbExecutor interface {
13 | ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
14 | QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
15 | }
16 | QueryFactory interface {
17 | FromSQL(sql string, args ...interface{}) QueryExecutor
18 | FromSQLBuilder(b sb.SQLBuilder) QueryExecutor
19 | }
20 | querySupport struct {
21 | de DbExecutor
22 | }
23 | )
24 |
25 | func NewQueryFactory(de DbExecutor) QueryFactory {
26 | return &querySupport{de}
27 | }
28 |
29 | func (qs *querySupport) FromSQL(query string, args ...interface{}) QueryExecutor {
30 | return newQueryExecutor(qs.de, nil, query, args...)
31 | }
32 |
33 | func (qs *querySupport) FromSQLBuilder(b sb.SQLBuilder) QueryExecutor {
34 | query, args, err := b.ToSQL()
35 | return newQueryExecutor(qs.de, err, query, args...)
36 | }
37 |
--------------------------------------------------------------------------------
/exec/scanner_internal_test.go:
--------------------------------------------------------------------------------
1 | package exec
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/DATA-DOG/go-sqlmock"
7 | "github.com/stretchr/testify/suite"
8 | )
9 |
10 | type scannerSuite struct {
11 | suite.Suite
12 | }
13 |
14 | func TestScanner(t *testing.T) {
15 | suite.Run(t, &scannerSuite{})
16 | }
17 |
18 | func (s *scannerSuite) TestScanStructs() {
19 | type StructWithTags struct {
20 | Address string `db:"address"`
21 | Name string `db:"name"`
22 | }
23 | db, mock, err := sqlmock.New()
24 | s.Require().NoError(err)
25 |
26 | mock.ExpectQuery(`SELECT \* FROM "items"`).
27 | WithArgs().
28 | WillReturnRows(sqlmock.NewRows([]string{"address", "name"}).
29 | AddRow(testAddr1, testName1).
30 | AddRow(testAddr2, testName2),
31 | )
32 | rows, err := db.Query(`SELECT * FROM "items"`)
33 | s.Require().NoError(err)
34 |
35 | sc := NewScanner(rows)
36 |
37 | result := make([]StructWithTags, 0)
38 | err = sc.ScanStructs(result)
39 | s.Require().EqualError(err, errUnsupportedScanStructsType.Error())
40 |
41 | err = sc.ScanStructs(&result)
42 | s.Require().NoError(err)
43 | s.Require().ElementsMatch(
44 | []StructWithTags{{Address: testAddr1, Name: testName1}, {Address: testAddr2, Name: testName2}},
45 | result,
46 | )
47 | }
48 |
49 | func (s *scannerSuite) TestScanVals() {
50 | db, mock, err := sqlmock.New()
51 | s.Require().NoError(err)
52 |
53 | mock.ExpectQuery(`SELECT "id" FROM "items"`).
54 | WithArgs().
55 | WillReturnRows(sqlmock.NewRows([]string{"id"}).AddRow(1).AddRow(2))
56 |
57 | rows, err := db.Query(`SELECT "id" FROM "items"`)
58 | s.Require().NoError(err)
59 |
60 | sc := NewScanner(rows)
61 |
62 | result := make([]int, 0)
63 | err = sc.ScanVals(result)
64 | s.Require().EqualError(err, errUnsupportedScanValsType.Error())
65 |
66 | err = sc.ScanVals(&result)
67 | s.Require().NoError(err)
68 | s.Require().ElementsMatch([]int{1, 2}, result)
69 | }
70 |
--------------------------------------------------------------------------------
/exp/alias.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | import "fmt"
4 |
5 | type (
6 | aliasExpression struct {
7 | aliased Expression
8 | alias IdentifierExpression
9 | }
10 | )
11 |
12 | // Creates a new AliasedExpression for the Expression and alias
13 | func NewAliasExpression(exp Expression, alias interface{}) AliasedExpression {
14 | switch v := alias.(type) {
15 | case string:
16 | return aliasExpression{aliased: exp, alias: ParseIdentifier(v)}
17 | case IdentifierExpression:
18 | return aliasExpression{aliased: exp, alias: v}
19 | default:
20 | panic(fmt.Sprintf("Cannot create alias from %+v", v))
21 | }
22 | }
23 |
24 | func (ae aliasExpression) Clone() Expression {
25 | return NewAliasExpression(ae.aliased, ae.alias.Clone())
26 | }
27 |
28 | func (ae aliasExpression) Expression() Expression {
29 | return ae
30 | }
31 |
32 | func (ae aliasExpression) Aliased() Expression {
33 | return ae.aliased
34 | }
35 |
36 | func (ae aliasExpression) GetAs() IdentifierExpression {
37 | return ae.alias
38 | }
39 |
40 | // Returns a new IdentifierExpression with the specified schema
41 | func (ae aliasExpression) Schema(schema string) IdentifierExpression {
42 | return ae.alias.Schema(schema)
43 | }
44 |
45 | // Returns a new IdentifierExpression with the specified table
46 | func (ae aliasExpression) Table(table string) IdentifierExpression {
47 | return ae.alias.Table(table)
48 | }
49 |
50 | // Returns a new IdentifierExpression with the specified column
51 | func (ae aliasExpression) Col(col interface{}) IdentifierExpression {
52 | return ae.alias.Col(col)
53 | }
54 |
55 | // Returns a new IdentifierExpression with the column set to *
56 | //
57 | // I("my_table").As("t").All() //"t".*
58 | func (ae aliasExpression) All() IdentifierExpression {
59 | return ae.alias.All()
60 | }
61 |
--------------------------------------------------------------------------------
/exp/alias_test.go:
--------------------------------------------------------------------------------
1 | package exp_test
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/doug-martin/goqu/v9/exp"
7 | "github.com/stretchr/testify/suite"
8 | )
9 |
10 | type aliasExpressionSuite struct {
11 | suite.Suite
12 | }
13 |
14 | func TestAliasExpressionSuite(t *testing.T) {
15 | suite.Run(t, &aliasExpressionSuite{})
16 | }
17 |
18 | func (aes *aliasExpressionSuite) TestClone() {
19 | ae := exp.NewAliasExpression(exp.NewIdentifierExpression("", "", "col"), "c")
20 | aes.Equal(ae, ae.Clone())
21 | }
22 |
23 | func (aes *aliasExpressionSuite) TestExpression() {
24 | ae := exp.NewAliasExpression(exp.NewIdentifierExpression("", "", "col"), "c")
25 | aes.Equal(ae, ae.Expression())
26 | }
27 |
28 | func (aes *aliasExpressionSuite) TestAliased() {
29 | ident := exp.NewIdentifierExpression("", "", "col")
30 | ae := exp.NewAliasExpression(ident, "c")
31 | aes.Equal(ident, ae.Aliased())
32 | }
33 |
34 | func (aes *aliasExpressionSuite) TestGetAs() {
35 | ae := exp.NewAliasExpression(exp.NewIdentifierExpression("", "", "col"), "c")
36 | aes.Equal(exp.NewIdentifierExpression("", "", "c"), ae.GetAs())
37 | }
38 |
39 | func (aes *aliasExpressionSuite) TestSchema() {
40 | si := exp.NewAliasExpression(
41 | exp.NewIdentifierExpression("", "t", nil),
42 | exp.NewIdentifierExpression("", "t", nil),
43 | ).Schema("s")
44 | aes.Equal(exp.NewIdentifierExpression("s", "t", nil), si)
45 | }
46 |
47 | func (aes *aliasExpressionSuite) TestTable() {
48 | si := exp.NewAliasExpression(
49 | exp.NewIdentifierExpression("schema", "", nil),
50 | exp.NewIdentifierExpression("s", "", nil),
51 | ).Table("t")
52 | aes.Equal(exp.NewIdentifierExpression("s", "t", nil), si)
53 | }
54 |
55 | func (aes *aliasExpressionSuite) TestCol() {
56 | si := exp.NewAliasExpression(
57 | exp.NewIdentifierExpression("", "table", nil),
58 | exp.NewIdentifierExpression("", "t", nil),
59 | ).Col("c")
60 | aes.Equal(exp.NewIdentifierExpression("", "t", "c"), si)
61 | }
62 |
63 | func (aes *aliasExpressionSuite) TestAll() {
64 | si := exp.NewAliasExpression(
65 | exp.NewIdentifierExpression("", "table", nil),
66 | exp.NewIdentifierExpression("", "t", nil),
67 | ).All()
68 | aes.Equal(exp.NewIdentifierExpression("", "t", exp.Star()), si)
69 | }
70 |
--------------------------------------------------------------------------------
/exp/case.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type (
4 | caseElse struct {
5 | result interface{}
6 | }
7 | caseWhen struct {
8 | caseElse
9 | condition interface{}
10 | }
11 | caseExpression struct {
12 | value interface{}
13 | whens []CaseWhen
14 | elseCondition CaseElse
15 | }
16 | )
17 |
18 | func NewCaseElse(result interface{}) CaseElse {
19 | return caseElse{result: result}
20 | }
21 |
22 | func (ce caseElse) Result() interface{} {
23 | return ce.result
24 | }
25 |
26 | func NewCaseWhen(condition, result interface{}) CaseWhen {
27 | return caseWhen{caseElse: caseElse{result: result}, condition: condition}
28 | }
29 |
30 | func (cw caseWhen) Condition() interface{} {
31 | return cw.condition
32 | }
33 |
34 | func NewCaseExpression() CaseExpression {
35 | return caseExpression{value: nil, whens: []CaseWhen{}, elseCondition: nil}
36 | }
37 |
38 | func (c caseExpression) Expression() Expression {
39 | return c
40 | }
41 |
42 | func (c caseExpression) Clone() Expression {
43 | return caseExpression{value: c.value, whens: c.whens, elseCondition: c.elseCondition}
44 | }
45 |
46 | func (c caseExpression) As(alias interface{}) AliasedExpression {
47 | return NewAliasExpression(c, alias)
48 | }
49 |
50 | func (c caseExpression) GetValue() interface{} {
51 | return c.value
52 | }
53 |
54 | func (c caseExpression) GetWhens() []CaseWhen {
55 | return c.whens
56 | }
57 |
58 | func (c caseExpression) GetElse() CaseElse {
59 | return c.elseCondition
60 | }
61 |
62 | func (c caseExpression) Value(value interface{}) CaseExpression {
63 | c.value = value
64 | return c
65 | }
66 |
67 | func (c caseExpression) When(condition, result interface{}) CaseExpression {
68 | c.whens = append(c.whens, NewCaseWhen(condition, result))
69 | return c
70 | }
71 |
72 | func (c caseExpression) Else(result interface{}) CaseExpression {
73 | c.elseCondition = NewCaseElse(result)
74 | return c
75 | }
76 |
77 | func (c caseExpression) Asc() OrderedExpression { return asc(c) }
78 | func (c caseExpression) Desc() OrderedExpression { return desc(c) }
79 |
--------------------------------------------------------------------------------
/exp/col.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | import (
4 | "fmt"
5 | "reflect"
6 |
7 | "github.com/doug-martin/goqu/v9/internal/util"
8 | )
9 |
10 | type columnList struct {
11 | columns []Expression
12 | }
13 |
14 | func NewColumnListExpression(vals ...interface{}) ColumnListExpression {
15 | cols := []Expression{}
16 | for _, val := range vals {
17 | switch t := val.(type) {
18 | case nil: // do nothing
19 | case string:
20 | cols = append(cols, ParseIdentifier(t))
21 | case ColumnListExpression:
22 | cols = append(cols, t.Columns()...)
23 | case Expression:
24 | cols = append(cols, t)
25 | default:
26 | _, valKind := util.GetTypeInfo(val, reflect.Indirect(reflect.ValueOf(val)))
27 |
28 | if valKind == reflect.Struct {
29 | cm, err := util.GetColumnMap(val)
30 | if err != nil {
31 | panic(err.Error())
32 | }
33 | structCols := cm.Cols()
34 | for _, col := range structCols {
35 | i := ParseIdentifier(col)
36 | var sc Expression = i
37 | if i.IsQualified() {
38 | sc = i.As(NewIdentifierExpression("", "", col))
39 | }
40 | cols = append(cols, sc)
41 | }
42 | } else {
43 | panic(fmt.Sprintf("Cannot create expression from %+v", val))
44 | }
45 | }
46 | }
47 | return columnList{columns: cols}
48 | }
49 |
50 | func NewOrderedColumnList(vals ...OrderedExpression) ColumnListExpression {
51 | exps := make([]interface{}, 0, len(vals))
52 | for _, col := range vals {
53 | exps = append(exps, col.Expression())
54 | }
55 | return NewColumnListExpression(exps...)
56 | }
57 |
58 | func (cl columnList) Clone() Expression {
59 | newExps := make([]Expression, 0, len(cl.columns))
60 | for _, exp := range cl.columns {
61 | newExps = append(newExps, exp.Clone())
62 | }
63 | return columnList{columns: newExps}
64 | }
65 |
66 | func (cl columnList) Expression() Expression {
67 | return cl
68 | }
69 |
70 | func (cl columnList) IsEmpty() bool {
71 | return len(cl.columns) == 0
72 | }
73 |
74 | func (cl columnList) Columns() []Expression {
75 | return cl.columns
76 | }
77 |
78 | func (cl columnList) Append(cols ...Expression) ColumnListExpression {
79 | ret := columnList{}
80 | exps := ret.columns
81 | exps = append(exps, cl.columns...)
82 | exps = append(exps, cols...)
83 | ret.columns = exps
84 | return ret
85 | }
86 |
--------------------------------------------------------------------------------
/exp/compound.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type compound struct {
4 | t CompoundType
5 | rhs AppendableExpression
6 | }
7 |
8 | func NewCompoundExpression(ct CompoundType, rhs AppendableExpression) CompoundExpression {
9 | return compound{t: ct, rhs: rhs}
10 | }
11 |
12 | func (c compound) Expression() Expression { return c }
13 |
14 | func (c compound) Clone() Expression {
15 | return compound{t: c.t, rhs: c.rhs.Clone().(AppendableExpression)}
16 | }
17 |
18 | func (c compound) Type() CompoundType { return c.t }
19 | func (c compound) RHS() AppendableExpression { return c.rhs }
20 |
--------------------------------------------------------------------------------
/exp/cte.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type commonExpr struct {
4 | recursive bool
5 | name LiteralExpression
6 | subQuery Expression
7 | }
8 |
9 | // Creates a new WITH common table expression for a SQLExpression, typically Datasets'. This function is used
10 | // internally by Dataset when a CTE is added to another Dataset
11 | func NewCommonTableExpression(recursive bool, name string, subQuery Expression) CommonTableExpression {
12 | return commonExpr{recursive: recursive, name: NewLiteralExpression(name), subQuery: subQuery}
13 | }
14 |
15 | func (ce commonExpr) Expression() Expression { return ce }
16 |
17 | func (ce commonExpr) Clone() Expression {
18 | return commonExpr{recursive: ce.recursive, name: ce.name, subQuery: ce.subQuery.Clone().(SQLExpression)}
19 | }
20 |
21 | func (ce commonExpr) IsRecursive() bool { return ce.recursive }
22 | func (ce commonExpr) Name() LiteralExpression { return ce.name }
23 | func (ce commonExpr) SubQuery() Expression { return ce.subQuery }
24 |
--------------------------------------------------------------------------------
/exp/exp_list.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type (
4 | expressionList struct {
5 | operator ExpressionListType
6 | expressions []Expression
7 | }
8 | )
9 |
10 | // A list of expressions that should be ORed together
11 | //
12 | // Or(I("a").Eq(10), I("b").Eq(11)) //(("a" = 10) OR ("b" = 11))
13 | func NewExpressionList(operator ExpressionListType, expressions ...Expression) ExpressionList {
14 | el := expressionList{operator: operator}
15 | exps := make([]Expression, 0, len(el.expressions))
16 | for _, e := range expressions {
17 | switch t := e.(type) {
18 | case ExpressionList:
19 | if !t.IsEmpty() {
20 | exps = append(exps, e)
21 | }
22 | case Ex:
23 | if len(t) > 0 {
24 | exps = append(exps, e)
25 | }
26 | case ExOr:
27 | if len(t) > 0 {
28 | exps = append(exps, e)
29 | }
30 | default:
31 | exps = append(exps, e)
32 | }
33 | }
34 | el.expressions = exps
35 | return el
36 | }
37 |
38 | func (el expressionList) Clone() Expression {
39 | newExps := make([]Expression, 0, len(el.expressions))
40 | for _, exp := range el.expressions {
41 | newExps = append(newExps, exp.Clone())
42 | }
43 | return expressionList{operator: el.operator, expressions: newExps}
44 | }
45 |
46 | func (el expressionList) Expression() Expression {
47 | return el
48 | }
49 |
50 | func (el expressionList) IsEmpty() bool {
51 | return len(el.expressions) == 0
52 | }
53 |
54 | func (el expressionList) Type() ExpressionListType {
55 | return el.operator
56 | }
57 |
58 | func (el expressionList) Expressions() []Expression {
59 | return el.expressions
60 | }
61 |
62 | func (el expressionList) Append(expressions ...Expression) ExpressionList {
63 | exps := make([]Expression, 0, len(el.expressions)+len(expressions))
64 | exps = append(exps, el.expressions...)
65 | exps = append(exps, expressions...)
66 | return NewExpressionList(el.operator, exps...)
67 | }
68 |
--------------------------------------------------------------------------------
/exp/lateral.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type (
4 | lateral struct {
5 | table AppendableExpression
6 | }
7 | )
8 |
9 | // Creates a new SQL lateral expression
10 | //
11 | // L(From("test")) -> LATERAL (SELECT * FROM "tests")
12 | func NewLateralExpression(table AppendableExpression) LateralExpression {
13 | return lateral{table: table}
14 | }
15 |
16 | func (l lateral) Clone() Expression {
17 | return NewLateralExpression(l.table)
18 | }
19 |
20 | func (l lateral) Table() AppendableExpression {
21 | return l.table
22 | }
23 |
24 | func (l lateral) Expression() Expression { return l }
25 | func (l lateral) As(val interface{}) AliasedExpression { return NewAliasExpression(l, val) }
26 |
--------------------------------------------------------------------------------
/exp/lateral_test.go:
--------------------------------------------------------------------------------
1 | package exp_test
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/doug-martin/goqu/v9/exp"
7 | "github.com/stretchr/testify/suite"
8 | )
9 |
10 | type lateralExpressionSuite struct {
11 | suite.Suite
12 | }
13 |
14 | func TestLateralExpressionSuite(t *testing.T) {
15 | suite.Run(t, &lateralExpressionSuite{})
16 | }
17 |
18 | func (les *lateralExpressionSuite) TestClone() {
19 | le := exp.NewLateralExpression(newTestAppendableExpression(`SELECT * FROM "test"`, []interface{}{}))
20 | les.Equal(exp.NewLateralExpression(newTestAppendableExpression(`SELECT * FROM "test"`, []interface{}{})), le.Clone())
21 | }
22 |
23 | func (les *lateralExpressionSuite) TestExpression() {
24 | le := exp.NewLateralExpression(newTestAppendableExpression(`SELECT * FROM "test"`, []interface{}{}))
25 | les.Equal(le, le.Expression())
26 | }
27 |
28 | func (les *lateralExpressionSuite) TestLateral() {
29 | le := exp.NewLateralExpression(newTestAppendableExpression(`SELECT * FROM "test"`, []interface{}{}))
30 | les.Equal(newTestAppendableExpression(`SELECT * FROM "test"`, []interface{}{}), le.Table())
31 | }
32 |
33 | func (les *lateralExpressionSuite) TestAs() {
34 | le := exp.NewLateralExpression(newTestAppendableExpression(`SELECT * FROM "test"`, []interface{}{}))
35 | les.Equal(exp.NewAliasExpression(le, "foo"), le.As("foo"))
36 | }
37 |
--------------------------------------------------------------------------------
/exp/lock.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type (
4 | LockStrength int
5 | WaitOption int
6 | Lock interface {
7 | Strength() LockStrength
8 | WaitOption() WaitOption
9 | Of() []IdentifierExpression
10 | }
11 | lock struct {
12 | strength LockStrength
13 | waitOption WaitOption
14 | of []IdentifierExpression
15 | }
16 | )
17 |
18 | const (
19 | ForNolock LockStrength = iota
20 | ForUpdate
21 | ForNoKeyUpdate
22 | ForShare
23 | ForKeyShare
24 |
25 | Wait WaitOption = iota
26 | NoWait
27 | SkipLocked
28 | )
29 |
30 | func NewLock(strength LockStrength, option WaitOption, of ...IdentifierExpression) Lock {
31 | return lock{
32 | strength: strength,
33 | waitOption: option,
34 | of: of,
35 | }
36 | }
37 |
38 | func (l lock) Strength() LockStrength {
39 | return l.strength
40 | }
41 |
42 | func (l lock) WaitOption() WaitOption {
43 | return l.waitOption
44 | }
45 |
46 | func (l lock) Of() []IdentifierExpression {
47 | return l.of
48 | }
49 |
--------------------------------------------------------------------------------
/exp/order.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type (
4 | orderedExpression struct {
5 | sortExpression Expression
6 | direction SortDirection
7 | nullSortType NullSortType
8 | }
9 | )
10 |
11 | // used internally to create a new SORT_ASC OrderedExpression
12 | func asc(exp Expression) OrderedExpression {
13 | return NewOrderedExpression(exp, AscDir, NoNullsSortType)
14 | }
15 |
16 | // used internally to create a new SORT_DESC OrderedExpression
17 | func desc(exp Expression) OrderedExpression {
18 | return NewOrderedExpression(exp, DescSortDir, NoNullsSortType)
19 | }
20 |
21 | // used internally to create a new SORT_ASC OrderedExpression
22 | func NewOrderedExpression(exp Expression, direction SortDirection, sortType NullSortType) OrderedExpression {
23 | return orderedExpression{sortExpression: exp, direction: direction, nullSortType: sortType}
24 | }
25 |
26 | func (oe orderedExpression) Clone() Expression {
27 | return NewOrderedExpression(oe.sortExpression, oe.direction, oe.nullSortType)
28 | }
29 |
30 | func (oe orderedExpression) Expression() Expression {
31 | return oe
32 | }
33 |
34 | func (oe orderedExpression) SortExpression() Expression {
35 | return oe.sortExpression
36 | }
37 |
38 | func (oe orderedExpression) IsAsc() bool {
39 | return oe.direction == AscDir
40 | }
41 |
42 | func (oe orderedExpression) NullSortType() NullSortType {
43 | return oe.nullSortType
44 | }
45 |
46 | func (oe orderedExpression) NullsFirst() OrderedExpression {
47 | return NewOrderedExpression(oe.sortExpression, oe.direction, NullsFirstSortType)
48 | }
49 |
50 | func (oe orderedExpression) NullsLast() OrderedExpression {
51 | return NewOrderedExpression(oe.sortExpression, oe.direction, NullsLastSortType)
52 | }
53 |
--------------------------------------------------------------------------------
/exp/range.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type (
4 | ranged struct {
5 | lhs Expression
6 | rhs RangeVal
7 | op RangeOperation
8 | }
9 | rangeVal struct {
10 | start interface{}
11 | end interface{}
12 | }
13 | )
14 |
15 | // used internally to create an BETWEEN comparison RangeExpression
16 | func between(lhs Expression, rhs RangeVal) RangeExpression {
17 | return NewRangeExpression(BetweenOp, lhs, rhs)
18 | }
19 |
20 | // used internally to create an NOT BETWEEN comparison RangeExpression
21 | func notBetween(lhs Expression, rhs RangeVal) RangeExpression {
22 | return NewRangeExpression(NotBetweenOp, lhs, rhs)
23 | }
24 |
25 | func NewRangeExpression(op RangeOperation, lhs Expression, rhs RangeVal) RangeExpression {
26 | return ranged{op: op, lhs: lhs, rhs: rhs}
27 | }
28 |
29 | func (r ranged) Clone() Expression {
30 | return NewRangeExpression(r.op, r.lhs.Clone(), r.rhs)
31 | }
32 |
33 | func (r ranged) Expression() Expression {
34 | return r
35 | }
36 |
37 | func (r ranged) RHS() RangeVal {
38 | return r.rhs
39 | }
40 |
41 | func (r ranged) LHS() Expression {
42 | return r.lhs
43 | }
44 |
45 | func (r ranged) Op() RangeOperation {
46 | return r.op
47 | }
48 |
49 | // Creates a new Range to be used with a Between expression
50 | //
51 | // exp.C("col").Between(exp.Range(1, 10))
52 | func NewRangeVal(start, end interface{}) RangeVal {
53 | return rangeVal{start: start, end: end}
54 | }
55 |
56 | func (rv rangeVal) Start() interface{} {
57 | return rv.start
58 | }
59 |
60 | func (rv rangeVal) End() interface{} {
61 | return rv.end
62 | }
63 |
--------------------------------------------------------------------------------
/exp/record.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | import (
4 | "reflect"
5 | "sort"
6 |
7 | "github.com/doug-martin/goqu/v9/internal/util"
8 | )
9 |
10 | // Alternative to writing map[string]interface{}. Can be used for Inserts, Updates or Deletes
11 | type Record map[string]interface{}
12 |
13 | func (r Record) Cols() []string {
14 | cols := make([]string, 0, len(r))
15 | for col := range r {
16 | cols = append(cols, col)
17 | }
18 | sort.Strings(cols)
19 | return cols
20 | }
21 |
22 | func NewRecordFromStruct(i interface{}, forInsert, forUpdate bool) (r Record, err error) {
23 | value := reflect.ValueOf(i)
24 | if value.IsValid() {
25 | cm, err := util.GetColumnMap(value.Interface())
26 | if err != nil {
27 | return nil, err
28 | }
29 | cols := cm.Cols()
30 | r = make(map[string]interface{}, len(cols))
31 | for _, col := range cols {
32 | f := cm[col]
33 | if !shouldSkipField(f, forInsert, forUpdate) {
34 | if fieldValue, isAvailable := util.SafeGetFieldByIndex(value, f.FieldIndex); isAvailable {
35 | if !shouldOmitField(fieldValue, f) {
36 | r[f.ColumnName] = getRecordValue(fieldValue, f)
37 | }
38 | }
39 | }
40 | }
41 | }
42 | return
43 | }
44 |
45 | func shouldSkipField(f util.ColumnData, forInsert, forUpdate bool) bool {
46 | shouldSkipInsert := forInsert && !f.ShouldInsert
47 | shouldSkipUpdate := forUpdate && !f.ShouldUpdate
48 | return shouldSkipInsert || shouldSkipUpdate
49 | }
50 |
51 | func shouldOmitField(val reflect.Value, f util.ColumnData) bool {
52 | if f.OmitNil && util.IsNil(val) {
53 | return true
54 | } else if f.OmitEmpty && util.IsEmptyValue(val) {
55 | return true
56 | }
57 | return false
58 | }
59 |
60 | func getRecordValue(val reflect.Value, f util.ColumnData) interface{} {
61 | if f.DefaultIfEmpty && util.IsEmptyValue(val) {
62 | return Default()
63 | } else if val.IsValid() {
64 | return val.Interface()
65 | } else {
66 | return reflect.Zero(f.GoType).Interface()
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/exp/truncate.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | // Options to use when generating a TRUNCATE statement
4 | type TruncateOptions struct {
5 | // Set to true to add CASCADE to the TRUNCATE statement
6 | Cascade bool
7 | // Set to true to add RESTRICT to the TRUNCATE statement
8 | Restrict bool
9 | // Set to true to specify IDENTITY options, (e.g. RESTART, CONTINUE) to the TRUNCATE statement
10 | Identity string
11 | }
12 |
--------------------------------------------------------------------------------
/exp/truncate_clauses.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | type (
4 | TruncateClauses interface {
5 | HasTable() bool
6 | clone() *truncateClauses
7 |
8 | Table() ColumnListExpression
9 | SetTable(tables ColumnListExpression) TruncateClauses
10 |
11 | Options() TruncateOptions
12 | SetOptions(opts TruncateOptions) TruncateClauses
13 | }
14 | truncateClauses struct {
15 | tables ColumnListExpression
16 | options TruncateOptions
17 | }
18 | )
19 |
20 | func NewTruncateClauses() TruncateClauses {
21 | return &truncateClauses{}
22 | }
23 |
24 | func (tc *truncateClauses) HasTable() bool {
25 | return tc.tables != nil
26 | }
27 |
28 | func (tc *truncateClauses) clone() *truncateClauses {
29 | return &truncateClauses{
30 | tables: tc.tables,
31 | }
32 | }
33 |
34 | func (tc *truncateClauses) Table() ColumnListExpression {
35 | return tc.tables
36 | }
37 | func (tc *truncateClauses) SetTable(tables ColumnListExpression) TruncateClauses {
38 | ret := tc.clone()
39 | ret.tables = tables
40 | return ret
41 | }
42 |
43 | func (tc *truncateClauses) Options() TruncateOptions {
44 | return tc.options
45 | }
46 | func (tc *truncateClauses) SetOptions(opts TruncateOptions) TruncateClauses {
47 | ret := tc.clone()
48 | ret.options = opts
49 | return ret
50 | }
51 |
--------------------------------------------------------------------------------
/exp/truncate_clauses_test.go:
--------------------------------------------------------------------------------
1 | package exp_test
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/doug-martin/goqu/v9/exp"
7 | "github.com/stretchr/testify/suite"
8 | )
9 |
10 | type truncateClausesSuite struct {
11 | suite.Suite
12 | }
13 |
14 | func TestTruncateClausesSuite(t *testing.T) {
15 | suite.Run(t, new(truncateClausesSuite))
16 | }
17 |
18 | func (tcs *truncateClausesSuite) TestHasTable() {
19 | c := exp.NewTruncateClauses()
20 | cle := exp.NewColumnListExpression("test1", "test2")
21 | c2 := c.SetTable(cle)
22 |
23 | tcs.False(c.HasTable())
24 |
25 | tcs.True(c2.HasTable())
26 | }
27 |
28 | func (tcs *truncateClausesSuite) TestTable() {
29 | c := exp.NewTruncateClauses()
30 | cle := exp.NewColumnListExpression("test1", "test2")
31 | c2 := c.SetTable(cle)
32 |
33 | tcs.Nil(c.Table())
34 |
35 | tcs.Equal(cle, c2.Table())
36 | }
37 |
38 | func (tcs *truncateClausesSuite) TestSetTable() {
39 | cle := exp.NewColumnListExpression("test1", "test2")
40 | c := exp.NewTruncateClauses().SetTable(cle)
41 | cle2 := exp.NewColumnListExpression("test3", "test4")
42 | c2 := c.SetTable(cle2)
43 |
44 | tcs.Equal(cle, c.Table())
45 |
46 | tcs.Equal(cle2, c2.Table())
47 | }
48 |
49 | func (tcs *truncateClausesSuite) TestOptions() {
50 | c := exp.NewTruncateClauses()
51 | opts := exp.TruncateOptions{Restrict: true, Identity: "RESTART", Cascade: true}
52 | c2 := c.SetOptions(opts)
53 |
54 | tcs.Equal(exp.TruncateOptions{}, c.Options())
55 |
56 | tcs.Equal(opts, c2.Options())
57 | }
58 |
59 | func (tcs *truncateClausesSuite) TestSetOptions() {
60 | opts := exp.TruncateOptions{Restrict: true, Identity: "RESTART", Cascade: true}
61 | c := exp.NewTruncateClauses().SetOptions(opts)
62 | opts2 := exp.TruncateOptions{Restrict: false, Identity: "RESTART", Cascade: false}
63 | c2 := c.SetOptions(opts2)
64 |
65 | tcs.Equal(opts, c.Options())
66 |
67 | tcs.Equal(opts2, c2.Options())
68 | }
69 |
--------------------------------------------------------------------------------
/exp/update.go:
--------------------------------------------------------------------------------
1 | package exp
2 |
3 | import (
4 | "reflect"
5 | "sort"
6 |
7 | "github.com/doug-martin/goqu/v9/internal/errors"
8 | "github.com/doug-martin/goqu/v9/internal/util"
9 | )
10 |
11 | type (
12 | update struct {
13 | col IdentifierExpression
14 | val interface{}
15 | }
16 | )
17 |
18 | func set(col IdentifierExpression, val interface{}) UpdateExpression {
19 | return update{col: col, val: val}
20 | }
21 |
22 | func NewUpdateExpressions(update interface{}) (updates []UpdateExpression, err error) {
23 | if us, ok := update.([]UpdateExpression); ok {
24 | updates = append(updates, us...)
25 | return updates, nil
26 | }
27 | if u, ok := update.(UpdateExpression); ok {
28 | updates = append(updates, u)
29 | return updates, nil
30 | }
31 | updateValue := reflect.Indirect(reflect.ValueOf(update))
32 | switch updateValue.Kind() {
33 | case reflect.Map:
34 | keys := util.ValueSlice(updateValue.MapKeys())
35 | sort.Sort(keys)
36 | for _, key := range keys {
37 | updates = append(updates, ParseIdentifier(key.String()).Set(updateValue.MapIndex(key).Interface()))
38 | }
39 | case reflect.Struct:
40 | return getUpdateExpressionsStruct(updateValue)
41 | default:
42 | return nil, errors.New("unsupported update interface type %+v", updateValue.Type())
43 | }
44 | return updates, nil
45 | }
46 |
47 | func getUpdateExpressionsStruct(value reflect.Value) (updates []UpdateExpression, err error) {
48 | r, err := NewRecordFromStruct(value.Interface(), false, true)
49 | if err != nil {
50 | return updates, err
51 | }
52 | cols := r.Cols()
53 | for _, col := range cols {
54 | updates = append(updates, ParseIdentifier(col).Set(r[col]))
55 | }
56 | return updates, nil
57 | }
58 |
59 | func (u update) Expression() Expression {
60 | return u
61 | }
62 |
63 | func (u update) Clone() Expression {
64 | return update{col: u.col.Clone().(IdentifierExpression), val: u.val}
65 | }
66 |
67 | func (u update) Col() IdentifierExpression {
68 | return u.col
69 | }
70 |
71 | func (u update) Val() interface{} {
72 | return u.val
73 | }
74 |
--------------------------------------------------------------------------------
/go.coverage.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | echo "" > coverage.txt
5 |
6 | go test -coverprofile=coverage.txt -coverpkg=./... ./...
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/doug-martin/goqu/v9
2 |
3 | go 1.19
4 |
5 | require (
6 | github.com/DATA-DOG/go-sqlmock v1.5.0
7 | github.com/denisenkom/go-mssqldb v0.12.3
8 | github.com/go-sql-driver/mysql v1.7.1
9 | github.com/lib/pq v1.10.9
10 | github.com/mattn/go-sqlite3 v1.14.17
11 | github.com/stretchr/testify v1.8.4
12 | )
13 |
14 | require (
15 | github.com/davecgh/go-spew v1.1.1 // indirect
16 | github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
17 | github.com/golang-sql/sqlexp v0.1.0 // indirect
18 | github.com/pmezard/go-difflib v1.0.0 // indirect
19 | github.com/stretchr/objx v0.5.0 // indirect
20 | golang.org/x/crypto v0.11.0 // indirect
21 | gopkg.in/yaml.v3 v3.0.1 // indirect
22 | )
23 |
--------------------------------------------------------------------------------
/go.test.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -e
4 | echo "" > coverage.txt
5 |
6 | go test -v -race ./...
--------------------------------------------------------------------------------
/goqu_test.go:
--------------------------------------------------------------------------------
1 | package goqu_test
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/DATA-DOG/go-sqlmock"
7 | "github.com/doug-martin/goqu/v9"
8 | "github.com/stretchr/testify/suite"
9 | )
10 |
11 | type (
12 | dialectWrapperSuite struct {
13 | suite.Suite
14 | }
15 | )
16 |
17 | func (dws *dialectWrapperSuite) SetupSuite() {
18 | testDialect := goqu.DefaultDialectOptions()
19 | // override to some value to ensure correct dialect is set
20 | goqu.RegisterDialect("test", testDialect)
21 | }
22 |
23 | func (dws *dialectWrapperSuite) TearDownSuite() {
24 | goqu.DeregisterDialect("test")
25 | }
26 |
27 | func (dws *dialectWrapperSuite) TestFrom() {
28 | dw := goqu.Dialect("test")
29 | dws.Equal(goqu.From("table").WithDialect("test"), dw.From("table"))
30 | }
31 |
32 | func (dws *dialectWrapperSuite) TestSelect() {
33 | dw := goqu.Dialect("test")
34 | dws.Equal(goqu.Select("col").WithDialect("test"), dw.Select("col"))
35 | }
36 |
37 | func (dws *dialectWrapperSuite) TestInsert() {
38 | dw := goqu.Dialect("test")
39 | dws.Equal(goqu.Insert("table").WithDialect("test"), dw.Insert("table"))
40 | }
41 |
42 | func (dws *dialectWrapperSuite) TestDelete() {
43 | dw := goqu.Dialect("test")
44 | dws.Equal(goqu.Delete("table").WithDialect("test"), dw.Delete("table"))
45 | }
46 |
47 | func (dws *dialectWrapperSuite) TestTruncate() {
48 | dw := goqu.Dialect("test")
49 | dws.Equal(goqu.Truncate("table").WithDialect("test"), dw.Truncate("table"))
50 | }
51 |
52 | func (dws *dialectWrapperSuite) TestDB() {
53 | mDB, _, err := sqlmock.New()
54 | dws.Require().NoError(err)
55 | dw := goqu.Dialect("test")
56 | dws.Equal(goqu.New("test", mDB), dw.DB(mDB))
57 | }
58 |
59 | func TestDialectWrapper(t *testing.T) {
60 | suite.Run(t, new(dialectWrapperSuite))
61 | }
62 |
--------------------------------------------------------------------------------
/internal/errors/error.go:
--------------------------------------------------------------------------------
1 | package errors
2 |
3 | import "fmt"
4 |
5 | type Error struct {
6 | err string
7 | }
8 |
9 | func New(message string, args ...interface{}) error {
10 | return Error{err: "goqu: " + fmt.Sprintf(message, args...)}
11 | }
12 |
13 | func NewEncodeError(t interface{}) error {
14 | return Error{err: "goqu_encode_error: " + fmt.Sprintf("Unable to encode value %+v", t)}
15 | }
16 |
17 | func (e Error) Error() string {
18 | return e.err
19 | }
20 |
--------------------------------------------------------------------------------
/internal/tag/tags.go:
--------------------------------------------------------------------------------
1 | package tag
2 |
3 | import (
4 | "reflect"
5 | "strings"
6 | )
7 |
8 | // tagOptions is the string following a comma in a struct field's "json"
9 | // tag, or the empty string. It does not include the leading comma.
10 | type Options string
11 |
12 | func New(tagName string, st reflect.StructTag) Options {
13 | return Options(st.Get(tagName))
14 | }
15 |
16 | func (o Options) Values() []string {
17 | if string(o) == "" {
18 | return []string{}
19 | }
20 | return strings.Split(string(o), ",")
21 | }
22 |
23 | // Contains reports whether a comma-separated list of options
24 | // contains a particular substr flag. substr must be surrounded by a
25 | // string boundary or commas.
26 | func (o Options) Contains(optionName string) bool {
27 | if o.IsEmpty() {
28 | return false
29 | }
30 | values := o.Values()
31 | for _, s := range values {
32 | if s == optionName {
33 | return true
34 | }
35 | }
36 | return false
37 | }
38 |
39 | // Contains reports whether a comma-separated list of options
40 | // contains a particular substr flag. substr must be surrounded by a
41 | // string boundary or commas.
42 | func (o Options) Equals(val string) bool {
43 | if len(o) == 0 {
44 | return false
45 | }
46 | return string(o) == val
47 | }
48 |
49 | func (o Options) IsEmpty() bool {
50 | return len(o) == 0
51 | }
52 |
--------------------------------------------------------------------------------
/internal/util/value_slice.go:
--------------------------------------------------------------------------------
1 | package util
2 |
3 | import (
4 | "fmt"
5 | "reflect"
6 | "sort"
7 | "strings"
8 | )
9 |
10 | type ValueSlice []reflect.Value
11 |
12 | func (vs ValueSlice) Len() int { return len(vs) }
13 | func (vs ValueSlice) Less(i, j int) bool { return vs[i].String() < vs[j].String() }
14 | func (vs ValueSlice) Swap(i, j int) { vs[i], vs[j] = vs[j], vs[i] }
15 |
16 | func (vs ValueSlice) Equal(other ValueSlice) bool {
17 | sort.Sort(other)
18 | for i, key := range vs {
19 | if other[i].String() != key.String() {
20 | return false
21 | }
22 | }
23 | return true
24 | }
25 |
26 | func (vs ValueSlice) String() string {
27 | vals := make([]string, vs.Len())
28 | for i, key := range vs {
29 | vals[i] = fmt.Sprintf("%q", key.String())
30 | }
31 | sort.Strings(vals)
32 | return fmt.Sprintf("[%s]", strings.Join(vals, ","))
33 | }
34 |
--------------------------------------------------------------------------------
/mocks/SQLDialect.go:
--------------------------------------------------------------------------------
1 | // Code generated by mockery v1.0.0. DO NOT EDIT.
2 |
3 | package mocks
4 |
5 | import exp "github.com/doug-martin/goqu/v9/exp"
6 |
7 | import mock "github.com/stretchr/testify/mock"
8 | import sb "github.com/doug-martin/goqu/v9/internal/sb"
9 |
10 | // SQLDialect is an autogenerated mock type for the SQLDialect type
11 | type SQLDialect struct {
12 | mock.Mock
13 | }
14 |
15 | // Dialect provides a mock function with given fields:
16 | func (_m *SQLDialect) Dialect() string {
17 | ret := _m.Called()
18 |
19 | var r0 string
20 | if rf, ok := ret.Get(0).(func() string); ok {
21 | r0 = rf()
22 | } else {
23 | r0 = ret.Get(0).(string)
24 | }
25 |
26 | return r0
27 | }
28 |
29 | // ToDeleteSQL provides a mock function with given fields: b, clauses
30 | func (_m *SQLDialect) ToDeleteSQL(b sb.SQLBuilder, clauses exp.DeleteClauses) {
31 | _m.Called(b, clauses)
32 | }
33 |
34 | // ToInsertSQL provides a mock function with given fields: b, clauses
35 | func (_m *SQLDialect) ToInsertSQL(b sb.SQLBuilder, clauses exp.InsertClauses) {
36 | _m.Called(b, clauses)
37 | }
38 |
39 | // ToSelectSQL provides a mock function with given fields: b, clauses
40 | func (_m *SQLDialect) ToSelectSQL(b sb.SQLBuilder, clauses exp.SelectClauses) {
41 | _m.Called(b, clauses)
42 | }
43 |
44 | // ToTruncateSQL provides a mock function with given fields: b, clauses
45 | func (_m *SQLDialect) ToTruncateSQL(b sb.SQLBuilder, clauses exp.TruncateClauses) {
46 | _m.Called(b, clauses)
47 | }
48 |
49 | // ToUpdateSQL provides a mock function with given fields: b, clauses
50 | func (_m *SQLDialect) ToUpdateSQL(b sb.SQLBuilder, clauses exp.UpdateClauses) {
51 | _m.Called(b, clauses)
52 | }
53 |
--------------------------------------------------------------------------------
/prepared.go:
--------------------------------------------------------------------------------
1 | package goqu
2 |
3 | var (
4 | // defaultPrepared is controlled by SetDefaultPrepared
5 | defaultPrepared bool
6 | )
7 |
8 | type prepared int
9 |
10 | const (
11 | // zero value that defers to defaultPrepared
12 | preparedNoPreference prepared = iota
13 |
14 | // explicitly enabled via Prepared(true) on a dataset
15 | preparedEnabled
16 |
17 | // explicitly disabled via Prepared(false) on a dataset
18 | preparedDisabled
19 | )
20 |
21 | // Bool converts the ternary prepared state into a boolean. If the prepared
22 | // state is preparedNoPreference, the value depends on the last value that
23 | // SetDefaultPrepared was called with which is false by default.
24 | func (p prepared) Bool() bool {
25 | if p == preparedNoPreference {
26 | return defaultPrepared
27 | } else if p == preparedEnabled {
28 | return true
29 | }
30 |
31 | return false
32 | }
33 |
34 | // preparedFromBool converts a bool from e.g. Prepared(true) into a prepared
35 | // const.
36 | func preparedFromBool(prepared bool) prepared {
37 | if prepared {
38 | return preparedEnabled
39 | }
40 |
41 | return preparedDisabled
42 | }
43 |
44 | // SetDefaultPrepared controls the default Prepared state of all datasets. If
45 | // set to true, any new dataset will use prepared queries by default.
46 | func SetDefaultPrepared(prepared bool) {
47 | defaultPrepared = prepared
48 | }
49 |
--------------------------------------------------------------------------------
/sql_dialect_example_test.go:
--------------------------------------------------------------------------------
1 | package goqu_test
2 |
3 | import (
4 | "fmt"
5 |
6 | "github.com/doug-martin/goqu/v9"
7 | )
8 |
9 | func ExampleRegisterDialect() {
10 | opts := goqu.DefaultDialectOptions()
11 | opts.QuoteRune = '`'
12 | goqu.RegisterDialect("custom-dialect", opts)
13 |
14 | dialect := goqu.Dialect("custom-dialect")
15 |
16 | ds := dialect.From("test")
17 |
18 | sql, args, _ := ds.ToSQL()
19 | fmt.Println(sql, args)
20 |
21 | // Output:
22 | // SELECT * FROM `test` []
23 | }
24 |
--------------------------------------------------------------------------------
/sqlgen/base_test.go:
--------------------------------------------------------------------------------
1 | package sqlgen_test
2 |
3 | import (
4 | "github.com/doug-martin/goqu/v9/internal/sb"
5 | "github.com/stretchr/testify/suite"
6 | )
7 |
8 | type baseSQLGeneratorSuite struct {
9 | suite.Suite
10 | }
11 |
12 | func (bsgs *baseSQLGeneratorSuite) assertNotPreparedSQL(b sb.SQLBuilder, expectedSQL string) {
13 | actualSQL, actualArgs, err := b.ToSQL()
14 | bsgs.NoError(err)
15 | bsgs.Equal(expectedSQL, actualSQL)
16 | bsgs.Empty(actualArgs)
17 | }
18 |
19 | func (bsgs *baseSQLGeneratorSuite) assertPreparedSQL(
20 | b sb.SQLBuilder,
21 | expectedSQL string,
22 | expectedArgs []interface{},
23 | ) {
24 | actualSQL, actualArgs, err := b.ToSQL()
25 | bsgs.NoError(err)
26 | bsgs.Equal(expectedSQL, actualSQL)
27 | if len(actualArgs) == 0 {
28 | bsgs.Empty(expectedArgs)
29 | } else {
30 | bsgs.Equal(expectedArgs, actualArgs)
31 | }
32 | }
33 |
34 | func (bsgs *baseSQLGeneratorSuite) assertErrorSQL(b sb.SQLBuilder, errMsg string) {
35 | actualSQL, actualArgs, err := b.ToSQL()
36 | bsgs.EqualError(err, errMsg)
37 | bsgs.Empty(actualSQL)
38 | bsgs.Empty(actualArgs)
39 | }
40 |
--------------------------------------------------------------------------------
/sqlgen/mocks/DeleteSQLGenerator.go:
--------------------------------------------------------------------------------
1 | // Code generated by mockery v1.0.0. DO NOT EDIT.
2 |
3 | package mocks
4 |
5 | import exp "github.com/doug-martin/goqu/v9/exp"
6 | import mock "github.com/stretchr/testify/mock"
7 | import sb "github.com/doug-martin/goqu/v9/internal/sb"
8 |
9 | // DeleteSQLGenerator is an autogenerated mock type for the DeleteSQLGenerator type
10 | type DeleteSQLGenerator struct {
11 | mock.Mock
12 | }
13 |
14 | // Dialect provides a mock function with given fields:
15 | func (_m *DeleteSQLGenerator) Dialect() string {
16 | ret := _m.Called()
17 |
18 | var r0 string
19 | if rf, ok := ret.Get(0).(func() string); ok {
20 | r0 = rf()
21 | } else {
22 | r0 = ret.Get(0).(string)
23 | }
24 |
25 | return r0
26 | }
27 |
28 | // Generate provides a mock function with given fields: b, clauses
29 | func (_m *DeleteSQLGenerator) Generate(b sb.SQLBuilder, clauses exp.DeleteClauses) {
30 | _m.Called(b, clauses)
31 | }
32 |
--------------------------------------------------------------------------------
/sqlgen/mocks/InsertSQLGenerator.go:
--------------------------------------------------------------------------------
1 | // Code generated by mockery v1.0.0. DO NOT EDIT.
2 |
3 | package mocks
4 |
5 | import exp "github.com/doug-martin/goqu/v9/exp"
6 | import mock "github.com/stretchr/testify/mock"
7 | import sb "github.com/doug-martin/goqu/v9/internal/sb"
8 |
9 | // InsertSQLGenerator is an autogenerated mock type for the InsertSQLGenerator type
10 | type InsertSQLGenerator struct {
11 | mock.Mock
12 | }
13 |
14 | // Dialect provides a mock function with given fields:
15 | func (_m *InsertSQLGenerator) Dialect() string {
16 | ret := _m.Called()
17 |
18 | var r0 string
19 | if rf, ok := ret.Get(0).(func() string); ok {
20 | r0 = rf()
21 | } else {
22 | r0 = ret.Get(0).(string)
23 | }
24 |
25 | return r0
26 | }
27 |
28 | // Generate provides a mock function with given fields: b, clauses
29 | func (_m *InsertSQLGenerator) Generate(b sb.SQLBuilder, clauses exp.InsertClauses) {
30 | _m.Called(b, clauses)
31 | }
32 |
--------------------------------------------------------------------------------
/sqlgen/mocks/SelectSQLGenerator.go:
--------------------------------------------------------------------------------
1 | // Code generated by mockery v1.0.0. DO NOT EDIT.
2 |
3 | package mocks
4 |
5 | import exp "github.com/doug-martin/goqu/v9/exp"
6 | import mock "github.com/stretchr/testify/mock"
7 | import sb "github.com/doug-martin/goqu/v9/internal/sb"
8 |
9 | // SelectSQLGenerator is an autogenerated mock type for the SelectSQLGenerator type
10 | type SelectSQLGenerator struct {
11 | mock.Mock
12 | }
13 |
14 | // Dialect provides a mock function with given fields:
15 | func (_m *SelectSQLGenerator) Dialect() string {
16 | ret := _m.Called()
17 |
18 | var r0 string
19 | if rf, ok := ret.Get(0).(func() string); ok {
20 | r0 = rf()
21 | } else {
22 | r0 = ret.Get(0).(string)
23 | }
24 |
25 | return r0
26 | }
27 |
28 | // Generate provides a mock function with given fields: b, clauses
29 | func (_m *SelectSQLGenerator) Generate(b sb.SQLBuilder, clauses exp.SelectClauses) {
30 | _m.Called(b, clauses)
31 | }
32 |
--------------------------------------------------------------------------------
/sqlgen/mocks/TruncateSQLGenerator.go:
--------------------------------------------------------------------------------
1 | // Code generated by mockery v1.0.0. DO NOT EDIT.
2 |
3 | package mocks
4 |
5 | import exp "github.com/doug-martin/goqu/v9/exp"
6 | import mock "github.com/stretchr/testify/mock"
7 | import sb "github.com/doug-martin/goqu/v9/internal/sb"
8 |
9 | // TruncateSQLGenerator is an autogenerated mock type for the TruncateSQLGenerator type
10 | type TruncateSQLGenerator struct {
11 | mock.Mock
12 | }
13 |
14 | // Dialect provides a mock function with given fields:
15 | func (_m *TruncateSQLGenerator) Dialect() string {
16 | ret := _m.Called()
17 |
18 | var r0 string
19 | if rf, ok := ret.Get(0).(func() string); ok {
20 | r0 = rf()
21 | } else {
22 | r0 = ret.Get(0).(string)
23 | }
24 |
25 | return r0
26 | }
27 |
28 | // Generate provides a mock function with given fields: b, clauses
29 | func (_m *TruncateSQLGenerator) Generate(b sb.SQLBuilder, clauses exp.TruncateClauses) {
30 | _m.Called(b, clauses)
31 | }
32 |
--------------------------------------------------------------------------------
/sqlgen/mocks/UpdateSQLGenerator.go:
--------------------------------------------------------------------------------
1 | // Code generated by mockery v1.0.0. DO NOT EDIT.
2 |
3 | package mocks
4 |
5 | import exp "github.com/doug-martin/goqu/v9/exp"
6 | import mock "github.com/stretchr/testify/mock"
7 | import sb "github.com/doug-martin/goqu/v9/internal/sb"
8 |
9 | // UpdateSQLGenerator is an autogenerated mock type for the UpdateSQLGenerator type
10 | type UpdateSQLGenerator struct {
11 | mock.Mock
12 | }
13 |
14 | // Dialect provides a mock function with given fields:
15 | func (_m *UpdateSQLGenerator) Dialect() string {
16 | ret := _m.Called()
17 |
18 | var r0 string
19 | if rf, ok := ret.Get(0).(func() string); ok {
20 | r0 = rf()
21 | } else {
22 | r0 = ret.Get(0).(string)
23 | }
24 |
25 | return r0
26 | }
27 |
28 | // Generate provides a mock function with given fields: b, clauses
29 | func (_m *UpdateSQLGenerator) Generate(b sb.SQLBuilder, clauses exp.UpdateClauses) {
30 | _m.Called(b, clauses)
31 | }
32 |
--------------------------------------------------------------------------------
/sqlgen/sql_dialect_options_test.go:
--------------------------------------------------------------------------------
1 | package sqlgen_test
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/doug-martin/goqu/v9/sqlgen"
7 | "github.com/stretchr/testify/suite"
8 | )
9 |
10 | type sqlFragmentTypeSuite struct {
11 | suite.Suite
12 | }
13 |
14 | func (sfts *sqlFragmentTypeSuite) TestOptions_SQLFragmentType() {
15 | for _, tt := range []struct {
16 | typ sqlgen.SQLFragmentType
17 | expectedStr string
18 | }{
19 | {typ: sqlgen.CommonTableSQLFragment, expectedStr: "CommonTableSQLFragment"},
20 | {typ: sqlgen.SelectSQLFragment, expectedStr: "SelectSQLFragment"},
21 | {typ: sqlgen.FromSQLFragment, expectedStr: "FromSQLFragment"},
22 | {typ: sqlgen.JoinSQLFragment, expectedStr: "JoinSQLFragment"},
23 | {typ: sqlgen.WhereSQLFragment, expectedStr: "WhereSQLFragment"},
24 | {typ: sqlgen.GroupBySQLFragment, expectedStr: "GroupBySQLFragment"},
25 | {typ: sqlgen.HavingSQLFragment, expectedStr: "HavingSQLFragment"},
26 | {typ: sqlgen.CompoundsSQLFragment, expectedStr: "CompoundsSQLFragment"},
27 | {typ: sqlgen.OrderSQLFragment, expectedStr: "OrderSQLFragment"},
28 | {typ: sqlgen.LimitSQLFragment, expectedStr: "LimitSQLFragment"},
29 | {typ: sqlgen.OffsetSQLFragment, expectedStr: "OffsetSQLFragment"},
30 | {typ: sqlgen.ForSQLFragment, expectedStr: "ForSQLFragment"},
31 | {typ: sqlgen.UpdateBeginSQLFragment, expectedStr: "UpdateBeginSQLFragment"},
32 | {typ: sqlgen.SourcesSQLFragment, expectedStr: "SourcesSQLFragment"},
33 | {typ: sqlgen.IntoSQLFragment, expectedStr: "IntoSQLFragment"},
34 | {typ: sqlgen.UpdateSQLFragment, expectedStr: "UpdateSQLFragment"},
35 | {typ: sqlgen.UpdateFromSQLFragment, expectedStr: "UpdateFromSQLFragment"},
36 | {typ: sqlgen.ReturningSQLFragment, expectedStr: "ReturningSQLFragment"},
37 | {typ: sqlgen.InsertBeingSQLFragment, expectedStr: "InsertBeingSQLFragment"},
38 | {typ: sqlgen.DeleteBeginSQLFragment, expectedStr: "DeleteBeginSQLFragment"},
39 | {typ: sqlgen.TruncateSQLFragment, expectedStr: "TruncateSQLFragment"},
40 | {typ: sqlgen.WindowSQLFragment, expectedStr: "WindowSQLFragment"},
41 | {typ: sqlgen.SQLFragmentType(10000), expectedStr: "10000"},
42 | } {
43 | sfts.Equal(tt.expectedStr, tt.typ.String())
44 | }
45 | }
46 |
47 | func TestSQLFragmentType(t *testing.T) {
48 | suite.Run(t, new(sqlFragmentTypeSuite))
49 | }
50 |
--------------------------------------------------------------------------------
/sqlgen/sqlgen.go:
--------------------------------------------------------------------------------
1 | package sqlgen
2 |
3 | import "time"
4 |
5 | var timeLocation = time.UTC
6 |
7 | // Set the location to use when interpolating time.Time instances. See https://golang.org/pkg/time/#LoadLocation
8 | // NOTE: This has no effect when using prepared statements.
9 | func SetTimeLocation(loc *time.Location) {
10 | timeLocation = loc
11 | }
12 |
13 | func GetTimeLocation() *time.Location {
14 | return timeLocation
15 | }
16 |
--------------------------------------------------------------------------------
/sqlgen/truncate_sql_generator.go:
--------------------------------------------------------------------------------
1 | package sqlgen
2 |
3 | import (
4 | "strings"
5 |
6 | "github.com/doug-martin/goqu/v9/exp"
7 | "github.com/doug-martin/goqu/v9/internal/errors"
8 | "github.com/doug-martin/goqu/v9/internal/sb"
9 | )
10 |
11 | type (
12 | // An adapter interface to be used by a Dataset to generate SQL for a specific dialect.
13 | // See DefaultAdapter for a concrete implementation and examples.
14 | TruncateSQLGenerator interface {
15 | Dialect() string
16 | Generate(b sb.SQLBuilder, clauses exp.TruncateClauses)
17 | }
18 | // The default adapter. This class should be used when building a new adapter. When creating a new adapter you can
19 | // either override methods, or more typically update default values.
20 | // See (github.com/doug-martin/goqu/dialect/postgres)
21 | truncateSQLGenerator struct {
22 | CommonSQLGenerator
23 | }
24 | )
25 |
26 | var errNoSourceForTruncate = errors.New("no source found when generating truncate sql")
27 |
28 | func NewTruncateSQLGenerator(dialect string, do *SQLDialectOptions) TruncateSQLGenerator {
29 | return &truncateSQLGenerator{NewCommonSQLGenerator(dialect, do)}
30 | }
31 |
32 | func (tsg *truncateSQLGenerator) Generate(b sb.SQLBuilder, clauses exp.TruncateClauses) {
33 | if !clauses.HasTable() {
34 | b.SetError(errNoSourceForTruncate)
35 | return
36 | }
37 | for _, f := range tsg.DialectOptions().TruncateSQLOrder {
38 | if b.Error() != nil {
39 | return
40 | }
41 | switch f {
42 | case TruncateSQLFragment:
43 | tsg.TruncateSQL(b, clauses.Table(), clauses.Options())
44 | default:
45 | b.SetError(ErrNotSupportedFragment("TRUNCATE", f))
46 | }
47 | }
48 | }
49 |
50 | // Generates a TRUNCATE statement
51 | func (tsg *truncateSQLGenerator) TruncateSQL(b sb.SQLBuilder, from exp.ColumnListExpression, opts exp.TruncateOptions) {
52 | b.Write(tsg.DialectOptions().TruncateClause)
53 | tsg.SourcesSQL(b, from)
54 | if opts.Identity != tsg.DialectOptions().EmptyString {
55 | b.WriteRunes(tsg.DialectOptions().SpaceRune).
56 | WriteStrings(strings.ToUpper(opts.Identity)).
57 | Write(tsg.DialectOptions().IdentityFragment)
58 | }
59 | if opts.Cascade {
60 | b.Write(tsg.DialectOptions().CascadeFragment)
61 | } else if opts.Restrict {
62 | b.Write(tsg.DialectOptions().RestrictFragment)
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/.gitignore:
--------------------------------------------------------------------------------
1 | /examples/blog/blog
2 | /examples/orders/orders
3 | /examples/basic/basic
4 | .idea/
5 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | go_import_path: github.com/DATA-DOG/go-sqlmock
4 |
5 | go:
6 | - 1.2.x
7 | - 1.3.x
8 | - 1.4 # has no cover tool for latest releases
9 | - 1.5.x
10 | - 1.6.x
11 | - 1.7.x
12 | - 1.8.x
13 | - 1.9.x
14 | - 1.10.x
15 | - 1.11.x
16 | - 1.12.x
17 | - 1.13.x
18 | - 1.14.x
19 |
20 | script:
21 | - go vet
22 | - test -z "$(go fmt ./...)" # fail if not formatted properly
23 | - go test -race -coverprofile=coverage.txt -covermode=atomic
24 |
25 | after_success:
26 | - bash <(curl -s https://codecov.io/bash)
27 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/LICENSE:
--------------------------------------------------------------------------------
1 | The three clause BSD license (http://en.wikipedia.org/wiki/BSD_licenses)
2 |
3 | Copyright (c) 2013-2019, DATA-DOG team
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * The name DataDog.lt may not be used to endorse or promote products
17 | derived from this software without specific prior written permission.
18 |
19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 | DISCLAIMED. IN NO EVENT SHALL MICHAEL BOSTOCK BE LIABLE FOR ANY DIRECT,
23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/argument.go:
--------------------------------------------------------------------------------
1 | package sqlmock
2 |
3 | import "database/sql/driver"
4 |
5 | // Argument interface allows to match
6 | // any argument in specific way when used with
7 | // ExpectedQuery and ExpectedExec expectations.
8 | type Argument interface {
9 | Match(driver.Value) bool
10 | }
11 |
12 | // AnyArg will return an Argument which can
13 | // match any kind of arguments.
14 | //
15 | // Useful for time.Time or similar kinds of arguments.
16 | func AnyArg() Argument {
17 | return anyArgument{}
18 | }
19 |
20 | type anyArgument struct{}
21 |
22 | func (a anyArgument) Match(_ driver.Value) bool {
23 | return true
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/column.go:
--------------------------------------------------------------------------------
1 | package sqlmock
2 |
3 | import "reflect"
4 |
5 | // Column is a mocked column Metadata for rows.ColumnTypes()
6 | type Column struct {
7 | name string
8 | dbType string
9 | nullable bool
10 | nullableOk bool
11 | length int64
12 | lengthOk bool
13 | precision int64
14 | scale int64
15 | psOk bool
16 | scanType reflect.Type
17 | }
18 |
19 | func (c *Column) Name() string {
20 | return c.name
21 | }
22 |
23 | func (c *Column) DbType() string {
24 | return c.dbType
25 | }
26 |
27 | func (c *Column) IsNullable() (bool, bool) {
28 | return c.nullable, c.nullableOk
29 | }
30 |
31 | func (c *Column) Length() (int64, bool) {
32 | return c.length, c.lengthOk
33 | }
34 |
35 | func (c *Column) PrecisionScale() (int64, int64, bool) {
36 | return c.precision, c.scale, c.psOk
37 | }
38 |
39 | func (c *Column) ScanType() reflect.Type {
40 | return c.scanType
41 | }
42 |
43 | // NewColumn returns a Column with specified name
44 | func NewColumn(name string) *Column {
45 | return &Column{
46 | name: name,
47 | }
48 | }
49 |
50 | // Nullable returns the column with nullable metadata set
51 | func (c *Column) Nullable(nullable bool) *Column {
52 | c.nullable = nullable
53 | c.nullableOk = true
54 | return c
55 | }
56 |
57 | // OfType returns the column with type metadata set
58 | func (c *Column) OfType(dbType string, sampleValue interface{}) *Column {
59 | c.dbType = dbType
60 | c.scanType = reflect.TypeOf(sampleValue)
61 | return c
62 | }
63 |
64 | // WithLength returns the column with length metadata set.
65 | func (c *Column) WithLength(length int64) *Column {
66 | c.length = length
67 | c.lengthOk = true
68 | return c
69 | }
70 |
71 | // WithPrecisionAndScale returns the column with precision and scale metadata set.
72 | func (c *Column) WithPrecisionAndScale(precision, scale int64) *Column {
73 | c.precision = precision
74 | c.scale = scale
75 | c.psOk = true
76 | return c
77 | }
78 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/driver.go:
--------------------------------------------------------------------------------
1 | package sqlmock
2 |
3 | import (
4 | "database/sql"
5 | "database/sql/driver"
6 | "fmt"
7 | "sync"
8 | )
9 |
10 | var pool *mockDriver
11 |
12 | func init() {
13 | pool = &mockDriver{
14 | conns: make(map[string]*sqlmock),
15 | }
16 | sql.Register("sqlmock", pool)
17 | }
18 |
19 | type mockDriver struct {
20 | sync.Mutex
21 | counter int
22 | conns map[string]*sqlmock
23 | }
24 |
25 | func (d *mockDriver) Open(dsn string) (driver.Conn, error) {
26 | d.Lock()
27 | defer d.Unlock()
28 |
29 | c, ok := d.conns[dsn]
30 | if !ok {
31 | return c, fmt.Errorf("expected a connection to be available, but it is not")
32 | }
33 |
34 | c.opened++
35 | return c, nil
36 | }
37 |
38 | // New creates sqlmock database connection and a mock to manage expectations.
39 | // Accepts options, like ValueConverterOption, to use a ValueConverter from
40 | // a specific driver.
41 | // Pings db so that all expectations could be
42 | // asserted.
43 | func New(options ...func(*sqlmock) error) (*sql.DB, Sqlmock, error) {
44 | pool.Lock()
45 | dsn := fmt.Sprintf("sqlmock_db_%d", pool.counter)
46 | pool.counter++
47 |
48 | smock := &sqlmock{dsn: dsn, drv: pool, ordered: true}
49 | pool.conns[dsn] = smock
50 | pool.Unlock()
51 |
52 | return smock.open(options)
53 | }
54 |
55 | // NewWithDSN creates sqlmock database connection with a specific DSN
56 | // and a mock to manage expectations.
57 | // Accepts options, like ValueConverterOption, to use a ValueConverter from
58 | // a specific driver.
59 | // Pings db so that all expectations could be asserted.
60 | //
61 | // This method is introduced because of sql abstraction
62 | // libraries, which do not provide a way to initialize
63 | // with sql.DB instance. For example GORM library.
64 | //
65 | // Note, it will error if attempted to create with an
66 | // already used dsn
67 | //
68 | // It is not recommended to use this method, unless you
69 | // really need it and there is no other way around.
70 | func NewWithDSN(dsn string, options ...func(*sqlmock) error) (*sql.DB, Sqlmock, error) {
71 | pool.Lock()
72 | if _, ok := pool.conns[dsn]; ok {
73 | pool.Unlock()
74 | return nil, nil, fmt.Errorf("cannot create a new mock database with the same dsn: %s", dsn)
75 | }
76 | smock := &sqlmock{dsn: dsn, drv: pool, ordered: true}
77 | pool.conns[dsn] = smock
78 | pool.Unlock()
79 |
80 | return smock.open(options)
81 | }
82 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/expectations_before_go18.go:
--------------------------------------------------------------------------------
1 | // +build !go1.8
2 |
3 | package sqlmock
4 |
5 | import (
6 | "database/sql/driver"
7 | "fmt"
8 | "reflect"
9 | )
10 |
11 | // WillReturnRows specifies the set of resulting rows that will be returned
12 | // by the triggered query
13 | func (e *ExpectedQuery) WillReturnRows(rows *Rows) *ExpectedQuery {
14 | e.rows = &rowSets{sets: []*Rows{rows}, ex: e}
15 | return e
16 | }
17 |
18 | func (e *queryBasedExpectation) argsMatches(args []namedValue) error {
19 | if nil == e.args {
20 | return nil
21 | }
22 | if len(args) != len(e.args) {
23 | return fmt.Errorf("expected %d, but got %d arguments", len(e.args), len(args))
24 | }
25 | for k, v := range args {
26 | // custom argument matcher
27 | matcher, ok := e.args[k].(Argument)
28 | if ok {
29 | // @TODO: does it make sense to pass value instead of named value?
30 | if !matcher.Match(v.Value) {
31 | return fmt.Errorf("matcher %T could not match %d argument %T - %+v", matcher, k, args[k], args[k])
32 | }
33 | continue
34 | }
35 |
36 | dval := e.args[k]
37 | // convert to driver converter
38 | darg, err := e.converter.ConvertValue(dval)
39 | if err != nil {
40 | return fmt.Errorf("could not convert %d argument %T - %+v to driver value: %s", k, e.args[k], e.args[k], err)
41 | }
42 |
43 | if !driver.IsValue(darg) {
44 | return fmt.Errorf("argument %d: non-subset type %T returned from Value", k, darg)
45 | }
46 |
47 | if !reflect.DeepEqual(darg, v.Value) {
48 | return fmt.Errorf("argument %d expected [%T - %+v] does not match actual [%T - %+v]", k, darg, darg, v.Value, v.Value)
49 | }
50 | }
51 | return nil
52 | }
53 |
54 | func (e *queryBasedExpectation) attemptArgMatch(args []namedValue) (err error) {
55 | // catch panic
56 | defer func() {
57 | if e := recover(); e != nil {
58 | _, ok := e.(error)
59 | if !ok {
60 | err = fmt.Errorf(e.(string))
61 | }
62 | }
63 | }()
64 |
65 | err = e.argsMatches(args)
66 | return
67 | }
68 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/options.go:
--------------------------------------------------------------------------------
1 | package sqlmock
2 |
3 | import "database/sql/driver"
4 |
5 | // ValueConverterOption allows to create a sqlmock connection
6 | // with a custom ValueConverter to support drivers with special data types.
7 | func ValueConverterOption(converter driver.ValueConverter) func(*sqlmock) error {
8 | return func(s *sqlmock) error {
9 | s.converter = converter
10 | return nil
11 | }
12 | }
13 |
14 | // QueryMatcherOption allows to customize SQL query matcher
15 | // and match SQL query strings in more sophisticated ways.
16 | // The default QueryMatcher is QueryMatcherRegexp.
17 | func QueryMatcherOption(queryMatcher QueryMatcher) func(*sqlmock) error {
18 | return func(s *sqlmock) error {
19 | s.queryMatcher = queryMatcher
20 | return nil
21 | }
22 | }
23 |
24 | // MonitorPingsOption determines whether calls to Ping on the driver should be
25 | // observed and mocked.
26 | //
27 | // If true is passed, we will check these calls were expected. Expectations can
28 | // be registered using the ExpectPing() method on the mock.
29 | //
30 | // If false is passed or this option is omitted, calls to Ping will not be
31 | // considered when determining expectations and calls to ExpectPing will have
32 | // no effect.
33 | func MonitorPingsOption(monitorPings bool) func(*sqlmock) error {
34 | return func(s *sqlmock) error {
35 | s.monitorPings = monitorPings
36 | return nil
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/result.go:
--------------------------------------------------------------------------------
1 | package sqlmock
2 |
3 | import (
4 | "database/sql/driver"
5 | )
6 |
7 | // Result satisfies sql driver Result, which
8 | // holds last insert id and rows affected
9 | // by Exec queries
10 | type result struct {
11 | insertID int64
12 | rowsAffected int64
13 | err error
14 | }
15 |
16 | // NewResult creates a new sql driver Result
17 | // for Exec based query mocks.
18 | func NewResult(lastInsertID int64, rowsAffected int64) driver.Result {
19 | return &result{
20 | insertID: lastInsertID,
21 | rowsAffected: rowsAffected,
22 | }
23 | }
24 |
25 | // NewErrorResult creates a new sql driver Result
26 | // which returns an error given for both interface methods
27 | func NewErrorResult(err error) driver.Result {
28 | return &result{
29 | err: err,
30 | }
31 | }
32 |
33 | func (r *result) LastInsertId() (int64, error) {
34 | return r.insertID, r.err
35 | }
36 |
37 | func (r *result) RowsAffected() (int64, error) {
38 | return r.rowsAffected, r.err
39 | }
40 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/rows_go18.go:
--------------------------------------------------------------------------------
1 | // +build go1.8
2 |
3 | package sqlmock
4 |
5 | import (
6 | "database/sql/driver"
7 | "io"
8 | "reflect"
9 | )
10 |
11 | // Implement the "RowsNextResultSet" interface
12 | func (rs *rowSets) HasNextResultSet() bool {
13 | return rs.pos+1 < len(rs.sets)
14 | }
15 |
16 | // Implement the "RowsNextResultSet" interface
17 | func (rs *rowSets) NextResultSet() error {
18 | if !rs.HasNextResultSet() {
19 | return io.EOF
20 | }
21 |
22 | rs.pos++
23 | return nil
24 | }
25 |
26 | // type for rows with columns definition created with sqlmock.NewRowsWithColumnDefinition
27 | type rowSetsWithDefinition struct {
28 | *rowSets
29 | }
30 |
31 | // Implement the "RowsColumnTypeDatabaseTypeName" interface
32 | func (rs *rowSetsWithDefinition) ColumnTypeDatabaseTypeName(index int) string {
33 | return rs.getDefinition(index).DbType()
34 | }
35 |
36 | // Implement the "RowsColumnTypeLength" interface
37 | func (rs *rowSetsWithDefinition) ColumnTypeLength(index int) (length int64, ok bool) {
38 | return rs.getDefinition(index).Length()
39 | }
40 |
41 | // Implement the "RowsColumnTypeNullable" interface
42 | func (rs *rowSetsWithDefinition) ColumnTypeNullable(index int) (nullable, ok bool) {
43 | return rs.getDefinition(index).IsNullable()
44 | }
45 |
46 | // Implement the "RowsColumnTypePrecisionScale" interface
47 | func (rs *rowSetsWithDefinition) ColumnTypePrecisionScale(index int) (precision, scale int64, ok bool) {
48 | return rs.getDefinition(index).PrecisionScale()
49 | }
50 |
51 | // ColumnTypeScanType is defined from driver.RowsColumnTypeScanType
52 | func (rs *rowSetsWithDefinition) ColumnTypeScanType(index int) reflect.Type {
53 | return rs.getDefinition(index).ScanType()
54 | }
55 |
56 | // return column definition from current set metadata
57 | func (rs *rowSetsWithDefinition) getDefinition(index int) *Column {
58 | return rs.sets[rs.pos].def[index]
59 | }
60 |
61 | // NewRowsWithColumnDefinition return rows with columns metadata
62 | func NewRowsWithColumnDefinition(columns ...*Column) *Rows {
63 | cols := make([]string, len(columns))
64 | for i, column := range columns {
65 | cols[i] = column.Name()
66 | }
67 |
68 | return &Rows{
69 | cols: cols,
70 | def: columns,
71 | nextErr: make(map[int]error),
72 | converter: driver.DefaultParameterConverter,
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/sqlmock_go18_19.go:
--------------------------------------------------------------------------------
1 | // +build go1.8,!go1.9
2 |
3 | package sqlmock
4 |
5 | import "database/sql/driver"
6 |
7 | // CheckNamedValue meets https://golang.org/pkg/database/sql/driver/#NamedValueChecker
8 | func (c *sqlmock) CheckNamedValue(nv *driver.NamedValue) (err error) {
9 | nv.Value, err = c.converter.ConvertValue(nv.Value)
10 | return err
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/sqlmock_go19.go:
--------------------------------------------------------------------------------
1 | // +build go1.9
2 |
3 | package sqlmock
4 |
5 | import (
6 | "database/sql"
7 | "database/sql/driver"
8 | )
9 |
10 | // CheckNamedValue meets https://golang.org/pkg/database/sql/driver/#NamedValueChecker
11 | func (c *sqlmock) CheckNamedValue(nv *driver.NamedValue) (err error) {
12 | switch nv.Value.(type) {
13 | case sql.Out:
14 | return nil
15 | default:
16 | nv.Value, err = c.converter.ConvertValue(nv.Value)
17 | return err
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/statement.go:
--------------------------------------------------------------------------------
1 | package sqlmock
2 |
3 | type statement struct {
4 | conn *sqlmock
5 | ex *ExpectedPrepare
6 | query string
7 | }
8 |
9 | func (stmt *statement) Close() error {
10 | stmt.ex.wasClosed = true
11 | return stmt.ex.closeErr
12 | }
13 |
14 | func (stmt *statement) NumInput() int {
15 | return -1
16 | }
17 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/statement_before_go18.go:
--------------------------------------------------------------------------------
1 | // +build !go1.8
2 |
3 | package sqlmock
4 |
5 | import (
6 | "database/sql/driver"
7 | )
8 |
9 | // Deprecated: Drivers should implement ExecerContext instead.
10 | func (stmt *statement) Exec(args []driver.Value) (driver.Result, error) {
11 | return stmt.conn.Exec(stmt.query, args)
12 | }
13 |
14 | // Deprecated: Drivers should implement StmtQueryContext instead (or additionally).
15 | func (stmt *statement) Query(args []driver.Value) (driver.Rows, error) {
16 | return stmt.conn.Query(stmt.query, args)
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/github.com/DATA-DOG/go-sqlmock/statement_go18.go:
--------------------------------------------------------------------------------
1 | // +build go1.8
2 |
3 | package sqlmock
4 |
5 | import (
6 | "context"
7 | "database/sql/driver"
8 | )
9 |
10 | // Deprecated: Drivers should implement ExecerContext instead.
11 | func (stmt *statement) Exec(args []driver.Value) (driver.Result, error) {
12 | return stmt.conn.ExecContext(context.Background(), stmt.query, convertValueToNamedValue(args))
13 | }
14 |
15 | // Deprecated: Drivers should implement StmtQueryContext instead (or additionally).
16 | func (stmt *statement) Query(args []driver.Value) (driver.Rows, error) {
17 | return stmt.conn.QueryContext(context.Background(), stmt.query, convertValueToNamedValue(args))
18 | }
19 |
20 | func convertValueToNamedValue(args []driver.Value) []driver.NamedValue {
21 | namedArgs := make([]driver.NamedValue, len(args))
22 | for i, v := range args {
23 | namedArgs[i] = driver.NamedValue{Ordinal: i + 1, Value: v}
24 | }
25 | return namedArgs
26 | }
27 |
--------------------------------------------------------------------------------
/vendor/github.com/davecgh/go-spew/LICENSE:
--------------------------------------------------------------------------------
1 | ISC License
2 |
3 | Copyright (c) 2012-2016 Dave Collins
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any
6 | purpose with or without fee is hereby granted, provided that the above
7 | copyright notice and this permission notice appear in all copies.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 |
--------------------------------------------------------------------------------
/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015-2016 Dave Collins
2 | //
3 | // Permission to use, copy, modify, and distribute this software for any
4 | // purpose with or without fee is hereby granted, provided that the above
5 | // copyright notice and this permission notice appear in all copies.
6 | //
7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 |
15 | // NOTE: Due to the following build constraints, this file will only be compiled
16 | // when the code is running on Google App Engine, compiled by GopherJS, or
17 | // "-tags safe" is added to the go build command line. The "disableunsafe"
18 | // tag is deprecated and thus should not be used.
19 | // +build js appengine safe disableunsafe !go1.4
20 |
21 | package spew
22 |
23 | import "reflect"
24 |
25 | const (
26 | // UnsafeDisabled is a build-time constant which specifies whether or
27 | // not access to the unsafe package is available.
28 | UnsafeDisabled = true
29 | )
30 |
31 | // unsafeReflectValue typically converts the passed reflect.Value into a one
32 | // that bypasses the typical safety restrictions preventing access to
33 | // unaddressable and unexported data. However, doing this relies on access to
34 | // the unsafe package. This is a stub version which simply returns the passed
35 | // reflect.Value when the unsafe package is not available.
36 | func unsafeReflectValue(v reflect.Value) reflect.Value {
37 | return v
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/.gitignore:
--------------------------------------------------------------------------------
1 | /.idea
2 | /.connstr
3 | .vscode
4 | .terraform
5 | *.tfstate*
6 | *.log
7 | *.swp
8 | *~
9 | coverage.json
10 | coverage.txt
11 | coverage.xml
12 | testresults.xml
13 | .azureconnstr
14 |
15 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/.golangci.yml:
--------------------------------------------------------------------------------
1 | linters:
2 | enable:
3 | # basic go linters
4 | - gofmt
5 | - golint
6 | - govet
7 |
8 | # sql related linters
9 | - rowserrcheck
10 | - sqlclosecheck
11 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/accesstokenconnector.go:
--------------------------------------------------------------------------------
1 | // +build go1.10
2 |
3 | package mssql
4 |
5 | import (
6 | "context"
7 | "database/sql/driver"
8 | "errors"
9 | )
10 |
11 | // NewAccessTokenConnector creates a new connector from a DSN and a token provider.
12 | // The token provider func will be called when a new connection is requested and should return a valid access token.
13 | // The returned connector may be used with sql.OpenDB.
14 | func NewAccessTokenConnector(dsn string, tokenProvider func() (string, error)) (driver.Connector, error) {
15 | if tokenProvider == nil {
16 | return nil, errors.New("mssql: tokenProvider cannot be nil")
17 | }
18 |
19 | conn, err := NewConnector(dsn)
20 | if err != nil {
21 | return nil, err
22 | }
23 |
24 | conn.fedAuthRequired = true
25 | conn.fedAuthLibrary = FedAuthLibrarySecurityToken
26 | conn.securityTokenProvider = func(ctx context.Context) (string, error) {
27 | return tokenProvider()
28 | }
29 |
30 | return conn, nil
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/appveyor.yml:
--------------------------------------------------------------------------------
1 | version: 1.0.{build}
2 |
3 | image:
4 | - Visual Studio 2015
5 |
6 | clone_folder: c:\gopath\src\github.com\denisenkom\go-mssqldb
7 |
8 | environment:
9 | GOPATH: c:\gopath
10 | HOST: localhost
11 | SQLUSER: sa
12 | SQLPASSWORD: Password12!
13 | DATABASE: test
14 | GOVERSION: 113
15 | matrix:
16 | - GOVERSION: 18
17 | SQLINSTANCE: SQL2017
18 | - GOVERSION: 19
19 | SQLINSTANCE: SQL2017
20 | - GOVERSION: 110
21 | SQLINSTANCE: SQL2017
22 | - GOVERSION: 111
23 | SQLINSTANCE: SQL2017
24 | - GOVERSION: 112
25 | SQLINSTANCE: SQL2017
26 | - SQLINSTANCE: SQL2017
27 | - SQLINSTANCE: SQL2016
28 | - SQLINSTANCE: SQL2014
29 | - SQLINSTANCE: SQL2012SP1
30 | - SQLINSTANCE: SQL2008R2SP2
31 |
32 | # Go 1.14+ and SQL2019 are available on the Visual Studio 2019 image only
33 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
34 | GOVERSION: 114
35 | SQLINSTANCE: SQL2019
36 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
37 | GOVERSION: 115
38 | SQLINSTANCE: SQL2019
39 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
40 | GOVERSION: 115
41 | SQLINSTANCE: SQL2017
42 | - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
43 | GOVERSION: 116
44 | SQLINSTANCE: SQL2017
45 |
46 | install:
47 | - set GOROOT=c:\go%GOVERSION%
48 | - set PATH=%GOPATH%\bin;%GOROOT%\bin;%PATH%
49 | - go version
50 | - go env
51 | - go get -u github.com/golang-sql/civil
52 | - go get -u github.com/golang-sql/sqlexp
53 |
54 | build_script:
55 | - go build
56 |
57 | before_test:
58 | # setup SQL Server
59 | - ps: |
60 | $instanceName = $env:SQLINSTANCE
61 | Start-Service "MSSQL`$$instanceName"
62 | Start-Service "SQLBrowser"
63 | - sqlcmd -S "(local)\%SQLINSTANCE%" -Q "Use [master]; CREATE DATABASE test;"
64 | - sqlcmd -S "(local)\%SQLINSTANCE%" -h -1 -Q "set nocount on; Select @@version"
65 | - pip install codecov
66 |
67 | test_script:
68 | - go test -race -cpu 4 -coverprofile=coverage.txt -covermode=atomic
69 | - codecov -f coverage.txt
70 |
--------------------------------------------------------------------------------
/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("copyin query is closed")
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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/log.go:
--------------------------------------------------------------------------------
1 | package mssql
2 |
3 | import (
4 | "context"
5 |
6 | "github.com/denisenkom/go-mssqldb/msdsn"
7 | )
8 |
9 | const (
10 | logErrors = uint64(msdsn.LogErrors)
11 | logMessages = uint64(msdsn.LogMessages)
12 | logRows = uint64(msdsn.LogRows)
13 | logSQL = uint64(msdsn.LogSQL)
14 | logParams = uint64(msdsn.LogParams)
15 | logTransaction = uint64(msdsn.LogTransaction)
16 | logDebug = uint64(msdsn.LogDebug)
17 | logRetries = uint64(msdsn.LogRetries)
18 | )
19 |
20 | // Logger is an interface you can implement to have the go-msqldb
21 | // driver automatically log detailed information on your behalf
22 | type Logger interface {
23 | Printf(format string, v ...interface{})
24 | Println(v ...interface{})
25 | }
26 |
27 | // ContextLogger is an interface that provides more information
28 | // than Logger and lets you log messages yourself. This gives you
29 | // more information to log (e.g. trace IDs in the context), more
30 | // control over the logging activity (e.g. log it, trace it, or
31 | // log and trace it, depending on the class of message), and lets
32 | // you log in exactly the format you want.
33 | type ContextLogger interface {
34 | Log(ctx context.Context, category msdsn.Log, msg string)
35 | }
36 |
37 | // optionalLogger implements the ContextLogger interface with
38 | // a default "do nothing" behavior that can be overridden by an
39 | // optional ContextLogger supplied by the user.
40 | type optionalLogger struct {
41 | logger ContextLogger
42 | }
43 |
44 | // Log does nothing unless the user has specified an optional
45 | // ContextLogger to override the "do nothing" default behavior.
46 | func (o optionalLogger) Log(ctx context.Context, category msdsn.Log, msg string) {
47 | if nil != o.logger {
48 | o.logger.Log(ctx, category, msg)
49 | }
50 | }
51 |
52 | // loggerAdapter converts Logger interfaces into ContextLogger
53 | // interfaces. It provides backwards compatibility.
54 | type loggerAdapter struct {
55 | logger Logger
56 | }
57 |
58 | // Log passes the message to the underlying Logger interface's
59 | // Println function, emulating the orignal Logger behavior.
60 | func (la loggerAdapter) Log(_ context.Context, category msdsn.Log, msg string) {
61 |
62 | // Add prefix for certain categories
63 | switch category {
64 | case msdsn.LogErrors:
65 | msg = "ERROR: " + msg
66 | case msdsn.LogRetries:
67 | msg = "RETRY: " + msg
68 | }
69 |
70 | la.logger.Println(msg)
71 | }
72 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/msdsn/conn_str_go115.go:
--------------------------------------------------------------------------------
1 | //go:build go1.15
2 | // +build go1.15
3 |
4 | package msdsn
5 |
6 | import (
7 | "crypto/tls"
8 | "crypto/x509"
9 | "fmt"
10 | )
11 |
12 | func setupTLSCommonName(config *tls.Config, pem []byte) error {
13 | // fix for https://github.com/denisenkom/go-mssqldb/issues/704
14 | // A SSL/TLS certificate Common Name (CN) containing the ":" character
15 | // (which is a non-standard character) will cause normal verification to fail.
16 | // Since the VerifyConnection callback runs after normal certificate
17 | // verification, confirm that SetupTLS() has been called
18 | // with "insecureSkipVerify=false", then InsecureSkipVerify must be set to true
19 | // for this VerifyConnection callback to accomplish certificate verification.
20 | config.InsecureSkipVerify = true
21 | config.VerifyConnection = func(cs tls.ConnectionState) error {
22 | commonName := cs.PeerCertificates[0].Subject.CommonName
23 | if commonName != cs.ServerName {
24 | return fmt.Errorf("invalid certificate name %q, expected %q", commonName, cs.ServerName)
25 | }
26 | opts := x509.VerifyOptions{
27 | Roots: nil,
28 | Intermediates: x509.NewCertPool(),
29 | }
30 | opts.Intermediates.AppendCertsFromPEM(pem)
31 | _, err := cs.PeerCertificates[0].Verify(opts)
32 | return err
33 | }
34 | return nil
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/msdsn/conn_str_go115pre.go:
--------------------------------------------------------------------------------
1 | //go:build !go1.15
2 | // +build !go1.15
3 |
4 | package msdsn
5 |
6 | import "crypto/tls"
7 |
8 | func setupTLSCommonName(config *tls.Config, pem []byte) error {
9 | // Prior to Go 1.15, the TLS allowed ":" when checking the hostname.
10 | // See https://golang.org/issue/40748 for details.
11 | return skipSetup
12 | }
13 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/msdsn/conn_str_go118.go:
--------------------------------------------------------------------------------
1 | // +build go1.18
2 |
3 | package msdsn
4 |
5 | // disableRetryDefault is false for Go versions 1.18 and higher. This matches
6 | // the behavior requested in issue #586. A query that fails at the start due to
7 | // a bad connection is automatically retried. An error is returned only if the
8 | // query fails all of its retries.
9 | const disableRetryDefault bool = false
10 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/msdsn/conn_str_go118pre.go:
--------------------------------------------------------------------------------
1 | // +build !go1.18
2 |
3 | package msdsn
4 |
5 | // disableRetryDefault is true for versions of Go less than 1.18. This matches
6 | // the behavior requested in issue #275. A query that fails at the start due to
7 | // a bad connection is not retried. Instead, the detailed error is immediately
8 | // returned to the caller.
9 | const disableRetryDefault bool = true
10 |
--------------------------------------------------------------------------------
/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 | "errors"
9 | )
10 |
11 | var _ driver.Connector = &Connector{}
12 | var _ driver.SessionResetter = &Conn{}
13 |
14 | func (c *Conn) ResetSession(ctx context.Context) error {
15 | if !c.connectionGood {
16 | return driver.ErrBadConn
17 | }
18 | c.resetSession = true
19 |
20 | if c.connector == nil || len(c.connector.SessionInitSQL) == 0 {
21 | return nil
22 | }
23 |
24 | s, err := c.prepareContext(ctx, c.connector.SessionInitSQL)
25 | if err != nil {
26 | return driver.ErrBadConn
27 | }
28 | _, err = s.exec(ctx, nil)
29 | if err != nil {
30 | return driver.ErrBadConn
31 | }
32 |
33 | return nil
34 | }
35 |
36 | // Connect to the server and return a TDS connection.
37 | func (c *Connector) Connect(ctx context.Context) (driver.Conn, error) {
38 | conn, err := c.driver.connect(ctx, c, c.params)
39 | if err == nil {
40 | err = conn.ResetSession(ctx)
41 | }
42 | return conn, err
43 | }
44 |
45 | // Driver underlying the Connector.
46 | func (c *Connector) Driver() driver.Driver {
47 | return c.driver
48 | }
49 |
50 | func (r *Result) LastInsertId() (int64, error) {
51 | return -1, errors.New("LastInsertId is not supported. Please use the OUTPUT clause or add `select ID = convert(bigint, SCOPE_IDENTITY())` to the end of your query")
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/mssql_go110pre.go:
--------------------------------------------------------------------------------
1 | // +build !go1.10
2 |
3 | package mssql
4 |
5 | import (
6 | "database/sql/driver"
7 | "errors"
8 | )
9 |
10 | func (r *Result) LastInsertId() (int64, error) {
11 | s, err := r.c.Prepare("select cast(@@identity as bigint)")
12 | if err != nil {
13 | return 0, err
14 | }
15 | defer s.Close()
16 | rows, err := s.Query(nil)
17 | if err != nil {
18 | return 0, err
19 | }
20 | defer rows.Close()
21 | dest := make([]driver.Value, 1)
22 | err = rows.Next(dest)
23 | if err != nil {
24 | return 0, err
25 | }
26 | if dest[0] == nil {
27 | return -1, errors.New("There is no generated identity value")
28 | }
29 | lastInsertId := dest[0].(int64)
30 | return lastInsertId, nil
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/mssql_go118.go:
--------------------------------------------------------------------------------
1 | // +build go1.18
2 |
3 | package mssql
4 |
5 | // newRetryableError returns an error that allows the database/sql package
6 | // to automatically retry the failed query. Versions of Go 1.18 and higher
7 | // use errors.Is to determine whether or not a failed query can be retried.
8 | // Therefore, we wrap the underlying error in a RetryableError that both
9 | // implements errors.Is for automatic retry and maintains the error details.
10 | func newRetryableError(err error) error {
11 | return RetryableError{
12 | err: err,
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/github.com/denisenkom/go-mssqldb/mssql_go118pre.go:
--------------------------------------------------------------------------------
1 | // +build !go1.18
2 |
3 | package mssql
4 |
5 | import (
6 | "database/sql/driver"
7 | )
8 |
9 | // newRetryableError returns an error that allows the database/sql package
10 | // to automatically retry the failed query. Versions of Go lower than 1.18
11 | // compare directly to the sentinel error driver.ErrBadConn to determine
12 | // whether or not a failed query can be retried. Therefore, we replace the
13 | // actual error with driver.ErrBadConn, enabling retry but losing the error
14 | // details.
15 | func newRetryableError(err error) error {
16 | return driver.ErrBadConn
17 | }
18 |
--------------------------------------------------------------------------------
/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 |
18 | func isOutputValue(val driver.Value) bool {
19 | return false
20 | }
21 |
--------------------------------------------------------------------------------
/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 | var (
26 | sp_Cursor = procId{1, ""}
27 | sp_CursorOpen = procId{2, ""}
28 | sp_CursorPrepare = procId{3, ""}
29 | sp_CursorExecute = procId{4, ""}
30 | sp_CursorPrepExec = procId{5, ""}
31 | sp_CursorUnprepare = procId{6, ""}
32 | sp_CursorFetch = procId{7, ""}
33 | sp_CursorOption = procId{8, ""}
34 | sp_CursorClose = procId{9, ""}
35 | sp_ExecuteSql = procId{10, ""}
36 | sp_Prepare = procId{11, ""}
37 | sp_PrepExec = procId{13, ""}
38 | sp_PrepExecRpc = procId{14, ""}
39 | sp_Unprepare = procId{15, ""}
40 | )
41 |
42 | // http://msdn.microsoft.com/en-us/library/dd357576.aspx
43 | func sendRpc(buf *tdsBuffer, headers []headerStruct, proc procId, flags uint16, params []param, resetSession bool) (err error) {
44 | buf.BeginPacket(packRPCRequest, resetSession)
45 | writeAllHeaders(buf, headers)
46 | if len(proc.name) == 0 {
47 | var idswitch uint16 = 0xffff
48 | err = binary.Write(buf, binary.LittleEndian, &idswitch)
49 | if err != nil {
50 | return
51 | }
52 | err = binary.Write(buf, binary.LittleEndian, &proc.id)
53 | if err != nil {
54 | return
55 | }
56 | } else {
57 | err = writeUsVarChar(buf, proc.name)
58 | if err != nil {
59 | return
60 | }
61 | }
62 | err = binary.Write(buf, binary.LittleEndian, &flags)
63 | if err != nil {
64 | return
65 | }
66 | for _, param := range params {
67 | if err = writeBVarChar(buf, param.Name); err != nil {
68 | return
69 | }
70 | if err = binary.Write(buf, binary.LittleEndian, param.Flags); err != nil {
71 | return
72 | }
73 | err = writeTypeInfo(buf, ¶m.ti)
74 | if err != nil {
75 | return
76 | }
77 | err = param.ti.Writer(buf, param.ti, param.buffer)
78 | if err != nil {
79 | return
80 | }
81 | }
82 | return buf.FinishPacket()
83 | }
84 |
--------------------------------------------------------------------------------
/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 "strconv"
6 |
7 | const (
8 | _token_name_0 = "tokenReturnStatus"
9 | _token_name_1 = "tokenColMetadata"
10 | _token_name_2 = "tokenOrdertokenErrortokenInfotokenReturnValuetokenLoginAcktokenFeatureExtAck"
11 | _token_name_3 = "tokenRowtokenNbcRow"
12 | _token_name_4 = "tokenEnvChange"
13 | _token_name_5 = "tokenSSPItokenFedAuthInfo"
14 | _token_name_6 = "tokenDonetokenDoneProctokenDoneInProc"
15 | )
16 |
17 | var (
18 | _token_index_2 = [...]uint8{0, 10, 20, 29, 45, 58, 76}
19 | _token_index_3 = [...]uint8{0, 8, 19}
20 | _token_index_5 = [...]uint8{0, 9, 25}
21 | _token_index_6 = [...]uint8{0, 9, 22, 37}
22 | )
23 |
24 | func (i token) String() string {
25 | switch {
26 | case i == 121:
27 | return _token_name_0
28 | case i == 129:
29 | return _token_name_1
30 | case 169 <= i && i <= 174:
31 | i -= 169
32 | return _token_name_2[_token_index_2[i]:_token_index_2[i+1]]
33 | case 209 <= i && i <= 210:
34 | i -= 209
35 | return _token_name_3[_token_index_3[i]:_token_index_3[i+1]]
36 | case i == 227:
37 | return _token_name_4
38 | case 237 <= i && i <= 238:
39 | i -= 237
40 | return _token_name_5[_token_index_5[i]:_token_index_5[i+1]]
41 | case 253 <= i && i <= 255:
42 | i -= 253
43 | return _token_name_6[_token_index_6[i]:_token_index_6[i+1]]
44 | default:
45 | return "token(" + strconv.FormatInt(int64(i), 10) + ")"
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/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 |
76 | // MarshalText converts Uniqueidentifier to bytes corresponding to the stringified hexadecimal representation of the Uniqueidentifier
77 | // e.g., "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA" -> [65 65 65 65 65 65 65 65 45 65 65 65 65 45 65 65 65 65 45 65 65 65 65 65 65 65 65 65 65 65 65]
78 | func (u UniqueIdentifier) MarshalText() []byte {
79 | return []byte(u.String())
80 | }
81 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/atomic_bool.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package.
2 | //
3 | // Copyright 2022 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 | //go:build go1.19
9 | // +build go1.19
10 |
11 | package mysql
12 |
13 | import "sync/atomic"
14 |
15 | /******************************************************************************
16 | * Sync utils *
17 | ******************************************************************************/
18 |
19 | type atomicBool = atomic.Bool
20 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/atomic_bool_go118.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package.
2 | //
3 | // Copyright 2022 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 | //go:build !go1.19
9 | // +build !go1.19
10 |
11 | package mysql
12 |
13 | import "sync/atomic"
14 |
15 | /******************************************************************************
16 | * Sync utils *
17 | ******************************************************************************/
18 |
19 | // atomicBool is an implementation of atomic.Bool for older version of Go.
20 | // it is a wrapper around uint32 for usage as a boolean value with
21 | // atomic access.
22 | type atomicBool struct {
23 | _ noCopy
24 | value uint32
25 | }
26 |
27 | // Load returns whether the current boolean value is true
28 | func (ab *atomicBool) Load() bool {
29 | return atomic.LoadUint32(&ab.value) > 0
30 | }
31 |
32 | // Store sets the value of the bool regardless of the previous value
33 | func (ab *atomicBool) Store(value bool) {
34 | if value {
35 | atomic.StoreUint32(&ab.value, 1)
36 | } else {
37 | atomic.StoreUint32(&ab.value, 0)
38 | }
39 | }
40 |
41 | // Swap sets the value of the bool and returns the old value.
42 | func (ab *atomicBool) Swap(value bool) bool {
43 | if value {
44 | return atomic.SwapUint32(&ab.value, 1) > 0
45 | }
46 | return atomic.SwapUint32(&ab.value, 0) > 0
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/conncheck.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2 | //
3 | // Copyright 2019 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 | //go:build linux || darwin || dragonfly || freebsd || netbsd || openbsd || solaris || illumos
10 | // +build linux darwin dragonfly freebsd netbsd openbsd solaris illumos
11 |
12 | package mysql
13 |
14 | import (
15 | "errors"
16 | "io"
17 | "net"
18 | "syscall"
19 | )
20 |
21 | var errUnexpectedRead = errors.New("unexpected read from socket")
22 |
23 | func connCheck(conn net.Conn) error {
24 | var sysErr error
25 |
26 | sysConn, ok := conn.(syscall.Conn)
27 | if !ok {
28 | return nil
29 | }
30 | rawConn, err := sysConn.SyscallConn()
31 | if err != nil {
32 | return err
33 | }
34 |
35 | err = rawConn.Read(func(fd uintptr) bool {
36 | var buf [1]byte
37 | n, err := syscall.Read(int(fd), buf[:])
38 | switch {
39 | case n == 0 && err == nil:
40 | sysErr = io.EOF
41 | case n > 0:
42 | sysErr = errUnexpectedRead
43 | case err == syscall.EAGAIN || err == syscall.EWOULDBLOCK:
44 | sysErr = nil
45 | default:
46 | sysErr = err
47 | }
48 | return true
49 | })
50 | if err != nil {
51 | return err
52 | }
53 |
54 | return sysErr
55 | }
56 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/conncheck_dummy.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package
2 | //
3 | // Copyright 2019 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 | //go:build !linux && !darwin && !dragonfly && !freebsd && !netbsd && !openbsd && !solaris && !illumos
10 | // +build !linux,!darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!solaris,!illumos
11 |
12 | package mysql
13 |
14 | import "net"
15 |
16 | func connCheck(conn net.Conn) error {
17 | return nil
18 | }
19 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/fuzz.go:
--------------------------------------------------------------------------------
1 | // Go MySQL Driver - A MySQL-Driver for Go's database/sql package.
2 | //
3 | // Copyright 2020 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 | //go:build gofuzz
10 | // +build gofuzz
11 |
12 | package mysql
13 |
14 | import (
15 | "database/sql"
16 | )
17 |
18 | func Fuzz(data []byte) int {
19 | db, err := sql.Open("mysql", string(data))
20 | if err != nil {
21 | return 0
22 | }
23 | db.Close()
24 | return 1
25 | }
26 |
--------------------------------------------------------------------------------
/vendor/github.com/go-sql-driver/mysql/nulltime.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 | "database/sql"
13 | "database/sql/driver"
14 | "fmt"
15 | "time"
16 | )
17 |
18 | // NullTime represents a time.Time that may be NULL.
19 | // NullTime implements the Scanner interface so
20 | // it can be used as a scan destination:
21 | //
22 | // var nt NullTime
23 | // err := db.QueryRow("SELECT time FROM foo WHERE id=?", id).Scan(&nt)
24 | // ...
25 | // if nt.Valid {
26 | // // use nt.Time
27 | // } else {
28 | // // NULL value
29 | // }
30 | //
31 | // # This NullTime implementation is not driver-specific
32 | //
33 | // Deprecated: NullTime doesn't honor the loc DSN parameter.
34 | // NullTime.Scan interprets a time as UTC, not the loc DSN parameter.
35 | // Use sql.NullTime instead.
36 | type NullTime sql.NullTime
37 |
38 | // Scan implements the Scanner interface.
39 | // The value type must be time.Time or string / []byte (formatted time-string),
40 | // otherwise Scan fails.
41 | func (nt *NullTime) Scan(value interface{}) (err error) {
42 | if value == nil {
43 | nt.Time, nt.Valid = time.Time{}, false
44 | return
45 | }
46 |
47 | switch v := value.(type) {
48 | case time.Time:
49 | nt.Time, nt.Valid = v, true
50 | return
51 | case []byte:
52 | nt.Time, err = parseDateTime(v, time.UTC)
53 | nt.Valid = (err == nil)
54 | return
55 | case string:
56 | nt.Time, err = parseDateTime([]byte(v), time.UTC)
57 | nt.Valid = (err == nil)
58 | return
59 | }
60 |
61 | nt.Valid = false
62 | return fmt.Errorf("Can't convert %T to time.Time", value)
63 | }
64 |
65 | // Value implements the driver Valuer interface.
66 | func (nt NullTime) Value() (driver.Value, error) {
67 | if !nt.Valid {
68 | return nil, nil
69 | }
70 | return nt.Time, nil
71 | }
72 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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.Load() {
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.Load() {
26 | return ErrInvalidConn
27 | }
28 | err = tx.mc.exec("ROLLBACK")
29 | tx.mc = nil
30 | return
31 | }
32 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/civil/README.md:
--------------------------------------------------------------------------------
1 | # Civil Date and Time
2 |
3 | [](https://godoc.org/github.com/golang-sql/civil)
4 |
5 | Civil provides Date, Time of Day, and DateTime data types.
6 |
7 | While there are many uses, using specific types when working
8 | with databases make is conceptually eaiser to understand what value
9 | is set in the remote system.
10 |
11 | ## Source
12 |
13 | This civil package was extracted and forked from `cloud.google.com/go/civil`.
14 | As such the license and contributing requirements remain the same as that
15 | module.
16 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2017 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 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/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 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/README.md:
--------------------------------------------------------------------------------
1 | # golang-sql exp
2 |
3 | https://godoc.org/github.com/golang-sql/sqlexp
4 |
5 | All contributions must have a valid golang CLA.
6 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp provides interfaces and functions that may be adopted into
6 | // the database/sql package in the future. All features may change or be removed
7 | // in the future.
8 | package sqlexp // imports github.com/golang-sql/sqlexp
9 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/mssql.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp
6 |
7 | import (
8 | "context"
9 | "database/sql/driver"
10 | "fmt"
11 | "strings"
12 | )
13 |
14 | type mssql struct{}
15 |
16 | var (
17 | _ DriverNamer = mssql{}
18 | _ DriverQuoter = mssql{}
19 | _ DriverSavepointer = mssql{}
20 | )
21 |
22 | func (mssql) Open(string) (driver.Conn, error) {
23 | panic("not implemented")
24 | }
25 |
26 | func (mssql) Namer(ctx context.Context) (Namer, error) {
27 | return sqlServerNamer{}, nil
28 | }
29 |
30 | func (mssql) Quoter(ctx context.Context) (Quoter, error) {
31 | return sqlServerQuoter{}, nil
32 | }
33 |
34 | func (mssql) Savepointer() (Savepointer, error) {
35 | return sqlServerSavepointer{}, nil
36 | }
37 |
38 | type sqlServerNamer struct{}
39 |
40 | func (sqlServerNamer) Name() string {
41 | return "sqlserver"
42 | }
43 | func (sqlServerNamer) Dialect() string {
44 | return DialectTSQL
45 | }
46 |
47 | type sqlServerQuoter struct{}
48 |
49 | func (sqlServerQuoter) ID(name string) string {
50 | return "[" + strings.Replace(name, "]", "]]", -1) + "]"
51 | }
52 | func (sqlServerQuoter) Value(v interface{}) string {
53 | switch v := v.(type) {
54 | default:
55 | panic("unsupported value")
56 | case string:
57 | return "'" + strings.Replace(v, "'", "''", -1) + "'"
58 | }
59 | }
60 |
61 | type sqlServerSavepointer struct{}
62 |
63 | func (sqlServerSavepointer) Release(name string) string {
64 | return ""
65 | }
66 |
67 | func (sqlServerSavepointer) Create(name string) string {
68 | return fmt.Sprintf("save tran %s;", name)
69 | }
70 |
71 | func (sqlServerSavepointer) Rollback(name string) string {
72 | return fmt.Sprintf("rollback tran %s;", name)
73 | }
74 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/namer.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp
6 |
7 | import (
8 | "context"
9 | "database/sql/driver"
10 | "errors"
11 | "reflect"
12 | )
13 |
14 | const (
15 | DialectPostgres = "postgres"
16 | DialectTSQL = "tsql"
17 | DialectMySQL = "mysql"
18 | DialectSQLite = "sqlite"
19 | DialectOracle = "oracle"
20 | )
21 |
22 | // Namer returns the name of the database and the SQL dialect it
23 | // uses.
24 | type Namer interface {
25 | // Name of the database management system.
26 | //
27 | // Examples:
28 | // "posgresql-9.6"
29 | // "sqlserver-10.54.32"
30 | // "cockroachdb-1.0"
31 | Name() string
32 |
33 | // Dialect of SQL used in the database.
34 | Dialect() string
35 | }
36 |
37 | // DriverNamer may be implemented on the driver.Driver interface.
38 | // It may need to request information from the server to return
39 | // the correct information.
40 | type DriverNamer interface {
41 | Namer(ctx context.Context) (Namer, error)
42 | }
43 |
44 | // NamerFromDriver returns the DriverNamer from the DB if
45 | // it is implemented.
46 | func NamerFromDriver(d driver.Driver, ctx context.Context) (Namer, error) {
47 | if q, is := d.(DriverNamer); is {
48 | return q.Namer(ctx)
49 | }
50 | dv := reflect.ValueOf(d)
51 |
52 | d, found := internalDrivers[dv.Type().String()]
53 | if found {
54 | if q, is := d.(DriverNamer); is {
55 | return q.Namer(ctx)
56 | }
57 | }
58 | return nil, errors.New("namer not found")
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/pg.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp
6 |
7 | import (
8 | "context"
9 | "database/sql/driver"
10 | "fmt"
11 | )
12 |
13 | type postgresql struct{}
14 |
15 | var (
16 | _ DriverNamer = postgresql{}
17 | _ DriverQuoter = postgresql{}
18 | _ DriverSavepointer = postgresql{}
19 | )
20 |
21 | func (postgresql) Open(string) (driver.Conn, error) {
22 | panic("not implemented")
23 | }
24 |
25 | func (postgresql) Namer(ctx context.Context) (Namer, error) {
26 | return pgNamer{}, nil
27 | }
28 |
29 | func (postgresql) Quoter(ctx context.Context) (Quoter, error) {
30 | panic("not implemented")
31 | }
32 |
33 | func (postgresql) Savepointer() (Savepointer, error) {
34 | return pgSavepointer{}, nil
35 | }
36 |
37 | type pgNamer struct{}
38 |
39 | func (pgNamer) Name() string {
40 | return "postgresql"
41 | }
42 | func (pgNamer) Dialect() string {
43 | return DialectPostgres
44 | }
45 |
46 | type pgQuoter struct{}
47 |
48 | func (pgQuoter) ID(name string) string {
49 | return ""
50 | }
51 | func (pgQuoter) Value(v interface{}) string {
52 | return ""
53 | }
54 |
55 | type pgSavepointer struct{}
56 |
57 | func (pgSavepointer) Release(name string) string {
58 | return fmt.Sprintf("release savepoint %s;", name)
59 | }
60 |
61 | func (pgSavepointer) Create(name string) string {
62 | return fmt.Sprintf("savepoint %s;", name)
63 | }
64 |
65 | func (pgSavepointer) Rollback(name string) string {
66 | return fmt.Sprintf("rollback to savepoint %s;", name)
67 | }
68 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/querier.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp
6 |
7 | import (
8 | "context"
9 | "database/sql"
10 | )
11 |
12 | // Querier is the common interface to execute queries on a DB, Tx, or Conn.
13 | type Querier interface {
14 | ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
15 | QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
16 | QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
17 | }
18 |
19 | var (
20 | _ Querier = &sql.DB{}
21 | _ Querier = &sql.Tx{}
22 | )
23 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/quoter.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp
6 |
7 | import (
8 | "context"
9 | "database/sql/driver"
10 | "errors"
11 | "reflect"
12 | )
13 |
14 | // BUG(kardianos): Both the Quoter and Namer may need to access the server.
15 |
16 | // Quoter returns safe and valid SQL strings to use when building a SQL text.
17 | type Quoter interface {
18 | // ID quotes identifiers such as schema, table, or column names.
19 | // ID does not operate on multipart identifiers such as "public.Table",
20 | // it only operates on single identifiers such as "public" and "Table".
21 | ID(name string) string
22 |
23 | // Value quotes database values such as string or []byte types as strings
24 | // that are suitable and safe to embed in SQL text. The returned value
25 | // of a string will include all surrounding quotes.
26 | //
27 | // If a value type is not supported it must panic.
28 | Value(v interface{}) string
29 | }
30 |
31 | // DriverQuoter returns a Quoter interface and is suitable for extending
32 | // the driver.Driver type.
33 | //
34 | // The driver may need to hit the database to determine how it is configured to
35 | // ensure the correct escaping rules are used.
36 | type DriverQuoter interface {
37 | Quoter(ctx context.Context) (Quoter, error)
38 | }
39 |
40 | // QuoterFromDriver takes a database driver, often obtained through a sql.DB.Driver
41 | // call or from using it directly to get the quoter interface.
42 | //
43 | // Currently MssqlDriver is hard-coded to also return a valided Quoter.
44 | func QuoterFromDriver(d driver.Driver, ctx context.Context) (Quoter, error) {
45 | if q, is := d.(DriverQuoter); is {
46 | return q.Quoter(ctx)
47 | }
48 | dv := reflect.ValueOf(d)
49 |
50 | d, found := internalDrivers[dv.Type().String()]
51 | if found {
52 | if q, is := d.(DriverQuoter); is {
53 | return q.Quoter(ctx)
54 | }
55 | }
56 | return nil, errors.New("quoter interface not found")
57 | }
58 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/registry.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp
6 |
7 | import (
8 | "database/sql/driver"
9 | )
10 |
11 | var internalDrivers = map[string]driver.Driver{
12 | "*mssql.MssqlDriver": mssql{},
13 | "*pq.Driver": postgresql{},
14 | "*stdlib.Driver": postgresql{},
15 | }
16 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-sql/sqlexp/savepoint.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 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 sqlexp
6 |
7 | import (
8 | "database/sql/driver"
9 | "errors"
10 | "reflect"
11 | )
12 |
13 | type Savepointer interface {
14 | Release(name string) string
15 | Create(name string) string
16 | Rollback(name string) string
17 | }
18 |
19 | type DriverSavepointer interface {
20 | Savepointer() (Savepointer, error)
21 | }
22 |
23 | // SavepointFromDriver
24 | func SavepointFromDriver(d driver.Driver) (Savepointer, error) {
25 | if q, is := d.(DriverSavepointer); is {
26 | return q.Savepointer()
27 | }
28 | dv := reflect.ValueOf(d)
29 |
30 | d, found := internalDrivers[dv.Type().String()]
31 | if found {
32 | if q, is := d.(DriverSavepointer); is {
33 | return q.Savepointer()
34 | }
35 | }
36 | return nil, errors.New("savepointer interface not found")
37 | }
38 |
--------------------------------------------------------------------------------
/vendor/github.com/lib/pq/.gitignore:
--------------------------------------------------------------------------------
1 | .db
2 | *.test
3 | *~
4 | *.swp
5 | .idea
6 | .vscode
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/lib/pq/README.md:
--------------------------------------------------------------------------------
1 | # pq - A pure Go postgres driver for Go's database/sql package
2 |
3 | [](https://pkg.go.dev/github.com/lib/pq?tab=doc)
4 |
5 | ## Install
6 |
7 | go get github.com/lib/pq
8 |
9 | ## Features
10 |
11 | * SSL
12 | * Handles bad connections for `database/sql`
13 | * Scan `time.Time` correctly (i.e. `timestamp[tz]`, `time[tz]`, `date`)
14 | * Scan binary blobs correctly (i.e. `bytea`)
15 | * Package for `hstore` support
16 | * COPY FROM support
17 | * pq.ParseURL for converting urls to connection strings for sql.Open.
18 | * Many libpq compatible environment variables
19 | * Unix socket support
20 | * Notifications: `LISTEN`/`NOTIFY`
21 | * pgpass support
22 | * GSS (Kerberos) auth
23 |
24 | ## Tests
25 |
26 | `go test` is used for testing. See [TESTS.md](TESTS.md) for more details.
27 |
28 | ## Status
29 |
30 | This package is currently in maintenance mode, which means:
31 | 1. It generally does not accept new features.
32 | 2. It does accept bug fixes and version compatability changes provided by the community.
33 | 3. Maintainers usually do not resolve reported issues.
34 | 4. Community members are encouraged to help each other with reported issues.
35 |
36 | For users that require new features or reliable resolution of reported bugs, we recommend using [pgx](https://github.com/jackc/pgx) which is under active development.
37 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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(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 |
--------------------------------------------------------------------------------
/vendor/github.com/lib/pq/conn_go115.go:
--------------------------------------------------------------------------------
1 | //go:build go1.15
2 | // +build go1.15
3 |
4 | package pq
5 |
6 | import "database/sql/driver"
7 |
8 | var _ driver.Validator = &conn{}
9 |
--------------------------------------------------------------------------------
/vendor/github.com/lib/pq/krb.go:
--------------------------------------------------------------------------------
1 | package pq
2 |
3 | // NewGSSFunc creates a GSS authentication provider, for use with
4 | // RegisterGSSProvider.
5 | type NewGSSFunc func() (GSS, error)
6 |
7 | var newGss NewGSSFunc
8 |
9 | // RegisterGSSProvider registers a GSS authentication provider. For example, if
10 | // you need to use Kerberos to authenticate with your server, add this to your
11 | // main package:
12 | //
13 | // import "github.com/lib/pq/auth/kerberos"
14 | //
15 | // func init() {
16 | // pq.RegisterGSSProvider(func() (pq.GSS, error) { return kerberos.NewGSS() })
17 | // }
18 | func RegisterGSSProvider(newGssArg NewGSSFunc) {
19 | newGss = newGssArg
20 | }
21 |
22 | // GSS provides GSSAPI authentication (e.g., Kerberos).
23 | type GSS interface {
24 | GetInitToken(host string, service string) ([]byte, error)
25 | GetInitTokenFromSpn(spn string) ([]byte, error)
26 | Continue(inToken []byte) (done bool, outToken []byte, err error)
27 | }
28 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/lib/pq/ssl_windows.go:
--------------------------------------------------------------------------------
1 | //go:build windows
2 | // +build windows
3 |
4 | package pq
5 |
6 | // sslKeyPermissions checks the permissions on user-supplied ssl key files.
7 | // The key file should have very little access.
8 | //
9 | // libpq does not check key file permissions on Windows.
10 | func sslKeyPermissions(string) error { return nil }
11 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/lib/pq/user_other.go:
--------------------------------------------------------------------------------
1 | // Package pq is a pure Go Postgres driver for the database/sql package.
2 |
3 | //go:build js || android || hurd || zos
4 | // +build js android hurd zos
5 |
6 | package pq
7 |
8 | func userCurrent() (string, error) {
9 | return "", ErrCouldNotDetectUsername
10 | }
11 |
--------------------------------------------------------------------------------
/vendor/github.com/lib/pq/user_posix.go:
--------------------------------------------------------------------------------
1 | // Package pq is a pure Go Postgres driver for the database/sql package.
2 |
3 | //go:build aix || darwin || dragonfly || freebsd || (linux && !android) || nacl || netbsd || openbsd || plan9 || solaris || rumprun || illumos
4 | // +build aix darwin dragonfly freebsd linux,!android nacl netbsd openbsd plan9 solaris rumprun illumos
5 |
6 | package pq
7 |
8 | import (
9 | "os"
10 | "os/user"
11 | )
12 |
13 | func userCurrent() (string, error) {
14 | u, err := user.Current()
15 | if err == nil {
16 | return u.Username, nil
17 | }
18 |
19 | name := os.Getenv("USER")
20 | if name != "" {
21 | return name, nil
22 | }
23 |
24 | return "", ErrCouldNotDetectUsername
25 | }
26 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/.codecov.yml:
--------------------------------------------------------------------------------
1 | coverage:
2 | status:
3 | project: off
4 | patch: off
5 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_go18.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
14 | "context"
15 | )
16 |
17 | // Ping implement Pinger.
18 | func (c *SQLiteConn) Ping(ctx context.Context) error {
19 | if c.db == nil {
20 | // must be ErrBadConn for sql to close the database
21 | return driver.ErrBadConn
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 | return c.query(ctx, query, args)
29 | }
30 |
31 | // ExecContext implement ExecerContext.
32 | func (c *SQLiteConn) ExecContext(ctx context.Context, query string, args []driver.NamedValue) (driver.Result, error) {
33 | return c.exec(ctx, query, args)
34 | }
35 |
36 | // PrepareContext implement ConnPrepareContext.
37 | func (c *SQLiteConn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error) {
38 | return c.prepare(ctx, query)
39 | }
40 |
41 | // BeginTx implement ConnBeginTx.
42 | func (c *SQLiteConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx, error) {
43 | return c.begin(ctx)
44 | }
45 |
46 | // QueryContext implement QueryerContext.
47 | func (s *SQLiteStmt) QueryContext(ctx context.Context, args []driver.NamedValue) (driver.Rows, error) {
48 | return s.query(ctx, args)
49 | }
50 |
51 | // ExecContext implement ExecerContext.
52 | func (s *SQLiteStmt) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
53 | return s.exec(ctx, args)
54 | }
55 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_libsqlite3.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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,amd64 LDFLAGS: -L/usr/local/opt/sqlite/lib -lsqlite3
14 | #cgo darwin,amd64 CFLAGS: -I/usr/local/opt/sqlite/include
15 | #cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/sqlite/lib -lsqlite3
16 | #cgo darwin,arm64 CFLAGS: -I/opt/homebrew/opt/sqlite/include
17 | #cgo openbsd LDFLAGS: -lsqlite3
18 | #cgo solaris LDFLAGS: -lsqlite3
19 | #cgo windows LDFLAGS: -lsqlite3
20 | */
21 | import "C"
22 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 "sqlite3-binding.h"
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 | if err := c.loadExtension(extension, nil); err != nil {
32 | C.sqlite3_enable_load_extension(c.db, 0)
33 | return err
34 | }
35 | }
36 |
37 | rv = C.sqlite3_enable_load_extension(c.db, 0)
38 | if rv != C.SQLITE_OK {
39 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
40 | }
41 |
42 | return nil
43 | }
44 |
45 | // LoadExtension load the sqlite3 extension.
46 | func (c *SQLiteConn) LoadExtension(lib string, entry string) error {
47 | rv := C.sqlite3_enable_load_extension(c.db, 1)
48 | if rv != C.SQLITE_OK {
49 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
50 | }
51 |
52 | if err := c.loadExtension(lib, &entry); err != nil {
53 | C.sqlite3_enable_load_extension(c.db, 0)
54 | return err
55 | }
56 |
57 | rv = C.sqlite3_enable_load_extension(c.db, 0)
58 | if rv != C.SQLITE_OK {
59 | return errors.New(C.GoString(C.sqlite3_errmsg(c.db)))
60 | }
61 |
62 | return nil
63 | }
64 |
65 | func (c *SQLiteConn) loadExtension(lib string, entry *string) error {
66 | clib := C.CString(lib)
67 | defer C.free(unsafe.Pointer(clib))
68 |
69 | var centry *C.char
70 | if entry != nil {
71 | centry = C.CString(*entry)
72 | defer C.free(unsafe.Pointer(centry))
73 | }
74 |
75 | var errMsg *C.char
76 | defer C.sqlite3_free(unsafe.Pointer(errMsg))
77 |
78 | rv := C.sqlite3_load_extension(c.db, clib, centry, &errMsg)
79 | if rv != C.SQLITE_OK {
80 | return errors.New(C.GoString(errMsg))
81 | }
82 |
83 | return nil
84 | }
85 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_load_extension_omit.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_allow_uri_authority.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_app_armor.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_column_metadata.go:
--------------------------------------------------------------------------------
1 | // +build sqlite_column_metadata
2 |
3 | package sqlite3
4 |
5 | /*
6 | #ifndef USE_LIBSQLITE3
7 | #cgo CFLAGS: -DSQLITE_ENABLE_COLUMN_METADATA
8 | #include
9 | #else
10 | #include
11 | #endif
12 | */
13 | import "C"
14 |
15 | // ColumnTableName returns the table that is the origin of a particular result
16 | // column in a SELECT statement.
17 | //
18 | // See https://www.sqlite.org/c3ref/column_database_name.html
19 | func (s *SQLiteStmt) ColumnTableName(n int) string {
20 | return C.GoString(C.sqlite3_column_table_name(s.s, C.int(n)))
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_foreign_keys.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_fts5.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_icu.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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,amd64 CFLAGS: -I/usr/local/opt/icu4c/include
14 | #cgo darwin,amd64 LDFLAGS: -L/usr/local/opt/icu4c/lib
15 | #cgo darwin,arm64 CFLAGS: -I/opt/homebrew/opt/icu4c/include
16 | #cgo darwin,arm64 LDFLAGS: -L/opt/homebrew/opt/icu4c/lib
17 | #cgo openbsd LDFLAGS: -lsqlite3
18 | */
19 | import "C"
20 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_introspect.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_math_functions.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2022 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_math_functions
7 |
8 | package sqlite3
9 |
10 | /*
11 | #cgo CFLAGS: -DSQLITE_ENABLE_MATH_FUNCTIONS
12 | #cgo LDFLAGS: -lm
13 | */
14 | import "C"
15 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_os_trace.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2022 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 | //go:build sqlite_os_trace
7 | // +build sqlite_os_trace
8 |
9 | package sqlite3
10 |
11 | /*
12 | #cgo CFLAGS: -DSQLITE_FORCE_OS_TRACE=1
13 | #cgo CFLAGS: -DSQLITE_DEBUG_OS_TRACE=1
14 | */
15 | import "C"
16 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_preupdate.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 G.J.R. Timmer .
2 | // Copyright (C) 2018 segment.com
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 cgo
8 |
9 | package sqlite3
10 |
11 | // SQLitePreUpdateData represents all of the data available during a
12 | // pre-update hook call.
13 | type SQLitePreUpdateData struct {
14 | Conn *SQLiteConn
15 | Op int
16 | DatabaseName string
17 | TableName string
18 | OldRowID int64
19 | NewRowID int64
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_preupdate_omit.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 G.J.R. Timmer .
2 | // Copyright (C) 2018 segment.com
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_preupdate_hook,cgo
8 |
9 | package sqlite3
10 |
11 | // RegisterPreUpdateHook sets the pre-update hook for a connection.
12 | //
13 | // The callback is passed a SQLitePreUpdateData struct with the data for
14 | // the update, as well as methods for fetching copies of impacted data.
15 | //
16 | // If there is an existing preupdate hook for this connection, it will be
17 | // removed. If callback is nil the existing hook (if any) will be removed
18 | // without creating a new one.
19 | func (c *SQLiteConn) RegisterPreUpdateHook(callback func(SQLitePreUpdateData)) {
20 | // NOOP
21 | }
22 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_secure_delete.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_secure_delete_fast.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_serialize.go:
--------------------------------------------------------------------------------
1 | // +build !libsqlite3 sqlite_serialize
2 |
3 | package sqlite3
4 |
5 | /*
6 | #ifndef USE_LIBSQLITE3
7 | #include
8 | #else
9 | #include
10 | #endif
11 | #include
12 | #include
13 | */
14 | import "C"
15 |
16 | import (
17 | "fmt"
18 | "math"
19 | "reflect"
20 | "unsafe"
21 | )
22 |
23 | // Serialize returns a byte slice that is a serialization of the database.
24 | //
25 | // See https://www.sqlite.org/c3ref/serialize.html
26 | func (c *SQLiteConn) Serialize(schema string) ([]byte, error) {
27 | if schema == "" {
28 | schema = "main"
29 | }
30 | var zSchema *C.char
31 | zSchema = C.CString(schema)
32 | defer C.free(unsafe.Pointer(zSchema))
33 |
34 | var sz C.sqlite3_int64
35 | ptr := C.sqlite3_serialize(c.db, zSchema, &sz, 0)
36 | if ptr == nil {
37 | return nil, fmt.Errorf("serialize failed")
38 | }
39 | defer C.sqlite3_free(unsafe.Pointer(ptr))
40 |
41 | if sz > C.sqlite3_int64(math.MaxInt) {
42 | return nil, fmt.Errorf("serialized database is too large (%d bytes)", sz)
43 | }
44 |
45 | cBuf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
46 | Data: uintptr(unsafe.Pointer(ptr)),
47 | Len: int(sz),
48 | Cap: int(sz),
49 | }))
50 |
51 | res := make([]byte, int(sz))
52 | copy(res, cBuf)
53 | return res, nil
54 | }
55 |
56 | // Deserialize causes the connection to disconnect from the current database and
57 | // then re-open as an in-memory database based on the contents of the byte slice.
58 | //
59 | // See https://www.sqlite.org/c3ref/deserialize.html
60 | func (c *SQLiteConn) Deserialize(b []byte, schema string) error {
61 | if schema == "" {
62 | schema = "main"
63 | }
64 | var zSchema *C.char
65 | zSchema = C.CString(schema)
66 | defer C.free(unsafe.Pointer(zSchema))
67 |
68 | tmpBuf := (*C.uchar)(C.sqlite3_malloc64(C.sqlite3_uint64(len(b))))
69 | cBuf := *(*[]byte)(unsafe.Pointer(&reflect.SliceHeader{
70 | Data: uintptr(unsafe.Pointer(tmpBuf)),
71 | Len: len(b),
72 | Cap: len(b),
73 | }))
74 | copy(cBuf, b)
75 |
76 | rc := C.sqlite3_deserialize(c.db, zSchema, tmpBuf, C.sqlite3_int64(len(b)),
77 | C.sqlite3_int64(len(b)), C.SQLITE_DESERIALIZE_FREEONCLOSE)
78 | if rc != C.SQLITE_OK {
79 | return fmt.Errorf("deserialize failed with return %v", rc)
80 | }
81 | return nil
82 | }
83 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_serialize_omit.go:
--------------------------------------------------------------------------------
1 | // +build libsqlite3,!sqlite_serialize
2 |
3 | package sqlite3
4 |
5 | import (
6 | "errors"
7 | )
8 |
9 | /*
10 | #cgo CFLAGS: -DSQLITE_OMIT_DESERIALIZE
11 | */
12 | import "C"
13 |
14 | func (c *SQLiteConn) Serialize(schema string) ([]byte, error) {
15 | return nil, errors.New("sqlite3: Serialize requires the sqlite_serialize build tag when using the libsqlite3 build tag")
16 | }
17 |
18 | func (c *SQLiteConn) Deserialize(b []byte, schema string) error {
19 | return errors.New("sqlite3: Deserialize requires the sqlite_serialize build tag when using the libsqlite3 build tag")
20 | }
21 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_stat4.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_unlock_notify.c:
--------------------------------------------------------------------------------
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 | #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
7 | #include
8 | #include "sqlite3-binding.h"
9 |
10 | extern int unlock_notify_wait(sqlite3 *db);
11 |
12 | int
13 | _sqlite3_step_blocking(sqlite3_stmt *stmt)
14 | {
15 | int rv;
16 | sqlite3* db;
17 |
18 | db = sqlite3_db_handle(stmt);
19 | for (;;) {
20 | rv = sqlite3_step(stmt);
21 | if (rv != SQLITE_LOCKED) {
22 | break;
23 | }
24 | if (sqlite3_extended_errcode(db) != SQLITE_LOCKED_SHAREDCACHE) {
25 | break;
26 | }
27 | rv = unlock_notify_wait(db);
28 | if (rv != SQLITE_OK) {
29 | break;
30 | }
31 | sqlite3_reset(stmt);
32 | }
33 |
34 | return rv;
35 | }
36 |
37 | int
38 | _sqlite3_step_row_blocking(sqlite3_stmt* stmt, long long* rowid, long long* changes)
39 | {
40 | int rv;
41 | sqlite3* db;
42 |
43 | db = sqlite3_db_handle(stmt);
44 | for (;;) {
45 | rv = sqlite3_step(stmt);
46 | if (rv!=SQLITE_LOCKED) {
47 | break;
48 | }
49 | if (sqlite3_extended_errcode(db) != SQLITE_LOCKED_SHAREDCACHE) {
50 | break;
51 | }
52 | rv = unlock_notify_wait(db);
53 | if (rv != SQLITE_OK) {
54 | break;
55 | }
56 | sqlite3_reset(stmt);
57 | }
58 |
59 | *rowid = (long long) sqlite3_last_insert_rowid(db);
60 | *changes = (long long) sqlite3_changes(db);
61 | return rv;
62 | }
63 |
64 | int
65 | _sqlite3_prepare_v2_blocking(sqlite3 *db, const char *zSql, int nBytes, sqlite3_stmt **ppStmt, const char **pzTail)
66 | {
67 | int rv;
68 |
69 | for (;;) {
70 | rv = sqlite3_prepare_v2(db, zSql, nBytes, ppStmt, pzTail);
71 | if (rv!=SQLITE_LOCKED) {
72 | break;
73 | }
74 | if (sqlite3_extended_errcode(db) != SQLITE_LOCKED_SHAREDCACHE) {
75 | break;
76 | }
77 | rv = unlock_notify_wait(db);
78 | if (rv != SQLITE_OK) {
79 | break;
80 | }
81 | }
82 |
83 | return rv;
84 | }
85 | #endif
86 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_unlock_notify.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 sqlite_unlock_notify
8 |
9 | package sqlite3
10 |
11 | /*
12 | #cgo CFLAGS: -DSQLITE_ENABLE_UNLOCK_NOTIFY
13 |
14 | #include
15 | #include "sqlite3-binding.h"
16 |
17 | extern void unlock_notify_callback(void *arg, int argc);
18 | */
19 | import "C"
20 | import (
21 | "fmt"
22 | "math"
23 | "sync"
24 | "unsafe"
25 | )
26 |
27 | type unlock_notify_table struct {
28 | sync.Mutex
29 | seqnum uint
30 | table map[uint]chan struct{}
31 | }
32 |
33 | var unt unlock_notify_table = unlock_notify_table{table: make(map[uint]chan struct{})}
34 |
35 | func (t *unlock_notify_table) add(c chan struct{}) uint {
36 | t.Lock()
37 | defer t.Unlock()
38 | h := t.seqnum
39 | t.table[h] = c
40 | t.seqnum++
41 | return h
42 | }
43 |
44 | func (t *unlock_notify_table) remove(h uint) {
45 | t.Lock()
46 | defer t.Unlock()
47 | delete(t.table, h)
48 | }
49 |
50 | func (t *unlock_notify_table) get(h uint) chan struct{} {
51 | t.Lock()
52 | defer t.Unlock()
53 | c, ok := t.table[h]
54 | if !ok {
55 | panic(fmt.Sprintf("Non-existent key for unlcok-notify channel: %d", h))
56 | }
57 | return c
58 | }
59 |
60 | //export unlock_notify_callback
61 | func unlock_notify_callback(argv unsafe.Pointer, argc C.int) {
62 | for i := 0; i < int(argc); i++ {
63 | parg := ((*(*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.uint)(nil))]*[1]uint)(argv))[i])
64 | arg := *parg
65 | h := arg[0]
66 | c := unt.get(h)
67 | c <- struct{}{}
68 | }
69 | }
70 |
71 | //export unlock_notify_wait
72 | func unlock_notify_wait(db *C.sqlite3) C.int {
73 | // It has to be a bufferred channel to not block in sqlite_unlock_notify
74 | // as sqlite_unlock_notify could invoke the callback before it returns.
75 | c := make(chan struct{}, 1)
76 | defer close(c)
77 |
78 | h := unt.add(c)
79 | defer unt.remove(h)
80 |
81 | pargv := C.malloc(C.sizeof_uint)
82 | defer C.free(pargv)
83 |
84 | argv := (*[1]uint)(pargv)
85 | argv[0] = h
86 | if rv := C.sqlite3_unlock_notify(db, (*[0]byte)(C.unlock_notify_callback), unsafe.Pointer(pargv)); rv != C.SQLITE_OK {
87 | return rv
88 | }
89 |
90 | <-c
91 |
92 | return C.SQLITE_OK
93 | }
94 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_vacuum_full.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_opt_vacuum_incr.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_other.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 | #cgo linux,ppc LDFLAGS: -lpthread
14 | #cgo linux,ppc64 LDFLAGS: -lpthread
15 | #cgo linux,ppc64le LDFLAGS: -lpthread
16 | */
17 | import "C"
18 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_solaris.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
--------------------------------------------------------------------------------
/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://github.com/php/php-src/blob/PHP-5.0/win32/time.c
19 | // License: https://github.com/php/php-src/blob/PHP-5.0/LICENSE
20 | // Details: https://stackoverflow.com/questions/5801813/c-usleep-is-obsolete-workarounds-for-windows-mingw?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa
21 |
22 | /*
23 | #include
24 |
25 | void usleep(__int64 usec)
26 | {
27 | HANDLE timer;
28 | LARGE_INTEGER ft;
29 |
30 | // Convert to 100 nanosecond interval, negative value indicates relative time
31 | ft.QuadPart = -(10*usec);
32 |
33 | timer = CreateWaitableTimer(NULL, TRUE, NULL);
34 | SetWaitableTimer(timer, &ft, 0, NULL, NULL, 0);
35 | WaitForSingleObject(timer, INFINITE);
36 | CloseHandle(timer);
37 | }
38 | */
39 | import "C"
40 |
41 | // EOF
42 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/sqlite3_windows.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 windows,386 CFLAGS: -D_USE_32BIT_TIME_T
16 | */
17 | import "C"
18 |
--------------------------------------------------------------------------------
/vendor/github.com/mattn/go-sqlite3/static_mock.go:
--------------------------------------------------------------------------------
1 | // Copyright (C) 2019 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 |
8 | package sqlite3
9 |
10 | import (
11 | "database/sql"
12 | "database/sql/driver"
13 | "errors"
14 | )
15 |
16 | var errorMsg = errors.New("Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub")
17 |
18 | func init() {
19 | sql.Register("sqlite3", &SQLiteDriver{})
20 | }
21 |
22 | type (
23 | SQLiteDriver struct {
24 | Extensions []string
25 | ConnectHook func(*SQLiteConn) error
26 | }
27 | SQLiteConn struct{}
28 | )
29 |
30 | func (SQLiteDriver) Open(s string) (driver.Conn, error) { return nil, errorMsg }
31 | func (c *SQLiteConn) RegisterAggregator(string, interface{}, bool) error { return errorMsg }
32 | func (c *SQLiteConn) RegisterAuthorizer(func(int, string, string, string) int) {}
33 | func (c *SQLiteConn) RegisterCollation(string, func(string, string) int) error { return errorMsg }
34 | func (c *SQLiteConn) RegisterCommitHook(func() int) {}
35 | func (c *SQLiteConn) RegisterFunc(string, interface{}, bool) error { return errorMsg }
36 | func (c *SQLiteConn) RegisterRollbackHook(func()) {}
37 | func (c *SQLiteConn) RegisterUpdateHook(func(int, string, string, int64)) {}
38 |
--------------------------------------------------------------------------------
/vendor/github.com/pmezard/go-difflib/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013, Patrick Mezard
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
6 | met:
7 |
8 | Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in the
12 | documentation and/or other materials provided with the distribution.
13 | The names of its contributors may not be used to endorse or promote
14 | products derived from this software without specific prior written
15 | permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | engines:
2 | gofmt:
3 | enabled: true
4 | golint:
5 | enabled: true
6 | govet:
7 | enabled: true
8 |
9 | exclude_patterns:
10 | - ".github/"
11 | - "vendor/"
12 | - "codegen/"
13 | - "*.yml"
14 | - ".*.yml"
15 | - "*.md"
16 | - "Gopkg.*"
17 | - "doc.go"
18 | - "type_specific_codegen_test.go"
19 | - "type_specific_codegen.go"
20 | - ".gitignore"
21 | - "LICENSE"
22 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.dll
4 | *.so
5 | *.dylib
6 |
7 | # Test binary, build with `go test -c`
8 | *.test
9 |
10 | # Output of the go coverage tool, specifically when used with LiteIDE
11 | *.out
12 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2014 Stretchr, Inc.
4 | Copyright (c) 2017-2018 objx contributors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/Taskfile.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 |
3 | env:
4 | GOFLAGS: -mod=vendor
5 |
6 | tasks:
7 | default:
8 | deps: [test]
9 |
10 | lint:
11 | desc: Checks code style
12 | cmds:
13 | - gofmt -d -s *.go
14 | - go vet ./...
15 | silent: true
16 |
17 | lint-fix:
18 | desc: Fixes code style
19 | cmds:
20 | - gofmt -w -s *.go
21 |
22 | test:
23 | desc: Runs go tests
24 | cmds:
25 | - go test -race ./...
26 |
27 | test-coverage:
28 | desc: Runs go tests and calculates test coverage
29 | cmds:
30 | - go test -race -coverprofile=c.out ./...
31 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/doc.go:
--------------------------------------------------------------------------------
1 | /*
2 | Objx - Go package for dealing with maps, slices, JSON and other data.
3 |
4 | Overview
5 |
6 | Objx provides the `objx.Map` type, which is a `map[string]interface{}` that exposes
7 | a powerful `Get` method (among others) that allows you to easily and quickly get
8 | access to data within the map, without having to worry too much about type assertions,
9 | missing data, default values etc.
10 |
11 | Pattern
12 |
13 | Objx uses a preditable pattern to make access data from within `map[string]interface{}` easy.
14 | Call one of the `objx.` functions to create your `objx.Map` to get going:
15 |
16 | m, err := objx.FromJSON(json)
17 |
18 | NOTE: Any methods or functions with the `Must` prefix will panic if something goes wrong,
19 | the rest will be optimistic and try to figure things out without panicking.
20 |
21 | Use `Get` to access the value you're interested in. You can use dot and array
22 | notation too:
23 |
24 | m.Get("places[0].latlng")
25 |
26 | Once you have sought the `Value` you're interested in, you can use the `Is*` methods to determine its type.
27 |
28 | if m.Get("code").IsStr() { // Your code... }
29 |
30 | Or you can just assume the type, and use one of the strong type methods to extract the real value:
31 |
32 | m.Get("code").Int()
33 |
34 | If there's no value there (or if it's the wrong type) then a default value will be returned,
35 | or you can be explicit about the default value.
36 |
37 | Get("code").Int(-1)
38 |
39 | If you're dealing with a slice of data as a value, Objx provides many useful methods for iterating,
40 | manipulating and selecting that data. You can find out more by exploring the index below.
41 |
42 | Reading data
43 |
44 | A simple example of how to use Objx:
45 |
46 | // Use MustFromJSON to make an objx.Map from some JSON
47 | m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`)
48 |
49 | // Get the details
50 | name := m.Get("name").Str()
51 | age := m.Get("age").Int()
52 |
53 | // Get their nickname (or use their name if they don't have one)
54 | nickname := m.Get("nickname").Str(name)
55 |
56 | Ranging
57 |
58 | Since `objx.Map` is a `map[string]interface{}` you can treat it as such.
59 | For example, to `range` the data, do what you would expect:
60 |
61 | m := objx.MustFromJSON(json)
62 | for key, value := range m {
63 | // Your code...
64 | }
65 | */
66 | package objx
67 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/mutations.go:
--------------------------------------------------------------------------------
1 | package objx
2 |
3 | // Exclude returns a new Map with the keys in the specified []string
4 | // excluded.
5 | func (m Map) Exclude(exclude []string) Map {
6 | excluded := make(Map)
7 | for k, v := range m {
8 | if !contains(exclude, k) {
9 | excluded[k] = v
10 | }
11 | }
12 | return excluded
13 | }
14 |
15 | // Copy creates a shallow copy of the Obj.
16 | func (m Map) Copy() Map {
17 | copied := Map{}
18 | for k, v := range m {
19 | copied[k] = v
20 | }
21 | return copied
22 | }
23 |
24 | // Merge blends the specified map with a copy of this map and returns the result.
25 | //
26 | // Keys that appear in both will be selected from the specified map.
27 | // This method requires that the wrapped object be a map[string]interface{}
28 | func (m Map) Merge(merge Map) Map {
29 | return m.Copy().MergeHere(merge)
30 | }
31 |
32 | // MergeHere blends the specified map with this map and returns the current map.
33 | //
34 | // Keys that appear in both will be selected from the specified map. The original map
35 | // will be modified. This method requires that
36 | // the wrapped object be a map[string]interface{}
37 | func (m Map) MergeHere(merge Map) Map {
38 | for k, v := range merge {
39 | m[k] = v
40 | }
41 | return m
42 | }
43 |
44 | // Transform builds a new Obj giving the transformer a chance
45 | // to change the keys and values as it goes. This method requires that
46 | // the wrapped object be a map[string]interface{}
47 | func (m Map) Transform(transformer func(key string, value interface{}) (string, interface{})) Map {
48 | newMap := Map{}
49 | for k, v := range m {
50 | modifiedKey, modifiedVal := transformer(k, v)
51 | newMap[modifiedKey] = modifiedVal
52 | }
53 | return newMap
54 | }
55 |
56 | // TransformKeys builds a new map using the specified key mapping.
57 | //
58 | // Unspecified keys will be unaltered.
59 | // This method requires that the wrapped object be a map[string]interface{}
60 | func (m Map) TransformKeys(mapping map[string]string) Map {
61 | return m.Transform(func(key string, value interface{}) (string, interface{}) {
62 | if newKey, ok := mapping[key]; ok {
63 | return newKey, value
64 | }
65 | return key, value
66 | })
67 | }
68 |
69 | // Checks if a string slice contains a string
70 | func contains(s []string, e string) bool {
71 | for _, a := range s {
72 | if a == e {
73 | return true
74 | }
75 | }
76 | return false
77 | }
78 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/security.go:
--------------------------------------------------------------------------------
1 | package objx
2 |
3 | import (
4 | "crypto/sha1"
5 | "encoding/hex"
6 | )
7 |
8 | // HashWithKey hashes the specified string using the security key
9 | func HashWithKey(data, key string) string {
10 | d := sha1.Sum([]byte(data + ":" + key))
11 | return hex.EncodeToString(d[:])
12 | }
13 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/tests.go:
--------------------------------------------------------------------------------
1 | package objx
2 |
3 | // Has gets whether there is something at the specified selector
4 | // or not.
5 | //
6 | // If m is nil, Has will always return false.
7 | func (m Map) Has(selector string) bool {
8 | if m == nil {
9 | return false
10 | }
11 | return !m.Get(selector).IsNil()
12 | }
13 |
14 | // IsNil gets whether the data is nil or not.
15 | func (v *Value) IsNil() bool {
16 | return v == nil || v.data == nil
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors.
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 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go:
--------------------------------------------------------------------------------
1 | //go:build go1.17
2 | // +build go1.17
3 |
4 | // TODO: once support for Go 1.16 is dropped, this file can be
5 | // merged/removed with assertion_compare_go1.17_test.go and
6 | // assertion_compare_legacy.go
7 |
8 | package assert
9 |
10 | import "reflect"
11 |
12 | // Wrapper around reflect.Value.CanConvert, for compatibility
13 | // reasons.
14 | func canConvert(value reflect.Value, to reflect.Type) bool {
15 | return value.CanConvert(to)
16 | }
17 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go:
--------------------------------------------------------------------------------
1 | //go:build !go1.17
2 | // +build !go1.17
3 |
4 | // TODO: once support for Go 1.16 is dropped, this file can be
5 | // merged/removed with assertion_compare_go1.17_test.go and
6 | // assertion_compare_can_convert.go
7 |
8 | package assert
9 |
10 | import "reflect"
11 |
12 | // Older versions of Go does not have the reflect.Value.CanConvert
13 | // method.
14 | func canConvert(value reflect.Value, to reflect.Type) bool {
15 | return false
16 | }
17 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.CommentFormat}}
2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool {
3 | if h, ok := t.(tHelper); ok { h.Helper() }
4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}})
5 | }
6 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.CommentWithoutT "a"}}
2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool {
3 | if h, ok := a.t.(tHelper); ok { h.Helper() }
4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
5 | }
6 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/doc.go:
--------------------------------------------------------------------------------
1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
2 | //
3 | // # Example Usage
4 | //
5 | // The following is a complete example using assert in a standard test function:
6 | //
7 | // import (
8 | // "testing"
9 | // "github.com/stretchr/testify/assert"
10 | // )
11 | //
12 | // func TestSomething(t *testing.T) {
13 | //
14 | // var a string = "Hello"
15 | // var b string = "Hello"
16 | //
17 | // assert.Equal(t, a, b, "The two words should be the same.")
18 | //
19 | // }
20 | //
21 | // if you assert many times, use the format below:
22 | //
23 | // import (
24 | // "testing"
25 | // "github.com/stretchr/testify/assert"
26 | // )
27 | //
28 | // func TestSomething(t *testing.T) {
29 | // assert := assert.New(t)
30 | //
31 | // var a string = "Hello"
32 | // var b string = "Hello"
33 | //
34 | // assert.Equal(a, b, "The two words should be the same.")
35 | // }
36 | //
37 | // # Assertions
38 | //
39 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package.
40 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the
41 | // testing framework. This allows the assertion funcs to write the failings and other details to
42 | // the correct place.
43 | //
44 | // Every assertion function also takes an optional string message as the final argument,
45 | // allowing custom error messages to be appended to the message the assertion method outputs.
46 | package assert
47 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/errors.go:
--------------------------------------------------------------------------------
1 | package assert
2 |
3 | import (
4 | "errors"
5 | )
6 |
7 | // AnError is an error instance useful for testing. If the code does not care
8 | // about error specifics, and only needs to return the error for example, this
9 | // error should be used to make the test code more readable.
10 | var AnError = errors.New("assert.AnError general error for testing")
11 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/forward_assertions.go:
--------------------------------------------------------------------------------
1 | package assert
2 |
3 | // Assertions provides assertion methods around the
4 | // TestingT interface.
5 | type Assertions struct {
6 | t TestingT
7 | }
8 |
9 | // New makes a new Assertions object for the specified TestingT.
10 | func New(t TestingT) *Assertions {
11 | return &Assertions{
12 | t: t,
13 | }
14 | }
15 |
16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs"
17 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/mock/doc.go:
--------------------------------------------------------------------------------
1 | // Package mock provides a system by which it is possible to mock your objects
2 | // and verify calls are happening as expected.
3 | //
4 | // # Example Usage
5 | //
6 | // The mock package provides an object, Mock, that tracks activity on another object. It is usually
7 | // embedded into a test object as shown below:
8 | //
9 | // type MyTestObject struct {
10 | // // add a Mock object instance
11 | // mock.Mock
12 | //
13 | // // other fields go here as normal
14 | // }
15 | //
16 | // When implementing the methods of an interface, you wire your functions up
17 | // to call the Mock.Called(args...) method, and return the appropriate values.
18 | //
19 | // For example, to mock a method that saves the name and age of a person and returns
20 | // the year of their birth or an error, you might write this:
21 | //
22 | // func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) {
23 | // args := o.Called(firstname, lastname, age)
24 | // return args.Int(0), args.Error(1)
25 | // }
26 | //
27 | // The Int, Error and Bool methods are examples of strongly typed getters that take the argument
28 | // index position. Given this argument list:
29 | //
30 | // (12, true, "Something")
31 | //
32 | // You could read them out strongly typed like this:
33 | //
34 | // args.Int(0)
35 | // args.Bool(1)
36 | // args.String(2)
37 | //
38 | // For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion:
39 | //
40 | // return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine)
41 | //
42 | // This may cause a panic if the object you are getting is nil (the type assertion will fail), in those
43 | // cases you should check for nil first.
44 | package mock
45 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/doc.go:
--------------------------------------------------------------------------------
1 | // Package require implements the same assertions as the `assert` package but
2 | // stops test execution when a test fails.
3 | //
4 | // # Example Usage
5 | //
6 | // The following is a complete example using require in a standard test function:
7 | //
8 | // import (
9 | // "testing"
10 | // "github.com/stretchr/testify/require"
11 | // )
12 | //
13 | // func TestSomething(t *testing.T) {
14 | //
15 | // var a string = "Hello"
16 | // var b string = "Hello"
17 | //
18 | // require.Equal(t, a, b, "The two words should be the same.")
19 | //
20 | // }
21 | //
22 | // # Assertions
23 | //
24 | // The `require` package have same global functions as in the `assert` package,
25 | // but instead of returning a boolean result they call `t.FailNow()`.
26 | //
27 | // Every assertion function also takes an optional string message as the final argument,
28 | // allowing custom error messages to be appended to the message the assertion method outputs.
29 | package require
30 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/forward_requirements.go:
--------------------------------------------------------------------------------
1 | package require
2 |
3 | // Assertions provides assertion methods around the
4 | // TestingT interface.
5 | type Assertions struct {
6 | t TestingT
7 | }
8 |
9 | // New makes a new Assertions object for the specified TestingT.
10 | func New(t TestingT) *Assertions {
11 | return &Assertions{
12 | t: t,
13 | }
14 | }
15 |
16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require_forward.go.tmpl -include-format-funcs"
17 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/require.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.Comment}}
2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
3 | if h, ok := t.(tHelper); ok { h.Helper() }
4 | if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return }
5 | t.FailNow()
6 | }
7 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.CommentWithoutT "a"}}
2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {
3 | if h, ok := a.t.(tHelper); ok { h.Helper() }
4 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
5 | }
6 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/requirements.go:
--------------------------------------------------------------------------------
1 | package require
2 |
3 | // TestingT is an interface wrapper around *testing.T
4 | type TestingT interface {
5 | Errorf(format string, args ...interface{})
6 | FailNow()
7 | }
8 |
9 | type tHelper interface {
10 | Helper()
11 | }
12 |
13 | // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful
14 | // for table driven tests.
15 | type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{})
16 |
17 | // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful
18 | // for table driven tests.
19 | type ValueAssertionFunc func(TestingT, interface{}, ...interface{})
20 |
21 | // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful
22 | // for table driven tests.
23 | type BoolAssertionFunc func(TestingT, bool, ...interface{})
24 |
25 | // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful
26 | // for table driven tests.
27 | type ErrorAssertionFunc func(TestingT, error, ...interface{})
28 |
29 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs"
30 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/suite/interfaces.go:
--------------------------------------------------------------------------------
1 | package suite
2 |
3 | import "testing"
4 |
5 | // TestingSuite can store and return the current *testing.T context
6 | // generated by 'go test'.
7 | type TestingSuite interface {
8 | T() *testing.T
9 | SetT(*testing.T)
10 | SetS(suite TestingSuite)
11 | }
12 |
13 | // SetupAllSuite has a SetupSuite method, which will run before the
14 | // tests in the suite are run.
15 | type SetupAllSuite interface {
16 | SetupSuite()
17 | }
18 |
19 | // SetupTestSuite has a SetupTest method, which will run before each
20 | // test in the suite.
21 | type SetupTestSuite interface {
22 | SetupTest()
23 | }
24 |
25 | // TearDownAllSuite has a TearDownSuite method, which will run after
26 | // all the tests in the suite have been run.
27 | type TearDownAllSuite interface {
28 | TearDownSuite()
29 | }
30 |
31 | // TearDownTestSuite has a TearDownTest method, which will run after
32 | // each test in the suite.
33 | type TearDownTestSuite interface {
34 | TearDownTest()
35 | }
36 |
37 | // BeforeTest has a function to be executed right before the test
38 | // starts and receives the suite and test names as input
39 | type BeforeTest interface {
40 | BeforeTest(suiteName, testName string)
41 | }
42 |
43 | // AfterTest has a function to be executed right after the test
44 | // finishes and receives the suite and test names as input
45 | type AfterTest interface {
46 | AfterTest(suiteName, testName string)
47 | }
48 |
49 | // WithStats implements HandleStats, a function that will be executed
50 | // when a test suite is finished. The stats contain information about
51 | // the execution of that suite and its tests.
52 | type WithStats interface {
53 | HandleStats(suiteName string, stats *SuiteInformation)
54 | }
55 |
56 | // SetupSubTest has a SetupSubTest method, which will run before each
57 | // subtest in the suite.
58 | type SetupSubTest interface {
59 | SetupSubTest()
60 | }
61 |
62 | // TearDownSubTest has a TearDownSubTest method, which will run after
63 | // each subtest in the suite have been run.
64 | type TearDownSubTest interface {
65 | TearDownSubTest()
66 | }
67 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/suite/stats.go:
--------------------------------------------------------------------------------
1 | package suite
2 |
3 | import "time"
4 |
5 | // SuiteInformation stats stores stats for the whole suite execution.
6 | type SuiteInformation struct {
7 | Start, End time.Time
8 | TestStats map[string]*TestInformation
9 | }
10 |
11 | // TestInformation stores information about the execution of each test.
12 | type TestInformation struct {
13 | TestName string
14 | Start, End time.Time
15 | Passed bool
16 | }
17 |
18 | func newSuiteInformation() *SuiteInformation {
19 | testStats := make(map[string]*TestInformation)
20 |
21 | return &SuiteInformation{
22 | TestStats: testStats,
23 | }
24 | }
25 |
26 | func (s SuiteInformation) start(testName string) {
27 | s.TestStats[testName] = &TestInformation{
28 | TestName: testName,
29 | Start: time.Now(),
30 | }
31 | }
32 |
33 | func (s SuiteInformation) end(testName string, passed bool) {
34 | s.TestStats[testName].End = time.Now()
35 | s.TestStats[testName].Passed = passed
36 | }
37 |
38 | func (s SuiteInformation) Passed() bool {
39 | for _, stats := range s.TestStats {
40 | if !stats.Passed {
41 | return false
42 | }
43 | }
44 |
45 | return true
46 | }
47 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 | import "math/bits"
12 |
13 | var shift1 = []int{3, 7, 11, 19}
14 | var shift2 = []int{3, 5, 9, 13}
15 | var shift3 = []int{3, 9, 11, 15}
16 |
17 | var xIndex2 = []uint{0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15}
18 | var xIndex3 = []uint{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
19 |
20 | func _Block(dig *digest, p []byte) int {
21 | a := dig.s[0]
22 | b := dig.s[1]
23 | c := dig.s[2]
24 | d := dig.s[3]
25 | n := 0
26 | var X [16]uint32
27 | for len(p) >= _Chunk {
28 | aa, bb, cc, dd := a, b, c, d
29 |
30 | j := 0
31 | for i := 0; i < 16; i++ {
32 | X[i] = uint32(p[j]) | uint32(p[j+1])<<8 | uint32(p[j+2])<<16 | uint32(p[j+3])<<24
33 | j += 4
34 | }
35 |
36 | // If this needs to be made faster in the future,
37 | // the usual trick is to unroll each of these
38 | // loops by a factor of 4; that lets you replace
39 | // the shift[] lookups with constants and,
40 | // with suitable variable renaming in each
41 | // unrolled body, delete the a, b, c, d = d, a, b, c
42 | // (or you can let the optimizer do the renaming).
43 | //
44 | // The index variables are uint so that % by a power
45 | // of two can be optimized easily by a compiler.
46 |
47 | // Round 1.
48 | for i := uint(0); i < 16; i++ {
49 | x := i
50 | s := shift1[i%4]
51 | f := ((c ^ d) & b) ^ d
52 | a += f + X[x]
53 | a = bits.RotateLeft32(a, s)
54 | a, b, c, d = d, a, b, c
55 | }
56 |
57 | // Round 2.
58 | for i := uint(0); i < 16; i++ {
59 | x := xIndex2[i]
60 | s := shift2[i%4]
61 | g := (b & c) | (b & d) | (c & d)
62 | a += g + X[x] + 0x5a827999
63 | a = bits.RotateLeft32(a, s)
64 | a, b, c, d = d, a, b, c
65 | }
66 |
67 | // Round 3.
68 | for i := uint(0); i < 16; i++ {
69 | x := xIndex3[i]
70 | s := shift3[i%4]
71 | h := b ^ c ^ d
72 | a += h + X[x] + 0x6ed9eba1
73 | a = bits.RotateLeft32(a, s)
74 | a, b, c, d = d, a, b, c
75 | }
76 |
77 | a += aa
78 | b += bb
79 | c += cc
80 | d += dd
81 |
82 | p = p[_Chunk:]
83 | n += _Chunk
84 | }
85 |
86 | dig.s[0] = a
87 | dig.s[1] = b
88 | dig.s[2] = c
89 | dig.s[3] = d
90 | return n
91 | }
92 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v3/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | This project is covered by two different licenses: MIT and Apache.
3 |
4 | #### MIT License ####
5 |
6 | The following files were ported to Go from C files of libyaml, and thus
7 | are still covered by their original MIT license, with the additional
8 | copyright staring in 2011 when the project was ported over:
9 |
10 | apic.go emitterc.go parserc.go readerc.go scannerc.go
11 | writerc.go yamlh.go yamlprivateh.go
12 |
13 | Copyright (c) 2006-2010 Kirill Simonov
14 | Copyright (c) 2006-2011 Kirill Simonov
15 |
16 | Permission is hereby granted, free of charge, to any person obtaining a copy of
17 | this software and associated documentation files (the "Software"), to deal in
18 | the Software without restriction, including without limitation the rights to
19 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
20 | of the Software, and to permit persons to whom the Software is furnished to do
21 | so, subject to the following conditions:
22 |
23 | The above copyright notice and this permission notice shall be included in all
24 | copies or substantial portions of the Software.
25 |
26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 | SOFTWARE.
33 |
34 | ### Apache License ###
35 |
36 | All the remaining project files are covered by the Apache license:
37 |
38 | Copyright (c) 2011-2019 Canonical Ltd
39 |
40 | Licensed under the Apache License, Version 2.0 (the "License");
41 | you may not use this file except in compliance with the License.
42 | You may obtain a copy of the License at
43 |
44 | http://www.apache.org/licenses/LICENSE-2.0
45 |
46 | Unless required by applicable law or agreed to in writing, software
47 | distributed under the License is distributed on an "AS IS" BASIS,
48 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49 | See the License for the specific language governing permissions and
50 | limitations under the License.
51 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v3/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright 2011-2016 Canonical Ltd.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v3/writerc.go:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2011-2019 Canonical Ltd
3 | // Copyright (c) 2006-2010 Kirill Simonov
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | // this software and associated documentation files (the "Software"), to deal in
7 | // the Software without restriction, including without limitation the rights to
8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 | // of the Software, and to permit persons to whom the Software is furnished to do
10 | // 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 |
23 | package yaml
24 |
25 | // Set the writer error and return false.
26 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
27 | emitter.error = yaml_WRITER_ERROR
28 | emitter.problem = problem
29 | return false
30 | }
31 |
32 | // Flush the output buffer.
33 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
34 | if emitter.write_handler == nil {
35 | panic("write handler not set")
36 | }
37 |
38 | // Check if the buffer is empty.
39 | if emitter.buffer_pos == 0 {
40 | return true
41 | }
42 |
43 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
44 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
45 | }
46 | emitter.buffer_pos = 0
47 | return true
48 | }
49 |
--------------------------------------------------------------------------------
/vendor/modules.txt:
--------------------------------------------------------------------------------
1 | # github.com/DATA-DOG/go-sqlmock v1.5.0
2 | ## explicit
3 | github.com/DATA-DOG/go-sqlmock
4 | # github.com/davecgh/go-spew v1.1.1
5 | ## explicit
6 | github.com/davecgh/go-spew/spew
7 | # github.com/denisenkom/go-mssqldb v0.12.3
8 | ## explicit; go 1.13
9 | github.com/denisenkom/go-mssqldb
10 | github.com/denisenkom/go-mssqldb/internal/cp
11 | github.com/denisenkom/go-mssqldb/internal/decimal
12 | github.com/denisenkom/go-mssqldb/internal/querytext
13 | github.com/denisenkom/go-mssqldb/msdsn
14 | # github.com/go-sql-driver/mysql v1.7.1
15 | ## explicit; go 1.13
16 | github.com/go-sql-driver/mysql
17 | # github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9
18 | ## explicit
19 | github.com/golang-sql/civil
20 | # github.com/golang-sql/sqlexp v0.1.0
21 | ## explicit; go 1.16
22 | github.com/golang-sql/sqlexp
23 | # github.com/lib/pq v1.10.9
24 | ## explicit; go 1.13
25 | github.com/lib/pq
26 | github.com/lib/pq/oid
27 | github.com/lib/pq/scram
28 | # github.com/mattn/go-sqlite3 v1.14.17
29 | ## explicit; go 1.16
30 | github.com/mattn/go-sqlite3
31 | # github.com/pmezard/go-difflib v1.0.0
32 | ## explicit
33 | github.com/pmezard/go-difflib/difflib
34 | # github.com/stretchr/objx v0.5.0
35 | ## explicit; go 1.12
36 | github.com/stretchr/objx
37 | # github.com/stretchr/testify v1.8.4
38 | ## explicit; go 1.20
39 | github.com/stretchr/testify/assert
40 | github.com/stretchr/testify/mock
41 | github.com/stretchr/testify/require
42 | github.com/stretchr/testify/suite
43 | # golang.org/x/crypto v0.11.0
44 | ## explicit; go 1.17
45 | golang.org/x/crypto/md4
46 | # gopkg.in/yaml.v3 v3.0.1
47 | ## explicit
48 | gopkg.in/yaml.v3
49 |
--------------------------------------------------------------------------------