fylzero's avatar
Level 67

What is your opinion on using != vs !== in PHP? SQLite testing

So, apparently (and correct me if I'm wrong)... All data in SQLite is a string?

I'd like to consider using SQLite :memory: for a project, but said project is using strict type checking in almost every comparison. Not sure if it absolutely needs to be written this way.

What is the best move here?

Don't use SQLite in memory for testing?

Remove the strict comparison operators?

Thanks in advance. Just curious what the room thinks.

0 likes
5 replies
fylzero's avatar
Level 67

@jlrdw I know the difference. The question is how to approach using SQLite with memory testing since it doesn't support basic type differences?

jlrdw's avatar

Just my opinion I would stick with strict as possible, I have programmed in C# and Java and they are strong types.

There's always a danger in especially Authentication and Gates if a comparison is loose a security flaw can take place.

fylzero's avatar
fylzero
OP
Best Answer
Level 67

So this actually hasn't been that much of a problem. So far my code and tests run, which I find odd, since SQLite puts out integers as strings and we have strict checking littered throughout the application in question.

I've mostly been able to assertSame and assertEquals instead of strict checking when needed on tests.

Haven't really run into any issues.

fylzero's avatar
Level 67

I eventually learned that using $casts in models largely solves this problem. By type-casting data it is usable with any database and solidifies your data types called from Eloquent.

Please or to participate in this conversation.