Opened 2 months ago
Last modified 2 weeks ago
#841 new defect
set_metadata unnecessarily strict in Perl bindings
| Reported by: | Eric Wong | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Xapian-bindings (Perl) | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Blocked By: | ||
| Blocking: | Operating System: | All |
Description
Calls which expect automatic integer to string conversion no longer works with the SWIG Xapian.pm bindings:
my $num = 6; $xdb->set_metadata("key", $num);
The old Search::Xapian bindings worked fine, and most Perl users expect auto-conversion from integers to strings. It would be easier for Perl users to auto-convert numeric values to the string type. Thanks.
Note:
See TracTickets
for help on using tickets.

I agree it's not very Perl-ish, but it is actually documented in the "COMPATIBILITY" section of
Xapian.pmfrom the newer bindings:This module is fussier about whether a passed scalar value is a string or an integer than Search::Xapian, so e.g. C<Xapian::Query-E<gt>new(2001)> will fail but the equivalent worked with Search::Xapian. If C<$term> might not be a string use C<Xapian::Query-E<gt>new("$term")> to ensure it is converted to a string. Whether explicit stringification is needed depends on whether the scalar is marked as having a string representation by Perl; prior to Perl 5.36.0 retrieving the string value of an integer could set this flag, but that's no longer the case in Perl 5.36.0 and later. The simple rule is to always explicitly stringify if the value might be numeric. This behaviour isn't very Perlish, but is likely to be hard to address universally as it comes from SWIG. Let us know if you find particular places where it's annoying and we can look at addressing those.