These aren't ready yet :)
To test the bindings you'll need to get into postgres as a superuser and create a user
Here's what my session looked like
~$ psql psql (9.1.1) Type "help" for help. postgres=# CREATE USER rustuser WITH PASSWORD 'rustpass'; CREATE ROLE postgres=# CREATE DATABASE rust_test_db; CREATE DATABASE
totally up in the air, I'm still learning rust. If you see something obviously brain dead please make an issue.
#[test] fn AlgebraTest() { // grab a connection let conn = TestConnect(); // define a person let person = Table("person", [ ("did", [Unique], SerialM), ("name", [Insert], VarCharM(255)) ]); // define a movie let movie = Table("movie_algebra", [ ("did", [Unique], SerialM), ("title", [Insert], VarCharM(255)), ("year", [Insert], Int32M), ("director", [Insert, ForeignKey(copy person, "did")], Int32M ) ]); // Drop some tables, just in case they're there. Assure(conn.Exec(DropTable(person))); Assure(conn.Exec(DropTable(movie))); // Create some tables Assure(conn.Exec(CreateTable(person))); Assure(conn.Exec(CreateTable(movie))); // Test the fancy insert. let q1 = person.Insert( [VarChar("lucas")] ); assert q1 == "insert into person (name) VALUES ('lucas')"; Assure(conn.Exec(q1)); unsafe { // no fancy select yet. // Grab the person.did of lucas let res = Assure(conn.Exec("select * from person where name = 'lucas'")); let lucas_did = copy GetRow(res, 0)[0]; // this index munging goes away // let q2 = movie.Insert( [VarChar("starwars"), Int32(1977), lucas_did]); assert q2 == "insert into movie_algebra (title,year,director) VALUES ('starwars',1977,1)"; Assure(conn.Exec(q2)); }
If postgres is setup correctly and rustc can find your libpq then you might be able to get the following output
$ rustc --bin pq.rc --test -W no-old-vecs && ./pq ... result: ok. 22 passed; 0 failed; 0 ignored