Skip to content

Instantly share code, notes, and snippets.

@jeregrine
Created December 10, 2013 16:18
Show Gist options
  • Select an option

  • Save jeregrine/7893318 to your computer and use it in GitHub Desktop.

Select an option

Save jeregrine/7893318 to your computer and use it in GitHub Desktop.
defmodule PostgrexBugTest do
use ExUnit.Case, async: false
setup_all do
{ :ok, pid } = Postgrex.Connection.start_link([hostname: "localhost", username: "postgres", password: "postgres", database: "postgrex"])
Postgrex.Connection.query!(pid, "CREATE TABLE items(id serial primary key, value text, created timestamp default CURRENT_TIMESTAMP)")
{:ok, [pid: pid]}
end
teardown_all context do
Postgrex.Connection.query(context[:pid], "DROP TABLE items")
:ok
end
test "the parenthesis on insert breaking everything", context do
Postgrex.Connection.query!(context[:pid], "INSERT INTO items(value) VALUES('hello world') RETURNING (id)")
end
test "the parenthesis with multiple return on insert breaking everything", context do
Postgrex.Connection.query!(context[:pid], "INSERT INTO items(value) VALUES('hello world') RETURNING (id, created)")
end
test "single return on insert does not", context do
Postgrex.Connection.query!(context[:pid], "INSERT INTO items(value) VALUES('hello world') RETURNING id")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment