Skip to content

Commit

Permalink
Release v1.17.6
Browse files Browse the repository at this point in the history
- Fix a bug in REPLACE query. ([GitHub #79](#79))
  • Loading branch information
mithrandie committed Jun 30, 2022
2 parents 983ca8d + 6932a36 commit 4442b67
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## Version 1.17.6

Released on Jun 30, 2022

- Fix a bug in REPLACE query. ([GitHub #79](https://github.com/mithrandie/csvq/issues/79))

## Version 1.17.5

Released on Jun 26, 2022
Expand Down
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ title: Change Log - csvq

# Change Log

## Version 1.17.6

Released on Jun 30, 2022

- Fix a bug in REPLACE query. ([GitHub #79](https://github.com/mithrandie/csvq/issues/79))

## Version 1.17.5

Released on Jun 26, 2022
Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ In the multiple operations, you can use variables, cursors, temporary tables, an

## Latest Release

Version 1.17.5
: Released on Jun 26, 2022
Version 1.17.6
: Released on Jun 30, 2022

<a class="waves-effect waves-light btn" href="https://github.com/mithrandie/csvq/releases/tag/v1.17.5">
<a class="waves-effect waves-light btn" href="https://github.com/mithrandie/csvq/releases/tag/v1.17.6">
<i class="material-icons left">file_download</i>download
</a>

Expand Down
4 changes: 2 additions & 2 deletions docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>https://mithrandie.github.io/csvq/</loc>
<lastmod>2022-06-26T02:35:14+00:00</lastmod>
<lastmod>2022-06-30T13:40:41+00:00</lastmod>
</url>
<url>
<loc>https://mithrandie.github.io/csvq/reference.html</loc>
Expand Down Expand Up @@ -178,7 +178,7 @@
</url>
<url>
<loc>https://mithrandie.github.io/csvq/changelog.html</loc>
<lastmod>2022-06-26T02:35:14+00:00</lastmod>
<lastmod>2022-06-30T13:40:41+00:00</lastmod>
</url>
<url>
<loc>https://mithrandie.github.io/csvq/license.html</loc>
Expand Down
1 change: 1 addition & 0 deletions lib/query/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func setup() {
_ = copyfile(filepath.Join(TestDir, "rename_column.csv"), filepath.Join(TestDataDir, "table1.csv"))
_ = copyfile(filepath.Join(TestDir, "updated_file_1.csv"), filepath.Join(TestDataDir, "table1.csv"))
_ = copyfile(filepath.Join(TestDir, "dup_name.csv"), filepath.Join(TestDataDir, "dup_name.csv"))
_ = copyfile(filepath.Join(TestDir, "table_empty.csv"), filepath.Join(TestDataDir, "table_empty.csv"))

_ = copyfile(filepath.Join(TestDir, "table3.tsv"), filepath.Join(TestDataDir, "table3.tsv"))
_ = copyfile(filepath.Join(TestDir, "dup_name.tsv"), filepath.Join(TestDataDir, "dup_name.tsv"))
Expand Down
51 changes: 51 additions & 0 deletions lib/query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2426,6 +2426,57 @@ var replaceTests = []struct {
},
}),
},
{
Name: "Replace Query to Empty Table",
Query: parser.ReplaceQuery{
Table: parser.Table{Object: parser.Identifier{Literal: "table_empty"}},
Fields: []parser.QueryExpression{
parser.FieldReference{Column: parser.Identifier{Literal: "column1"}},
parser.FieldReference{Column: parser.Identifier{Literal: "column2"}},
},
Keys: []parser.QueryExpression{
parser.FieldReference{Column: parser.Identifier{Literal: "column1"}},
},
ValuesList: []parser.QueryExpression{
parser.RowValue{
Value: parser.ValueList{
Values: []parser.QueryExpression{
parser.NewIntegerValueFromString("4"),
parser.NewStringValue("str4"),
},
},
},
},
},
ResultFile: &FileInfo{
Path: GetTestFilePath("table_empty.csv"),
Delimiter: ',',
NoHeader: false,
Encoding: text.UTF8,
LineBreak: text.LF,
ForUpdate: true,
},
UpdateCount: 1,
ViewCache: GenerateViewMap([]*View{
{
FileInfo: &FileInfo{
Path: GetTestFilePath("table_empty.csv"),
Delimiter: ',',
NoHeader: false,
Encoding: text.UTF8,
LineBreak: text.LF,
ForUpdate: true,
},
Header: NewHeader("table_empty", []string{"column1", "column2"}),
RecordSet: []Record{
NewRecord([]value.Primary{
value.NewInteger(4),
value.NewString("str4"),
}),
},
},
}),
},
{
Name: "Replace Query For Temporary View",
Query: parser.ReplaceQuery{
Expand Down
2 changes: 1 addition & 1 deletion lib/query/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package query

var Version = "v1.17.5"
var Version = "v1.17.6"
2 changes: 1 addition & 1 deletion lib/query/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -2222,7 +2222,7 @@ func (view *View) replace(ctx context.Context, flags *cmd.Flags, fields []parser
return 0, err
}

sortValuesInInsertRecords := make([]SortValues, view.RecordLen())
sortValuesInInsertRecords := make([]SortValues, len(records))
if err := NewGoroutineTaskManager(len(records), -1, flags.CPU).Run(ctx, func(index int) error {
sortValues := make(SortValues, len(keyIndices))
for j, idx := range keyIndices {
Expand Down
1 change: 1 addition & 0 deletions testdata/csv/table_empty.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
column1,column2

0 comments on commit 4442b67

Please sign in to comment.