Skip to content

Commit

Permalink
Release v1.17.10
Browse files Browse the repository at this point in the history
- Fix a bug when loading views from cache.
  • Loading branch information
mithrandie committed Aug 14, 2022
2 parents ceb66bf + fb4c747 commit 0f9b587
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 9 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.10

Released on Aug 14, 2022

- Fix a bug when loading views from cache.

## Version 1.17.9

Released on Aug 14, 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.10

Released on Aug 14, 2022

- Fix a bug when loading views from cache.

## Version 1.17.9

Released on Aug 14, 2022
Expand Down
4 changes: 2 additions & 2 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.9
Version 1.17.10
: Released on Aug 14, 2022

<a class="waves-effect waves-light btn" href="https://github.com/mithrandie/csvq/releases/tag/v1.17.9">
<a class="waves-effect waves-light btn" href="https://github.com/mithrandie/csvq/releases/tag/v1.17.10">
<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-08-14T06:12:34+00:00</lastmod>
<lastmod>2022-08-14T07:45:53+00:00</lastmod>
</url>
<url>
<loc>https://mithrandie.github.io/csvq/reference.html</loc>
Expand Down Expand Up @@ -182,7 +182,7 @@
</url>
<url>
<loc>https://mithrandie.github.io/csvq/changelog.html</loc>
<lastmod>2022-08-14T06:12:34+00:00</lastmod>
<lastmod>2022-08-14T07:45:53+00:00</lastmod>
</url>
<url>
<loc>https://mithrandie.github.io/csvq/license.html</loc>
Expand Down
2 changes: 1 addition & 1 deletion lib/query/built_in_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func ShowObjects(scope *ReferenceScope, expr parser.ShowObjects) (string, error)
createdFiles, updatedFiles := scope.Tx.UncommittedViews.UncommittedFiles()

for _, key := range keys {
if view, ok := scope.Tx.CachedViews.Load(key); ok {
if view, ok := scope.Tx.CachedViews.Load(strings.ToUpper(key)); ok {
fields := view.Header.TableColumnNames()
info := view.FileInfo
ufpath := strings.ToUpper(info.Path)
Expand Down
4 changes: 2 additions & 2 deletions lib/query/load_view.go
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ func cacheViewFromFile(

filePath, view, isCached, err := func() (string, *View, bool, error) {
if p, ok := scope.LoadFilePath(fileIdentifier.Literal); ok {
if v, ok := scope.Tx.CachedViews.Load(p); ok {
if v, ok := scope.Tx.CachedViews.Load(strings.ToUpper(p)); ok {
return p, v, true, nil
}
}
Expand All @@ -904,7 +904,7 @@ func cacheViewFromFile(
if e != nil {
return "", nil, false, e
}
v, ok := scope.Tx.CachedViews.Load(p)
v, ok := scope.Tx.CachedViews.Load(strings.ToUpper(p))
return p, v, ok, nil
}()
if err != nil {
Expand Down
46 changes: 46 additions & 0 deletions lib/query/load_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

var loadViewTests = []struct {
Name string
TestCache bool
Encoding text.Encoding
NoHeader bool
From parser.FromClause
Expand Down Expand Up @@ -144,6 +145,47 @@ var loadViewTests = []struct {
},
}}, time.Time{}, nil),
},
{
Name: "LoadView from Cached View",
TestCache: true,
From: parser.FromClause{
Tables: []parser.QueryExpression{
parser.Table{
Object: parser.Identifier{Literal: "table1"},
},
},
},
ForUpdate: true,
Result: &View{
Header: NewHeader("table1", []string{"column1", "column2"}),
RecordSet: []Record{
NewRecord([]value.Primary{
value.NewString("1"),
value.NewString("str1"),
}),
NewRecord([]value.Primary{
value.NewString("2"),
value.NewString("str2"),
}),
NewRecord([]value.Primary{
value.NewString("3"),
value.NewString("str3"),
}),
},
FileInfo: &FileInfo{
Path: "table1.csv",
Delimiter: ',',
Encoding: text.UTF8,
LineBreak: text.LF,
ForUpdate: true,
},
},
ResultScope: GenerateReferenceScope(nil, []map[string]map[string]interface{}{{
scopeNameAliases: {
"TABLE1": strings.ToUpper(GetTestFilePath("table1.csv")),
},
}}, time.Time{}, nil),
},
{
Name: "LoadView File with UTF-8 BOM",
From: parser.FromClause{
Expand Down Expand Up @@ -3189,6 +3231,10 @@ func TestLoadView(t *testing.T) {

queryScope := v.Scope.CreateNode()
view, err := LoadView(ctx, queryScope, v.From.Tables, v.ForUpdate, v.UseInternalId)
if v.TestCache {
queryScope.nodes[len(queryScope.nodes)-1].Clear()
view, err = LoadView(ctx, queryScope, v.From.Tables, v.ForUpdate, v.UseInternalId)
}

if err != nil {
if len(v.Error) < 1 {
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.9"
var Version = "v1.17.10"
2 changes: 1 addition & 1 deletion lib/terminal/completer_readline.go
Original file line number Diff line number Diff line change
Expand Up @@ -2129,7 +2129,7 @@ func (c *Completer) SearchAllTables(line string, _ string, _ int) readline.Candi
items := make([]string, 0, len(tableKeys)+len(files)+len(c.viewList))
tablePath := make(map[string]bool)
for _, k := range tableKeys {
if view, ok := c.scope.Tx.CachedViews.Load(k); ok {
if view, ok := c.scope.Tx.CachedViews.Load(strings.ToUpper(k)); ok {
lpath := view.FileInfo.Path
tablePath[lpath] = true
if filepath.Dir(lpath) == defaultDir {
Expand Down

0 comments on commit 0f9b587

Please sign in to comment.