Skip to content

Commit

Permalink
fix: fix index store panic error (#2776)
Browse files Browse the repository at this point in the history
Signed-off-by: yisaer <[email protected]>
  • Loading branch information
Yisaer committed Apr 16, 2024
1 parent 32099b0 commit 1fab120
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
8 changes: 8 additions & 0 deletions extensions/sqldatabase/sqlgen/sqlServerDialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ func TestGenerateSQLWithMultiIndex(t *testing.T) {
},
sql: `select * from t where col2 > '2' AND col1 > '1' order by 'col2' ASC, 'col1' ASC limit 3`,
},
{
cfg: &InternalSqlQueryCfg{
Table: "t",
Limit: 3,
store: store.NewIndexFieldWrap(),
},
sql: `select * from t limit 3`,
},
}

for _, tc := range testcases {
Expand Down
4 changes: 1 addition & 3 deletions extensions/sqldatabase/sqlgen/sqlgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ func (i *InternalSqlQueryCfg) InitIndexFieldStore() {
i.store.Init(f)
return
}
if len(i.IndexFields) > 0 {
i.store.Init(i.IndexFields...)
}
i.store.Init(i.IndexFields...)
}

func (i *InternalSqlQueryCfg) SetIndexValue(v interface{}) {
Expand Down
4 changes: 1 addition & 3 deletions extensions/sqldatabase/sqlgen/templateSqlDialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ func (t *TemplateSqlQueryCfg) InitIndexFieldStore() {
t.store.Init(f)
return
}
if len(t.IndexFields) > 0 {
t.store.Init(t.IndexFields...)
}
t.store.Init(t.IndexFields...)
}

func (t *TemplateSqlQueryCfg) SetIndexValue(v interface{}) {
Expand Down
7 changes: 7 additions & 0 deletions extensions/sqldatabase/sqlgen/templateSqlDialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ func TestGenerateTemplateWithMultiIndex(t *testing.T) {
},
sql: "select * from table where col1 > `1` AND col2 > `2` order by co1 ASC, co2 ASC",
},
{
cfg: &TemplateSqlQueryCfg{
TemplateSql: "select * from table",
store: store.NewIndexFieldWrap(),
},
sql: "select * from table",
},
}

for _, tc := range testcases {
Expand Down

0 comments on commit 1fab120

Please sign in to comment.