Skip to content

Instantly share code, notes, and snippets.

/sql.pl Secret

Created December 31, 2014 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2397c84a89af1e4dfd06 to your computer and use it in GitHub Desktop.
Save anonymous/2397c84a89af1e4dfd06 to your computer and use it in GitHub Desktop.
# A (original)
my $db = $self->pg->db;
return $db->query(
"insert into minion_jobs
(args, created, delayed, priority, retries, state, task)
values
(?, now(), (now() + (interval '1 second' * ?)), ?, ?, ?, ?)
returning id", encode_json($args), $options->{delay} // 0,
$options->{priority} // 0, 0, 'inactive', $task
)->hash->{id};
# B
my $db = $self->pg->db;
$db->json($args)->val(
$options->{delay} // 0,
$options->{priority} // 0,
0, 'inactive', $task
);
return $db->query(
"insert into minion_jobs
(args, created, delayed, priority, retries, state, task)
values
(?, now(), (now() + (interval '1 second' * ?)), ?, ?, ?, ?)
returning id"
)->hash->{id};
# C
my $db = $self->pg->db;
my $sql = $db->sql(
"insert into minion_jobs
(args, created, delayed, priority, retries, state, task)
values
(?, now(), (now() + (interval '1 second' * ?)), ?, ?, ?, ?)
returning id"
);
$sql->json($args)->val(
$options->{delay} // 0,
$options->{priority} // 0,
0, 'inactive', $task
);
return $sql->run->hash->{id};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment