[Bug 27630] New: TestBuilder real number precision to use column's size
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Bug ID: 27630 Summary: TestBuilder real number precision to use column's size Change sponsored?: --- Product: Koha Version: unspecified Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Test Suite Assignee: chris@bigballofwax.co.nz Reporter: lari.taskula@hypernova.fi QA Contact: testopia@bugs.koha-community.org t::lib::TestBuilder::_gen_real() always returns 2 decimal places no matter the column's size definition.
TestBuilder.pm _gen_real() printf("%.2f", rand($max-0.1));
Our database has decimal type columns with higher than 2 decimal places. This makes comparing structures with Test::More::is_deeply impossible when the other object is built by TestBuilder, and the other fetched from database, as seen here: # Structures begin differing at: # $got->[0]{amount} = '90203.710000' # $expected->[0]{amount} = '90203.71' -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 --- Comment #1 from Lari Taskula <lari.taskula@hypernova.fi> --- Created attachment 116336 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116336&action=edit Bug 27630: Add tests To test: 1. prove t/db_dependent/TestBuilder.t 2. Observe failing test t/db_dependent/TestBuilder.t .. 3/13 Failed test 'There can be more decimals when the column size allows it.' at t/db_dependent/TestBuilder.t line 101. got: '67631.42' expected: '67631.420000' Looks like you failed 1 test of 4. Sponsored-by: The National Library of Finland -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 --- Comment #2 from Lari Taskula <lari.taskula@hypernova.fi> --- Created attachment 116337 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116337&action=edit Bug 27630: Allow more TestBuilder decimal places than 2 To test: 1. prove t/db_dependent/TestBuilder.t 2. Observe success Sponsored-by: The National Library of Finland -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|chris@bigballofwax.co.nz |lari.taskula@hypernova.fi -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA --- Comment #3 from Lari Taskula <lari.taskula@hypernova.fi> --- There's something I'm missing. When column type is "decimal", DBIx returns the trailing decimal zeroes, but when it's "float", it returns only the numbers until the significant precision. So if column size for decimals is 4, and the number being 1.0100, I get the following results from DBIx: decimal: 1.0100 float: 1.01 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 --- Comment #4 from Lari Taskula <lari.taskula@hypernova.fi> --- Created attachment 116340 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116340&action=edit Bug 27630: Add test to prove different behavior with floats To test: 1. prove t/db_dependent/TestBuilder.t 2. It might or might not pass all tests - if it passes, run it again until you get the following error (always with the "float" step): ok 5 - decimal - Builder builds same precision as DBIx returns. not ok 6 - float - Builder builds same precision as DBIx returns. Failed test 'float - Builder builds same precision as DBIx returns.' at t/db_dependent/TestBuilder.t line 112. got: '51.7080' expected: '51.708' Looks like you failed 1 test of 6. Sponsored-by: The National Library of Finland -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116340|0 |1 is obsolete| | --- Comment #5 from Lari Taskula <lari.taskula@hypernova.fi> --- Created attachment 116342 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116342&action=edit Bug 27630: Add test to prove different behavior with floats To test: 1. prove t/db_dependent/TestBuilder.t 2. It might or might not pass all tests - if it passes, run it again until you get the following error (always with either the "float" or "double" steps): ok 5 - decimal - Builder builds same precision as DBIx returns. not ok 6 - float - Builder builds same precision as DBIx returns. Failed test 'float - Builder builds same precision as DBIx returns.' at t/db_dependent/TestBuilder.t line 112. got: '51.7080' expected: '51.708' Looks like you failed 1 test of 7. Sponsored-by: The National Library of Finland -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |20028 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20028 [Bug 20028] Export all patron related personal data in one package -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|TestBuilder real number |TestBuilder real number |precision to use column's |formatting is different to |size |DBI(x) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 --- Comment #6 from Lari Taskula <lari.taskula@hypernova.fi> --- Could we re-fetch the generated TestBuilder object at the end of TestBuilder::_storeColumnValues() to make it identical with what Koha::Object / DBIx / DBI returns? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116342|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116337|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=20621 --- Comment #7 from Lari Taskula <lari.taskula@hypernova.fi> --- (In reply to Lari Taskula from comment #6)
Could we re-fetch the generated TestBuilder object at the end of TestBuilder::_storeColumnValues() to make it identical with what Koha::Object / DBIx / DBI returns? Related to Bug 20621
-- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116336|0 |1 is obsolete| | --- Comment #8 from Lari Taskula <lari.taskula@hypernova.fi> --- Created attachment 116426 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116426&action=edit Bug 27630: Add tests This proves different behavior between floats and decimals for values built by TestBuilder vs values returned by DBI/DBIx. To test: 1. prove t/db_dependent/TestBuilder.t 2. Observe failure Subtest: _gen_real formatting 1..4 not ok 1 - There can be more decimals when the column size allows it. Failed test 'There can be more decimals when the column size allows it.' at t/db_dependent/TestBuilder.t line 112. got: '10.10' expected: '10.100000' not ok 2 - decimal - Builder builds same format as DBIx returns. Failed test 'decimal - Builder builds same format as DBIx returns.' at t/db_dependent/TestBuilder.t line 118. got: '10.10' expected: '10.100000' not ok 3 - float - Builder builds same precision as DBIx returns. Failed test 'float - Builder builds same precision as DBIx returns.' at t/db_dependent/TestBuilder.t line 124. got: '10.10' expected: '10.1' not ok 4 - double - Builder builds same precision as DBIx returns. Failed test 'double - Builder builds same precision as DBIx returns.' at t/db_dependent/TestBuilder.t line 131. got: '10.10' expected: '10.1' Looks like you failed 4 tests of 4. not ok 4 - _gen_real formatting Failed test '_gen_real formatting' Sponsored-by: The National Library of Finland -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 --- Comment #9 from Lari Taskula <lari.taskula@hypernova.fi> --- Created attachment 116427 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116427&action=edit Bug 27630: Update database generated values and format in TestBuilder To test: 1. prove t/db_dependent/TestBuilder.t 2. Observe success TODO: Enable the commented-out test when statistics table gets a primary key Sponsored-by: The National Library of Finland -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116426|0 |1 is obsolete| | --- Comment #10 from David Nind <david@davidnind.com> --- Created attachment 116440 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116440&action=edit Bug 27630: Add tests This proves different behavior between floats and decimals for values built by TestBuilder vs values returned by DBI/DBIx. To test: 1. prove t/db_dependent/TestBuilder.t 2. Observe failure Subtest: _gen_real formatting 1..4 not ok 1 - There can be more decimals when the column size allows it. Failed test 'There can be more decimals when the column size allows it.' at t/db_dependent/TestBuilder.t line 112. got: '10.10' expected: '10.100000' not ok 2 - decimal - Builder builds same format as DBIx returns. Failed test 'decimal - Builder builds same format as DBIx returns.' at t/db_dependent/TestBuilder.t line 118. got: '10.10' expected: '10.100000' not ok 3 - float - Builder builds same precision as DBIx returns. Failed test 'float - Builder builds same precision as DBIx returns.' at t/db_dependent/TestBuilder.t line 124. got: '10.10' expected: '10.1' not ok 4 - double - Builder builds same precision as DBIx returns. Failed test 'double - Builder builds same precision as DBIx returns.' at t/db_dependent/TestBuilder.t line 131. got: '10.10' expected: '10.1' Looks like you failed 4 tests of 4. not ok 4 - _gen_real formatting Failed test '_gen_real formatting' Sponsored-by: The National Library of Finland Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #116427|0 |1 is obsolete| | --- Comment #11 from David Nind <david@davidnind.com> --- Created attachment 116441 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=116441&action=edit Bug 27630: Update database generated values and format in TestBuilder To test: 1. prove t/db_dependent/TestBuilder.t 2. Observe success TODO: Enable the commented-out test when statistics table gets a primary key Sponsored-by: The National Library of Finland Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #12 from David Nind <david@davidnind.com> --- Testing notes: - Applied first patch and ran tests, then applied second patch and ran tests - Tests pass as per the test plan -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Failed QA --- Comment #13 from Lari Taskula <lari.taskula@hypernova.fi> --- Jonathan suggested using build_object() instead of build(). It works in most cases. build_object() already refreshes the object because it executes a search on the given Koha-objects class, thus returning values in the same format that Koha::Objets->search/find would have. I found only two DBIx schema files that have decimal fields with higher number of allowed decimal places than two, and no corresponding Koha::Object. These are AqbudgetsPlanning and PendingOfflineOperation. So there are very few cases where build_object would not be sufficient to solve the decimal formatting issues. Additionally, as pointed out by Jonathan, we should be first study the side effects this patch would have on the total execution time of Koha test suite. I'm gonna mark this as Failed QA until we have those numbers. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27630 Lari Taskula <lari.taskula@hypernova.fi> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks|20028 | Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=20028 [Bug 20028] Export all patron related personal data in one package -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org