Seriously, WTF?
MacGyveR
macgyver at thedumbterminal.co.uk
Tue May 6 07:43:52 BST 2008
On Tuesday 06 May 2008, Toby Corkindale wrote:
> 1)
> MySQL lets you set DEFAULT values for everything *except* DATETIME.. WTF?
> You *can* have TIMESTAMP default to something, however it seems to return
> different formats of data depending on the versions of MySQL you're
> running, thus confounding attempts to work on multiple versions (and
> breaking DateTime::Format::MySQL too).
> How do you guys deal with this? Am I missing something stupid?
>
> http://dev.mysql.com/doc/refman/5.0/en/data-type-defaults.html
>
>
> 2)
> MySQL's 'REPLACE INTO' command. What were they thinking?
> I suppose it seemed like a good idea at the time, but try this at home
> kids: create table A. Create table B which has a foreign key into table A,
> with 'on delete cascade' set. Nowever do a REPLACE INTO table A for an
> existing row.. Note that table B has now deleted all related rows.
> Wonderful!
>
>
> (I've been having to work with MySQL for over a year now and it STILL keeps
> coming up with new ways to fall to pieces when I least expect it.. On the
> other hand, I don't think Postgres (my preferred DB) would do the sort of
> replication needed at this company. When oh when will they sort that out?)
1) you could use a trigger so solve your date problem, but that is a bit icky
(mysql 5+)
2) i thought the docs state that replace is just a delete(if needed) then
insert using the primary key given. In that case it behaves the same was as
if the two commands were issued separately. but i completely agree here, a
sort of half feature that can't be used anywhere sensible :-(
More information about the london.pm
mailing list