Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

[mv] minivend/minimate partial update problem?



******    message to minivend-users from Lance Carito <lcarito@pathfinder.com>     ******


Hello, I guess this question may be directed more for Mr. Heins, but
perhaps there are others who can answer it:

I have an SQL database table which doesn't have a primary key column,
instead it has a column of non-unique keys, designed this way for
various reasons. When I use minimate's partial update function to add
new rows to the table, I run into problems when there are rows with
identical keys. For instance, the update file could contain:

key_code  sku
800338	  980006
800338	  980014

But what's inserted into the database is only this:

key_code   sku
800338	   980014

When I looked into the code of both the Minimate mmtags.cfg file, and
the lib/Vend/Table/DBI.pm module, it seems like Minivend, if a row
with the same key code exists, will delete the existing row, and then
insert the new row. For instance, in the set_row method within the
DBI.pm module, there's these lines of code:

$s->[$DBI]->do("delete from $s->[$TABLE] where $s->[$KEY] = $val");
$s->[$DBI]->do("insert into $s->[$TABLE] ($s->[$KEY]) VALUES ($val)");


Also, in the lib/MiniMate/mmtags.cfg file, within the import_fields
UserTag routine, there's these two if statements:

if (! $db->record_exists($k)) {
   if ($opt->{add}) {

It seems like it's first checking to see if the row with that key
exists already, and then checks to see if you picked the "Add Record"
option or the "Update Only" option on the Partial Update form.

If you chose on the form to Add new records, doesn't that choice imply
the records do not exist in the table? And even if they did, wouldn't
it be better if the SQL INSERT simply failed, due to duplicate keys
(if your table was designed that way) instead of simply skipping them?

I guess it was done this way to sort of "idiot proof" the update file?
For my purposes, I commented out the above mentioned lines of code,
and the partial update worked out fine. 

Could this be considered a minor flaw or a feature? Or am I totally
off the mark here, and overlooking some details? Any comments?


-- 
-Lance
"Here's my talisman. If you change your mind, give us a chant."
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: