Skip to content

Commit

Permalink
template: split used example (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelino committed Apr 10, 2019
1 parent 452f88e commit 34ba3b0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions content/executing-sql-scripts/_index.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ DELETE /_QUERIES/bar/some_delete?field1=foo

### Template functions

- *isSet* return true if param is set.

#### isSet
Return true if param is set.

```sql
SELECT * FROM table
Expand All @@ -87,14 +89,25 @@ WHERE name = "{{.field1}}"
;
```

- *defaultOrValue* return param value or default value.
#### defaultOrValue
Return param value or default value.

```sql
SELECT * FROM table WHERE name = '{{defaultOrValue "field1" "gopher"}}';
```

- *inFormat* if value of param is an slice this function format to an IN SQL clause.
#### inFormat
If value of param is an slice this function format to an IN SQL clause.

```sql
SELECT * FROM table WHERE name IN {{inFormat "field1"}};
```
```

#### split
Splits a string into substrings separated by a delimiter

```sql
SELECT * FROM table WHERE
name IN ({{ range $index,$part := split 'test1,test2,test3' `,` }}{{if gt $index 0 }},{{end}}'{{$part}}'{{ end }});

```

0 comments on commit 34ba3b0

Please sign in to comment.