On 02/11/12 15:22, Kit wrote:
2012/2/10 Willian Gustavo Veiga<[email protected]>:
SQLite is a great database to unit test (TDD) applications. You can run it
in memory with your tests ...

I've found a problem when I was unit testing my application. MySQL
(production database) supports EXTRACT SQL standard function. SQLite don't
support it. It would be great to have support in this standard.
Unfortunately, strftime isn't a solution. It's not a standard.
Function strftime is your solution. Write two models. One for MySQL,
one for SQLite. These databases are quite different and require
different SQL queries.
Maybe views could be used to handle differences, at least some of them ;-)
sqlite> create view dateCurrent as
   ...> select
   ...> substr(date(),0,5) as year,
   ...> substr(date(),6,2) as month,
   ...> substr(date(),9,2) as day;
sqlite> .header on
sqlite> select * from dateCurrent;
year|month|day
2012|02|12

mysql> create view dateCurrent as
    -> select
    -> substr(current_date,1,4) as year,
    -> substr(current_date,6,2) as month,
    -> substr(current_date,9,2) as day;
mysql> select * from dateCurrent;
+------+-------+-----+
| year | month | day |
+------+-------+-----+
| 2012 | 02    | 12  |
+------+-------+-----+

--
Roger


_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to