On 27.01.2009 13:29 Uhr, Morgan Tocker wrote:
SQL is often the result of code-generation, whereas Python/PHP are
"usually" not.
Let me reproduce (at least what I think Kay's comment is), but in php code:
<?php
/* Pretend this list of integers comes from
some other code above - the last empty string is a bug */
$integers = array('1', '2', '3', '6', '9', '');
mysql_query("SELECT * from blog_posts WHERE id IN (".implode(",",
$integers).")");
?>
the common perl mistake (since we are showing off our m4d scr1pt sk1llz ;)):
classdump:~ kroepke$ perl
my @a = (1,2,3,4,undef,5);
print "select a from t where b in (" . join(",", @a) . ");\n";
^D
select a from t where b in (1,2,3,4,,5);
often a bug in the code that assembles @a (more often than not @a is
coming from some other resultset that contained a NULL somewhere).
my vote: syntax error. otherwise you'll hardly ever notice that you even
have a problem in the first place (other than the eventual data
inconsistencies which truly are a pain to debug if you don't know where
they might be coming from).
cheers,
-k
--
Kay Roepke
Software Engineer, MySQL Enterprise Tools
Sun Microsystems GmbH Sonnenallee 1, DE-85551 Kirchheim-Heimstetten
Geschaeftsfuehrer: Thomas Schroeder, Wolfang Engels, Dr. Roland Boemer
Vorsitz d. Aufs.rat.: Martin Haering HRB MUC 161028
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp