Skip to content

Commit

Permalink
ADD resource list type condition.
Browse files Browse the repository at this point in the history
ADD resource list type condition.
  • Loading branch information
karminski committed Jan 23, 2024
1 parent 2059426 commit 22a4051
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/parser/sql/escaper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,15 @@ func TestEscapeMySQLSQLInStatementQueryInIntStringInUnsafeMode(t *testing.T) {
assert.Equal(t, []interface{}{}, usedArgs, "the usedArgs should be equal")
assert.Equal(t, "select * from users where id in ('a', 'b', 'c')", escapedSQL, "the token should be equal")
}

func TestEscapePostgresSQLAnyStatementQuery(t *testing.T) {
sql_1 := `select * from users where name = ANY('{{{multiselect1.value}}}')`
args := map[string]interface{}{
`multiselect1.value.map(b => Number(b))`: []interface{}{"a", "b", "c"},
}
sqlEscaper := NewSQLEscaper(resourcelist.TYPE_MYSQL_ID)
escapedSQL, usedArgs, errInEscape := sqlEscaper.EscapeSQLActionTemplate(sql_1, args, false)
assert.Nil(t, errInEscape)
assert.Equal(t, []interface{}{}, usedArgs, "the usedArgs should be equal")
assert.Equal(t, "select * from users where id in ('a', 'b', 'c')", escapedSQL, "the token should be equal")
}
4 changes: 4 additions & 0 deletions src/utils/resourcelist/resource_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var (
TYPE_ILLA_DRIVE = "illadrive"
TYPE_TRIGGER = "trigger"
TYPE_SERVER_SIDE_TRANSFORMER = "serversidetransformer"
TYPE_CONDITION = "condition"
)

var (
Expand Down Expand Up @@ -70,6 +71,7 @@ var (
TYPE_ILLA_DRIVE_ID = 30
TYPE_TRIGGER_ID = 31
TYPE_SERVER_SIDE_TRANSFORMER_ID = 32
TYPE_CONDITION_ID = 33
)

var type_array = []string{
Expand Down Expand Up @@ -106,6 +108,7 @@ var type_array = []string{
30: TYPE_ILLA_DRIVE,
31: TYPE_TRIGGER,
32: TYPE_SERVER_SIDE_TRANSFORMER,
33: TYPE_CONDITION,
}

var type_map = map[string]int{
Expand Down Expand Up @@ -142,6 +145,7 @@ var type_map = map[string]int{
TYPE_ILLA_DRIVE: TYPE_ILLA_DRIVE_ID,
TYPE_TRIGGER: TYPE_TRIGGER_ID,
TYPE_SERVER_SIDE_TRANSFORMER: TYPE_SERVER_SIDE_TRANSFORMER_ID,
TYPE_CONDITION: TYPE_CONDITION_ID,
}

var virtualResourceList = map[string]bool{
Expand Down

0 comments on commit 22a4051

Please sign in to comment.