Skip to content

Commit

Permalink
Document need to quote index columns
Browse files Browse the repository at this point in the history
Due to the use of `pg_get_indexdef()`, which double-quotes them and we
simply compare them. Resolves #247.
  • Loading branch information
theory committed May 23, 2020
1 parent 99fdf94 commit 03636ae
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Revision history for pgTAP
* Added support for the date and time keywords `CURRENT_DATE`, `CURRENT_TIME`,
`CURRENT_TIMESTAMP`, `LOCALTIME`, and `LOCALTIMESTAMP` to `col_default_is()`.
Thanks to Kevin Brannen for the report (#244)!
* Fixed failure to run tests on Postgres 13. Thanks to Christoph Berg for the
report (#248).
* Documented that mixed-case column names created with double quotes
must be double-quoted when passed to `has_index()` or `is_indexed()`,
sadly unlike other column arguments in pgTAP. Thanks to Keith Fiske for
the report (#247).

1.1.0 2019-11-25T19:05:38Z
--------------------------
Expand Down
23 changes: 23 additions & 0 deletions doc/pgtap.mmd
Original file line number Diff line number Diff line change
Expand Up @@ -3517,6 +3517,20 @@ incorrect, the diagnostics will look more like this:
# have: "idx_baz" ON public.sometab(lower(name))
# want: "idx_baz" ON public.sometab(lower(lname))

Note that unlike most other column parameter arguments in pgTAP, mixed-case
column mames crated with double-quotes must be double-quoted when passed
to `has_index()`, like so:

SELECT has_index(
'myschema',
'sometable',
'myindex',
ARRAY[ 'id', '"Name"', 'lower("foo-bar")' ]
);

This caveat applies only to column names, not to table and schema names,
which should omit double-quoting.

### `hasnt_index()` ###

SELECT hasnt_index( schema, table, index, description );
Expand Down Expand Up @@ -5092,6 +5106,15 @@ index on the named table. Effectively like `has_index()` except that it
doesn't require an index name and does require one or more column names or
expressions in the defined for the index.

Note that unlike most other column parameter arguments in pgTAP, mixed-case
column mames crated with double-quotes must be double-quoted when passed
to `is_indexed()`, like so:

SELECT is_indexed( 'widgets', '"Name"' );

This caveat applies only to column names, not to table and schema names,
which should omit double-quoting.

### `index_is_type()` ###

SELECT index_is_type( :schema, :table, :index, :type, :description );
Expand Down

0 comments on commit 03636ae

Please sign in to comment.