Skip to content

Commit

Permalink
Fix broken row_eq() examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed Apr 10, 2012
1 parent fd43a10 commit 3a53e41
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -8,6 +8,8 @@ Revision history for pgTAP
[the report](https://github.com/theory/pgtap/issues/16). [the report](https://github.com/theory/pgtap/issues/16).
* Noted `pg_prove --verbose` for showing test descriptions and fixed a few * Noted `pg_prove --verbose` for showing test descriptions and fixed a few
typos in the documentation. Thanks to Jay Levitt for the pull request! typos in the documentation. Thanks to Jay Levitt for the pull request!
* Fixed broken examples in the `row_eq()` documentation. Thanks to @set5think
for the report!


0.90.0 2011-12-03T20:18:16Z 0.90.0 2011-12-03T20:18:16Z
--------------------------- ---------------------------
Expand Down
14 changes: 8 additions & 6 deletions doc/pgtap.mmd
Expand Up @@ -1559,7 +1559,7 @@ created composite types and table types are supported. Thus, you can do this:
name TEXT name TEXT
); );


SELECT row_eq( ROW(1, 'foo')::sometype, ROW(1, 'foo')::sometype ); SELECT row_eq( $$ SELECT 1, 'foo' $$, ROW(1, 'foo')::sometype );


And, of course, this: And, of course, this:


Expand All @@ -1569,20 +1569,22 @@ And, of course, this:
); );


INSERT INTO users VALUES (1, 'theory'); INSERT INTO users VALUES (1, 'theory');
PREPARE get_user AS SELECT * FROM users LIMIT 1;


SELECT row_eq( id, name), ROW(1, 'theory')::users ) SELECT row_eq( 'get_user', ROW(1, 'theory')::users );
FROM users;


Compatible types can be compared, though. So if the `users` table actually Compatible types can be compared, though. So if the `users` table actually
included an `active` column, for example, and you only wanted to test the included an `active` column, for example, and you only wanted to test the
`id` and `name`, you could do this: `id` and `name`, you could do this:


SELECT row_eq( id, name), ROW(1, 'theory')::sometype ) SELECT row_eq(
FROM users; $$ SELECT id, name FROM users $$,
ROW(1, 'theory')::sometype
);


Note the use of the `sometype` composite type for the second argument. The Note the use of the `sometype` composite type for the second argument. The
upshot is that you can create composite types in your tests explicitly for upshot is that you can create composite types in your tests explicitly for
comparing the rerutn values of your queries, if such queries don't return an comparing the return values of your queries, if such queries don't return an
existing valid type. existing valid type.


Hopefully someday in the future we'll be able to support arbitrary `record` Hopefully someday in the future we'll be able to support arbitrary `record`
Expand Down

0 comments on commit 3a53e41

Please sign in to comment.