Modify

Opened 12 years ago

Closed 9 years ago

Last modified 9 years ago

#189 closed Erweiterung (fixed)

configuration_key unique machen

Reported by: Volker Rehn Owned by: somebody
Priority: normal Milestone: modified-shop-2.0.2.0
Component: Shop Version: 1.06
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by Torsten Riemer)

Aufgefallen beim Erstellen eines update-Pakets: Um die Tabelle configuration gefahrlos und wiederholbar mit inserts zu aktualisieren, muss erst gecheckt werden, ob es die Einträge schon gibt. Das geht zwar mit SQL, ist aber mühsam:

INSERT INTO configuration ( configuration_key, configuration_value, configuration_group_id, sort_order, date_added) 
SELECT 'MODULE_PAYMENT_BANKTRANSFER_CI', '', '6', '0', now() FROM configuration
WHERE NOT EXISTS (SELECT 1 FROM configuration WHERE configuration_key = 'MODULE_PAYMENT_BANKTRANSFER_CI')
LIMIT 1;

Tabelle configuration sollte sowieso den configuration_key unique haben. Denn zwei Sätze mit dem gleichen configuration_key sind falsch.

Dann könnte man das insert so schreiben:

INSERT INTO configuration ( configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_PAYMENT_BANKTRANSFER_CI', '', '6', '0', now()) 
ON DUPLICATE KEY UPDATE configuration_key = configuration_key

oder so:

INSERT IGNORE INTO configuration ( configuration_key, configuration_value, configuration_group_id, sort_order, date_added) VALUES ('MODULE_PAYMENT_BANKTRANSFER_CI', '', '6', '0', now())

INSERT IGNORE hat den Nachteil, dass *alle* Fehler ignoriert werden, ON DUPLICATE hat dieses pseudo-update am Ende, ist aber sicherer.

Attachments (0)

Change History (5)

comment:1 by Gerhard Waldemair, 11 years ago

Milestone: modified-shop-2.00modified-shop-2.10
Version: 1.062.10

Vorbereitung in 2.00 dafür gemacht

comment:2 by Torsten Riemer, 11 years ago

Description: modified (diff)

comment:3 by Gerhard Waldemair, 9 years ago

Resolution: fixed
Status: newclosed

ist bereits umgesetzt

comment:4 by Gerhard Waldemair, 9 years ago

In 10459:

fix #189, #1075

comment:5 by Torsten Riemer, 9 years ago

Milestone: modified-shop-2.1.0.0modified-shop-2.0.1.1
Version: 2.0.1.01.06

Modify Ticket

Action
as closed The owner will remain somebody.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.