Subject: | MySQL 5.0.18, Views and Foreign Keys |
lloy0076@david:~/work/programming/pos$ mysql yb_pos_trans;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 80 to server version: 5.0.18-Debian_4-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
Show quoted text
mysql> describe product_incomplete;
+-------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------+---------------+------+-----+---------+-------+
| receipt_id | int(11) | YES | | NULL | |
| prod_id | int(11) | YES | | NULL | |
| barcode | varchar(32) | YES | | NULL | |
| stockcode | varchar(32) | YES | | NULL | |
| description | varchar(64) | YES | | NULL | |
| sell_exgst | decimal(10,2) | YES | | NULL | |
| buy_price | decimal(10,2) | YES | | NULL | |
| discount | decimal(10,2) | YES | | NULL | |
| sell_gst | decimal(10,2) | YES | | NULL | |
| quantity | double | YES | | NULL | |
| line_total | decimal(10,2) | YES | | NULL | |
| serial_number | varchar(64) | YES | | NULL | |
| date_stamp | varbinary(10) | YES | | NULL | |
| time_stamp | varbinary(8) | YES | | NULL | |
| serial_override | tinyint(4) | YES | | NULL | |
| price_override | tinyint(4) | YES | | NULL | |
| discount_override | tinyint(4) | YES | | NULL | |
| ybresponse | tinyint(4) | YES | | NULL | |
| token_soap | varchar(128) | YES | | NULL | |
| token_status | tinyint(4) | YES | | NULL | |
| product_pri_key | int(11) | NO | | 0 | |
+-------------------+---------------+------+-----+---------+-------+
21 rows in set (0.02 sec)
The view was created with:
Show quoted textmysql> describe product;
+-------------------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra
|
+-------------------+---------------+------+-----+---------+----------------+
| receipt_id | int(11) | YES | | NULL |
|
| prod_id | int(11) | YES | | NULL |
|
| barcode | varchar(32) | YES | | NULL |
|
| stockcode | varchar(32) | YES | | NULL |
|
| description | varchar(64) | YES | | NULL |
|
| sell_exgst | decimal(10,2) | YES | | NULL |
|
| buy_price | decimal(10,2) | YES | | NULL |
|
| discount | decimal(10,2) | YES | | NULL |
|
| sell_gst | decimal(10,2) | YES | | NULL |
|
| quantity | double | YES | | NULL |
|
| line_total | decimal(10,2) | YES | | NULL |
|
| serial_number | varchar(64) | YES | | NULL |
|
| date_stamp | varchar(10) | YES | | NULL |
|
| date_time | varchar(8) | YES | | NULL |
|
| serial_override | tinyint(4) | YES | | NULL |
|
| price_override | tinyint(4) | YES | | NULL |
|
| discount_override | tinyint(4) | YES | | NULL |
|
| ybresponse | tinyint(4) | YES | | NULL |
|
| token_soap | varchar(128) | YES | | NULL |
|
| token_status | tinyint(4) | YES | | NULL |
|
| product_pri_key | int(11) | NO | PRI | NULL |
auto_increment |
+-------------------+---------------+------+-----+---------+----------------+
21 rows in set (0.03 sec)
Notice that the bottom part defines the product_pri_key as a primary key.
So I guess the description of my bug is:
"Class::DBI::Loader" (specifically when used with MySQL) does not setup
views correctly and instead croaks with:
Initializing "POS::CreditnotesIncomplete" at
/usr/local/share/perl/5.8.7/Class/DBI/Loader/Generic.pm line 192.
creditnotes_incomplete has no primary key at
/usr/local/share/perl/5.8.7/Class/DBI/Loader/Generic.pm line 196"
That appears to be where it checks for a primary key.
I'm not sure how this might be fixed - skipping views -might- work...
DSL