error when working with postgres
ccurvey - February 9, 2009 - 15:04
| Project: | Shoutbox |
| Version: | 6.x-1.0 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | disterics |
| Status: | active |
Jump to:
Description
If you try to use shoutbox with Postgres (at least version 8.3), shouts are not created (you get a listing of n/a) when you create them, and trying to "list all shouts" gives you an error of:
* warning: pg_query() [function.pg-query]: Query failed: ERROR: null value in column "hostname" violates not-null constraint in /home/chris/vijay/includes/database.pgsql.inc on line 139.
* user warning: query: INSERT INTO shoutbox (uid, nick, shout, url, moderate, created, changed, sid) VALUES (1, 'admin', 'I''m in charge here', 'www.chriscurvey.com', 0, 1234191751, 1234191751, '0e60b7b30e18414721c99e68c217712f') in /home/chris/vijay/sites/all/modules/shoutbox/shoutbox.module on line 27.My solution to the problem was to make the "hostname" field nullable at line 666 in shoutbox.install. I guess another (maybe better) solution would be to add a default to that field.

#1
Will fix this in the next release.
#2
I change shoutbox.module, line 666 to:
db_query("INSERT INTO {shoutbox} (uid, nick, shout, url, moderate, created, changed, hostname, sid) VALUES (%d, '%s', '%s', '%s', %d, %d, %d, '%s', '%s')", $user->uid, $form_state['values']['nick'], $form_state['values']['message'], $form_state['values']['url'], $moderate, $created, $created, ip_address(), session_id());I save ip_address() in that field, while the next version is realesed.
Thanks!!!
Alek
#3
Finally managed to install postgresql on my mac and reproduce the problem. Problem is, we no longer user the ip_address column but we were keeping it to help identify anonymous users from previous versions.
I will update the schema to exclude this column and delete it from old installs.