Subject: | Not able to sqlite_create_function for DATE_ADD |
I want to create a function to mimic MySQL's DATE_ADD, but it seem a function with esoteric parameters with spaces in them does not work as expected:
✔ 01:01 ~ $ perl -wle 'use Data::Dumper; use DBI; my $dbh = DBI->connect("dbi:SQLite:/tmp/test"); $dbh->sqlite_create_function("date_add", -1, sub { return 2; }); warn Dumper($dbh->selectrow_arrayref("select date_add(1);"));'
$VAR1 = [
2
];
✔ 01:01 ~ $ perl -wle 'use Data::Dumper; use DBI; my $dbh = DBI->connect("dbi:SQLite:/tmp/test"); $dbh->sqlite_create_function("date_add", -1, sub { return 2; }); warn Dumper($dbh->selectrow_arrayref("select date_add(1, interval 1 hour);"));'
DBD::SQLite::db selectrow_arrayref failed: near "1": syntax error at -e line 1.
$VAR1 = undef;
Is there something I am doing wrong, or should function parsing work differently? is that an sqlite issue, or can the DBI driver do something about it?