Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ The following options are available:
`emitColumns`
: When `true`, the column names in the `SELECT` statement are emitted as the first tuple in the resulting channel.

`trailingSemicolon`
: WHen `true`, append a semicolon `;` to the end of the SQL query if it is not present (default: `true`).

### sqlInsert

The `sqlInsert` operator collects the items in a source channel and inserts them into a SQL database. For example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class ChannelSqlExtension extends PluginExtensionPoint {
db: CharSequence,
emitColumns: Boolean,
batchSize: Integer,
batchDelay: Integer
batchDelay: Integer,
trailingSemicolon: Boolean
]

private static final Map INSERT_PARAMS = [
Expand Down
5 changes: 4 additions & 1 deletion plugins/nf-sqldb/src/main/nextflow/sql/QueryHandler.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class QueryHandler implements QueryOp<QueryHandler> {
private boolean emitColumns = false
private Integer batchSize
private long batchDelayMillis = 100
private boolean trailingSemicolon = true
private int queryCount

@Override
Expand Down Expand Up @@ -97,6 +98,8 @@ class QueryHandler implements QueryOp<QueryHandler> {
this.batchSize = opts.batchSize as Integer
if( opts.batchDelay )
this.batchDelayMillis = opts.batchDelay as long
if( opts.trailingSemicolon )
this.trailingSemicolon = opts.trailingSemicolon as boolean
return this
}

Expand Down Expand Up @@ -127,7 +130,7 @@ class QueryHandler implements QueryOp<QueryHandler> {
if( !q )
throw new IllegalArgumentException("Missing query argument")
def result = q.trim()
if( !result.endsWith(';') )
if( trailingSemicolon && !result.endsWith(';') )
result += ';'
return result
}
Expand Down