For that reason I avoid any database specific features and try to stay database agnostic in my implementations since I had few projects that required database switching.
MySQL vs. SQLite in testing
I ran into the same problem again and again in testing Laravel application.
I have some database queries where the most simplest solution is using the database built-in functions.
For example:
CONCAT(date, ' ', time)
NOW()
field REGEXP 'pattern'
These functions, and the REGEXP operator works fine under MySQL, but get error if I try to test these queries under SQLite.
I know for the NOW() I can use PHP level Carbon::now(), but not this is the point.
So is there any magic what convert the queries (functions, operators, any MySQL specific thing) to the right SQLite format? Or what is the best practice for this case?
@netdjw If you’re writing raw, MySQL query fragments then test using a MySQL database. Don’t write MySQL-specific stuff and then act confused it doesn’t work in non-MySQL databases.
Laravel used a database abstraction layer underneath, so if you’re not using query builder methods then chances are you’re writing something database-specific and it’s not going to portable.
Please or to participate in this conversation.