Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

results() returns document instead of array #41

Closed
AdriaandeJongh opened this issue Jan 9, 2019 · 6 comments
Closed

results() returns document instead of array #41

AdriaandeJongh opened this issue Jan 9, 2019 · 6 comments
Labels

Comments

@AdriaandeJongh
Copy link

The following query returns a single Document instead of an array if there is only 1 document that matches the query:

$result = $bd->query()->select('var1')->where('var2','!=','')->results();

The docs state results() should always just return an array, so this was a hard catch ;)

@timothymarois
Copy link
Member

@AdriaandeJongh Thanks! I will add that to the tests and see what's going on there. If I find it, I'll add a patch in the next fix. Maybe, for now, run a check to see if its a document or an array.

@aalfiann
Copy link

aalfiann commented Jan 22, 2019

I having same problem.

The first result is array (no problem), but the next result is not array but Document object.

I had to set cache to false to make this work.

@timothymarois
Copy link
Member

@aalfiann Can you confirm this is an issue when cache is set to true?

Does it work on the first query, and then the second query (cached) does not? Which would mean its related to reading the cache.

@aalfiann
Copy link

No, the cache is fine, It seems there is a problem in run() function.

I'm not sure, but for temporary right now, I just disabled cache when use select(array) and everything is ok.

@timothymarois
Copy link
Member

@aalfiann Ok, thanks for confirming. I will look into this and see if there is a patch to be made.

faryar76 pushed a commit to faryar76/Filebase that referenced this issue Feb 24, 2019
@faryar76 faryar76 mentioned this issue Feb 24, 2019
timothymarois added a commit that referenced this issue Feb 24, 2019
@timothymarois
Copy link
Member

@AdriaandeJongh This has been resolved from a recent by fix by @faryar76 – Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants