]> git.evergreen-ils.org Git - working/Evergreen.git/commit
LP#1379815 Fetch tag data as a table using tag/xpath combo
authorDan Wells <dbw2@calvin.edu>
Mon, 6 Oct 2014 15:52:27 +0000 (11:52 -0400)
committerBen Shum <bshum@biblio.org>
Wed, 19 Aug 2015 16:13:50 +0000 (12:13 -0400)
commit55f4479eb3adeb2f67ab88b566d8fc7453bc3ed3
treea1cd8df44cb25322c3f9630b814ad2112e29b2d9
parent9e946f5af3be4ecfe7d694a902c5a2ce8f9a4d23
LP#1379815 Fetch tag data as a table using tag/xpath combo

New function: oils_xpath_tag_to_table()

This function is adapted from oils_xpath_table() with the goal of being
more targeted and simpler to use.

The main issue with oils_xpath_table() is that it relies on peer
UNNEST() functions, and that leads to unexpected behavior whenever the
xpath arguments result in uneven or "gapped" selections.  In the first
type of case, the resulting table includes rows representing the least
common multiple of the underlying xpath selections.  In the second
type, though the xpaths may sometimes return the same number of values,
those values are not correlated except by order in the marc, which does
not account for the real possibility of null values in the set.

Crude Example:

999 $d ABC $e 123
999 $d DEF
999 $d GHI
999 $e 456

We need a table representing subfields 'd' and 'e' of the '999' fields,
so we might try an xpath like:

//*[@tag="999"]/*[@code="d"]|//*[@tag="999"]/*[@code="e"]

We want:

 d  |  e
---------
ABC | 123
DEF |
GHI |
    | 456

but we get:

 d  |  e
---------
ABC | 123
DEF | 456
GHI | 123
ABC | 456
DEF | 123
GHI | 456

This example illustrates both negative behaviors (non-correlated fields
and least-common-multiple row multiplication).

The new method, while internally quite similar, has a different
signature, with the most significant change being a 'tag' argument
which serves as a common base element for the xpaths (now an array
rather than a pipe-delimited string).

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/sql/Pg/002.functions.config.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.function.vandelay-oils_xpath_tag_to_table.sql [new file with mode: 0644]