Skip to content

Commit

Permalink
forward port from v1.0.0 to v2-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
noborus committed Jun 24, 2024
1 parent 06b4c0d commit b77192d
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 89 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For usage as a library, please refer to the [godoc](https://pkg.go.dev/github.co
* 3.3. [Output formats](#output-formats)
* 3.3.1. [Output options](#output-options)
* 3.4. [Handling of NULL](#handling-of-null)
* 3.5. [Multiple queries (v0.20.0 or later)](#multiple-queries-(v0.20.0-or-later))
* 3.5. [Multiple queries](#multiple-queries)
* 4. [Example](#example)
* 4.1. [STDIN input](#stdin-input)
* 4.2. [Multiple files](#multiple-files)
Expand Down Expand Up @@ -257,7 +257,7 @@ $ echo '[1,null,""]' | trdsql -inull "" -ojson -ijson "SELECT * FROM -"
]
```

### 3.5. <a name='multiple-queries-(v0.20.0-or-later)'></a>Multiple queries (v0.20.0 or later)
### 3.5. <a name='multiple-queries'></a>Multiple queries

Multiple queries can be executed by separating them with a semicolon.
Update queries must be followed by a SELECT statement.
Expand Down Expand Up @@ -1061,7 +1061,7 @@ C:\Users\{"User"}\AppData\Roaming\trdsql\config.json
Or use the -config file option.

```console
$ trdsql -config config.json "SELECT * FROM test.csv"
trdsql -config config.json "SELECT * FROM test.csv"
```

sample: [config.json](config.json.sample)
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ require (
github.com/go-sql-driver/mysql v1.8.1
github.com/goccy/go-yaml v1.11.3
github.com/iancoleman/orderedmap v0.3.0
github.com/itchyny/gojq v0.12.15
github.com/itchyny/gojq v0.12.16
github.com/jwalton/gchalk v1.3.0
github.com/klauspost/compress v1.17.8
github.com/klauspost/compress v1.17.9
github.com/lib/pq v1.10.9
github.com/mattn/go-runewidth v0.0.15
github.com/mattn/go-sqlite3 v1.14.22
Expand All @@ -20,21 +20,21 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/viper v1.18.2
github.com/ulikunitz/xz v0.5.12
golang.org/x/term v0.19.0
modernc.org/sqlite v1.29.8
golang.org/x/term v0.21.0
modernc.org/sqlite v1.30.1
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/itchyny/timefmt-go v0.1.5 // indirect
github.com/itchyny/timefmt-go v0.1.6 // indirect
github.com/jwalton/go-supportscolor v1.2.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand All @@ -53,16 +53,16 @@ require (
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gonum.org/v1/gonum v0.15.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b // indirect
modernc.org/libc v1.50.4 // indirect
modernc.org/libc v1.53.3 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/strutil v1.2.0 // indirect
Expand Down
58 changes: 30 additions & 28 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/dsnet/compress v0.0.1/go.mod h1:Aw8dCMJ7RioblQeTqt88akK31OvO8Dhf5Jflh
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
Expand Down Expand Up @@ -42,18 +42,18 @@ github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJ
github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE=
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/itchyny/gojq v0.12.15 h1:WC1Nxbx4Ifw5U2oQWACYz32JK8G9qxNtHzrvW4KEcqI=
github.com/itchyny/gojq v0.12.15/go.mod h1:uWAHCbCIla1jiNxmeT5/B5mOjSdfkCq6p8vxWg+BM10=
github.com/itchyny/timefmt-go v0.1.5 h1:G0INE2la8S6ru/ZI5JecgyzbbJNs5lG1RcBqa7Jm6GE=
github.com/itchyny/timefmt-go v0.1.5/go.mod h1:nEP7L+2YmAbT2kZ2HfSs1d8Xtw9LY8D2stDBckWakZ8=
github.com/itchyny/gojq v0.12.16 h1:yLfgLxhIr/6sJNVmYfQjTIv0jGctu6/DgDoivmxTr7g=
github.com/itchyny/gojq v0.12.16/go.mod h1:6abHbdC2uB9ogMS38XsErnfqJ94UlngIJGlRAIj4jTM=
github.com/itchyny/timefmt-go v0.1.6 h1:ia3s54iciXDdzWzwaVKXZPbiXzxxnv1SPGFfM/myJ5Q=
github.com/itchyny/timefmt-go v0.1.6/go.mod h1:RRDZYC5s9ErkjQvTvvU7keJjxUYzIISJGxm9/mAERQg=
github.com/jwalton/gchalk v1.3.0 h1:uTfAaNexN8r0I9bioRTksuT8VGjrPs9YIXR1PQbtX/Q=
github.com/jwalton/gchalk v1.3.0/go.mod h1:ytRlj60R9f7r53IAElbpq4lVuPOPNg2J4tJcCxtFqr8=
github.com/jwalton/go-supportscolor v1.1.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
github.com/jwalton/go-supportscolor v1.2.0 h1:g6Ha4u7Vm3LIsQ5wmeBpS4gazu0UP1DRDE8y6bre4H8=
github.com/jwalton/go-supportscolor v1.2.0/go.mod h1:hFVUAZV2cWg+WFFC4v8pT2X/S2qUUBYMioBD9AINXGs=
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU=
github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
Expand Down Expand Up @@ -142,33 +142,35 @@ go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic=
golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q=
golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk=
golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA=
golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw=
golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gonum.org/v1/gonum v0.15.0 h1:2lYxjRbTYyxkJxlhC+LvJIx3SsANPdRybu1tGj9/OrQ=
Expand All @@ -181,18 +183,18 @@ gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/cc/v4 v4.21.0 h1:D/gLKtcztomvWbsbvBKo3leKQv+86f+DdqEZBBXhnag=
modernc.org/cc/v4 v4.21.0/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
modernc.org/ccgo/v4 v4.17.3 h1:t2CQci84jnxKw3GGnHvjGKjiNZeZqyQx/023spkk4hU=
modernc.org/ccgo/v4 v4.17.3/go.mod h1:1FCbAtWYJoKuc+AviS+dH+vGNtYmFJqBeRWjmnDWsIg=
modernc.org/cc/v4 v4.21.3 h1:2mhBdWKtivdFlLR1ecKXTljPG1mfvbByX7QKztAIJl8=
modernc.org/cc/v4 v4.21.3/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
modernc.org/ccgo/v4 v4.18.1 h1:1zF5kPBFq/ZVTulBOKgQPQITdOzzyBUfC51gVYP62E4=
modernc.org/ccgo/v4 v4.18.1/go.mod h1:ao1fAxf9a2KEOL15WY8+yP3wnpaOpP/QuyFOZ9HJolM=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw=
modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b h1:BnN1t+pb1cy61zbvSUV7SeI0PwosMhlAEi/vBY4qxp8=
modernc.org/gc/v3 v3.0.0-20240304020402-f0dba7c97c2b/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
modernc.org/libc v1.50.4 h1:GeqBes21PQHbVitLewzkhLXLFnQ1AWxOlHI+g5InUnQ=
modernc.org/libc v1.50.4/go.mod h1:rhzrUx5oePTSTIzBgM0mTftwWHK8tiT9aNFUt1mldl0=
modernc.org/libc v1.53.3 h1:9O0aSLZuHPgp49we24NoFFteRgXNLGBAQ3TODrW3XLg=
modernc.org/libc v1.53.3/go.mod h1:kb+Erju4FfHNE59xd2fNpv5CBeAeej6fHbx8p8xaiyI=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
Expand All @@ -201,8 +203,8 @@ modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
modernc.org/sqlite v1.29.8 h1:nGKglNx9K5v0As+zF0/Gcl1kMkmaU1XynYyq92PbsC8=
modernc.org/sqlite v1.29.8/go.mod h1:lQPm27iqa4UNZpmr4Aor0MH0HkCLbt1huYDfWylLZFk=
modernc.org/sqlite v1.30.1 h1:YFhPVfu2iIgUf9kuA1CR7iiHdcEEsI2i+yjRYHscyxk=
modernc.org/sqlite v1.30.1/go.mod h1:DUmsiWQDaAvU4abhc/N+djlom/L2o8f7gZ95RCvyoLU=
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
Expand Down
3 changes: 1 addition & 2 deletions input_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ func NewCSVReader(reader io.Reader, opts *ReadOpts) (*CSVReader, error) {
}
r.names = make([]string, len(row))
for i, col := range row {
r.names[i] = col
if col == "" {
r.names[i] = "c" + strconv.Itoa(i+1)
} else {
r.names[i] = col
}
}
preReadN--
Expand Down
6 changes: 1 addition & 5 deletions input_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ func (r *JSONReader) objectRow(obj map[string]any) (map[string]any, []string, er
row := make(map[string]any)
for k, v := range obj {
names = append(names, k)
if v == nil {
row[k] = nil
} else {
row[k] = r.jsonString(v)
}
row[k] = r.jsonString(v)
}
return row, names, nil
}
Expand Down
12 changes: 2 additions & 10 deletions input_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,7 @@ func (r *YAMLReader) objectRow(obj map[string]any) (map[string]any, []string, er
row := make(map[string]any)
for k, v := range obj {
names = append(names, k)
if v == nil {
row[k] = nil
} else {
row[k] = r.toString(v)
}
row[k] = r.toString(v)
}
return row, names, nil
}
Expand All @@ -257,11 +253,7 @@ func (r *YAMLReader) objectMapSlice(obj yaml.MapSlice) (map[string]any, []string
for _, item := range obj {
key := item.Key.(string)
names = append(names, key)
if item.Value == nil {
row[key] = nil
} else {
row[key] = r.toString(item.Value)
}
row[key] = r.toString(item.Value)
}
return row, names, nil
}
Expand Down
6 changes: 2 additions & 4 deletions output_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,17 @@ func NewCSVWriter(writeOpts *WriteOpts) *CSVWriter {
}
w.outDelimiter = d

w.outQuote = 0
if len(writeOpts.OutQuote) > 0 {
w.outQuote = ([]rune(writeOpts.OutQuote))[0]
} else {
w.outQuote = 0
}
w.outAllQuote = writeOpts.OutAllQuotes
w.outUseCRLF = writeOpts.OutUseCRLF
w.outHeader = writeOpts.OutHeader
w.needQuotes = string(w.outDelimiter) + string(w.outQuote) + "\r\n"
w.endLine = "\n"
if writeOpts.OutUseCRLF {
w.endLine = "\r\n"
} else {
w.endLine = "\n"
}
w.needNULL = writeOpts.OutNeedNULL
w.outNULL = writeOpts.OutNULL
Expand Down
2 changes: 1 addition & 1 deletion output_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func isJSON(s []byte) bool {
return err == nil
}

// PostWrite is Actual output.
// PostWrite is actual output.
func (w *JSONWriter) PostWrite() error {
return w.writer.Encode(w.results)
}
6 changes: 2 additions & 4 deletions output_ltsv.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (w *LTSVWriter) PreWrite(columns []string, types []string) error {
return nil
}

// WriteRow is row write.
// WriteRow is row write to LTSV.
func (w *LTSVWriter) WriteRow(values []any, labels []string) error {
for n, col := range values {
if n > 0 {
Expand All @@ -44,11 +44,9 @@ func (w *LTSVWriter) WriteRow(values []any, labels []string) error {
return err
}

str := ""
str := ValString(col)
if col == nil && w.needNULL {
str = w.outNULL
} else {
str = ValString(col)
}
if _, err := w.writer.WriteString(str); err != nil {
return err
Expand Down
7 changes: 2 additions & 5 deletions output_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ func NewRAWWriter(writeOpts *WriteOpts) *RAWWriter {
w.writer = bufio.NewWriter(writeOpts.OutStream)
w.delimiter = delimiter
w.outHeader = writeOpts.OutHeader
w.endLine = "\n"
if writeOpts.OutUseCRLF {
w.endLine = "\r\n"
} else {
w.endLine = "\n"
}
w.needNULL = writeOpts.OutNeedNULL
w.outNULL = writeOpts.OutNULL
Expand Down Expand Up @@ -63,11 +62,9 @@ func (w *RAWWriter) WriteRow(values []any, _ []string) error {
return err
}
}
str := ""
str := ValString(col)
if col == nil && w.needNULL {
str = w.outNULL
} else {
str = ValString(col)
}
if _, err := w.writer.WriteString(str); err != nil {
return err
Expand Down
12 changes: 5 additions & 7 deletions output_tablewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,20 @@ func (w *TWWriter) PreWrite(columns []string, types []string) error {
// WriteRow is Addition to array.
func (w *TWWriter) WriteRow(values []any, columns []string) error {
for i, col := range values {
str := ""
str := ValString(col)
if w.markdown {
str = strings.ReplaceAll(str, `|`, `\|`)
}
if col == nil && w.needNULL {
str = w.outNULL
} else {
str = ValString(col)
if w.markdown {
str = strings.ReplaceAll(str, `|`, `\|`)
}
}
w.results[i] = str
}
w.writer.Append(w.results)
return nil
}

// PostWrite is Actual output.
// PostWrite is actual output.
func (w *TWWriter) PostWrite() error {
w.writer.Render()
return nil
Expand Down
4 changes: 1 addition & 3 deletions output_tbln.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,9 @@ func (w *TBLNWriter) PreWrite(columns []string, types []string) error {
// WriteRow is row write.
func (w *TBLNWriter) WriteRow(values []any, columns []string) error {
for i, col := range values {
str := ""
str := ValString(col)
if col == nil && w.needNULL {
str = w.outNULL
} else {
str = ValString(col)
}
w.results[i] = strings.ReplaceAll(str, "\n", "\\n")
}
Expand Down
6 changes: 2 additions & 4 deletions output_vertical.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (w *VFWriter) PreWrite(columns []string, types []string) error {
return nil
}

// WriteRow is Actual output.
// WriteRow is actual output.
func (w *VFWriter) WriteRow(values []any, columns []string) error {
w.count++
_, err := fmt.Fprintf(w.writer,
Expand All @@ -58,11 +58,9 @@ func (w *VFWriter) WriteRow(values []any, columns []string) error {
}
for i, col := range w.header {
v := w.hSize - runewidth.StringWidth(col)
str := ""
str := ValString(values[i])
if values[i] == nil && w.needNULL {
str = w.outNULL
} else {
str = ValString(values[i])
}

_, err := fmt.Fprintf(w.writer,
Expand Down
Loading

0 comments on commit b77192d

Please sign in to comment.