Bug 11391 - suggestions.suggesteddate has a problematic default value
Summary: suggestions.suggesteddate has a problematic default value
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Galen Charlton
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 7365 13012
  Show dependency treegraph
 
Reported: 2013-12-13 00:54 UTC by Galen Charlton
Modified: 2015-06-04 23:23 UTC (History)
1 user (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 11391: drop default value on suggestions.suggesteddate column (2.75 KB, patch)
2013-12-13 01:16 UTC, Galen Charlton
Details | Diff | Splinter Review
Bug 11391: (follow-up) update DBIC schema classes (1.97 KB, patch)
2013-12-13 01:16 UTC, Galen Charlton
Details | Diff | Splinter Review
Bug 11391: drop default value on suggestions.suggesteddate column (2.92 KB, patch)
2013-12-22 21:59 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 11391: (follow-up) update DBIC schema classes (2.02 KB, patch)
2013-12-22 22:00 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 11391: drop default value on suggestions.suggesteddate column (2.99 KB, patch)
2013-12-23 11:04 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 11391: (follow-up) update DBIC schema classes (2.08 KB, patch)
2013-12-23 11:04 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Galen Charlton 2013-12-13 00:54:21 UTC
The column suggesteddate in the suggestions table is currently defined as "date NOT NULL default 0".  When DBIx::Class translates that PostgreSQLese, it ends up as "date DEFAULT '0000-00-00' NOT NULL".  Since 0000-00-00 is not a valid date, DBIC will fail to deploy the suggestions table to a Pg database.

Since suggesteddate is supposed to be the date that the suggestion was submitted, CURRENT_DATE is a better default value regardless.
Comment 1 Galen Charlton 2013-12-13 01:01:15 UTC
Sadly, CURRENT_DATE itself cannot be used, as MySQL a non-constant default value only for timestamp columns.
Comment 2 Galen Charlton 2013-12-13 01:16:31 UTC Comment hidden (obsolete)
Comment 3 Galen Charlton 2013-12-13 01:16:39 UTC Comment hidden (obsolete)
Comment 4 Chris Cormack 2013-12-22 21:59:24 UTC Comment hidden (obsolete)
Comment 5 Chris Cormack 2013-12-22 22:00:42 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2013-12-23 11:04:15 UTC
Created attachment 23779 [details] [review]
Bug 11391: drop default value on suggestions.suggesteddate column

The 'default 0' clause got translated as an invalid constant
default of '0000-00-00' when DBIx::Schema is used to deploy
the suggestions table into a Pg database.  This patch drops
the default.

To test:

[1] Apply the patch and run the SQL specified in the database
    updated.
[2] Verify that the suggestions table no longer has an
    explicit default value for the suggesteddate column.
[3] Verify that prove -v t/db_dependent/Suggestions.t
    passes.
[4] Verify that installer/data/mysql/kohastructure.sql runs
    cleanly in an empty database.
[5] Verify that there are no visible regressions of the
    purchase suggestions functionality.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Having a default of 0 on a date seems like a mad thing to do anyway,
so good to get rid of it

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 7 Jonathan Druart 2013-12-23 11:04:22 UTC
Created attachment 23780 [details] [review]
Bug 11391: (follow-up) update DBIC schema classes

This patch updates the DBIC schema class for Suggestion
to reflect the dropped default value for the suggesteddate
column.

To test:

[1] Create an empty Pg database and use the deployment script
    being worked in in bug 11390.  The deployment shoudl
    succeed without reporting any errors regarding the
    suggestions table.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 8 Galen Charlton 2013-12-23 16:22:22 UTC
Pushed to master.
Comment 9 Fridolin Somers 2014-01-03 08:35:45 UTC
Patches pushed to 3.14.x, will be in 3.14.2.
(created version 3.14.01.003)