Skip to content

Commit

Permalink
test settings binds directly
Browse files Browse the repository at this point in the history
  • Loading branch information
m-barthelemy committed Apr 5, 2020
1 parent 0602485 commit aeaed52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions Sources/QueuesFluentDriver/FluentQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ extension FluentQueue: Queue {
.select ()
.column ("\(Self.model.$id.key)")
.from (JobModel.schema)
.where ("\(Self.model.$state.key)", SQLBinaryOperator.equal, JobState.pending)
//.where ("\(Self.model.$state.key)", SQLBinaryOperator.equal, JobState.pending)
.where("\(Self.model.$state.key)", SQLBinaryOperator.equal, SQLBind.init(JobState.pending))
.orderBy("\(Self.model.$createdAt.path.first!)")
.limit (1)

Expand All @@ -110,8 +111,10 @@ extension FluentQueue: Queue {

let query = db
.update(JobModel.schema)
.set("\(Self.model.$state.key)", to: JobState.processing)
.set("\(Self.model.$updatedAt.path.first!)", to: Date())
//.set("\(Self.model.$state.key)", to: JobState.processing)
.set(SQLColumn.init("\(Self.model.$state.key)"), to: SQLBind.init(JobState.processing))
//.set("\(Self.model.$updatedAt.path.first!)", to: Date())
.set(SQLColumn.init("\(Self.model.$updatedAt.path.first!)"), to: SQLBind.init(Date()))
.where(
SQLBinaryExpression(left: SQLColumn("\(Self.model.$id.key)"), op: SQLBinaryOperator.equal , right: subQueryGroup)
)
Expand Down
4 changes: 2 additions & 2 deletions Sources/QueuesFluentDriver/SQLDatabase+query.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ struct sqlCache{
extension SQLDatabase {
func query(db: SQLDatabase, sql: String, binds: [Encodable] = []) -> SQLRawBuilder {
var sql = sql
if(sqlCache.cache.keys.contains(sql)) {
/*if(sqlCache.cache.keys.contains(sql)) {
print("•••• Using SQL cache!")
}
else {
sqlCache.cache[sql] = prepareSql(sql: sql, binds: binds).1
}
}*/
var bindPos = 0
binds.forEach {
bindPos += 1
Expand Down

0 comments on commit aeaed52

Please sign in to comment.