ekvedaras / laravel-query-intellij

💿 Laravel Query Builder integration for PhpStorm
MIT License
47 stars 3 forks source link

Unknown column since latest update #100

Closed Ahmed-Elrayes closed 1 year ago

Ahmed-Elrayes commented 1 year ago

Hello, since the last update i keep getting unknown column even though i'm sure that i have the datasource added and even selected the database i want for the query in settings.. image

ekvedaras commented 1 year ago

Hi. Can you share the full code statement?

Ahmed-Elrayes commented 1 year ago

This is one statement. image

This is another one image

ekvedaras commented 1 year ago

Does CompetitorUser model has $table property defined? How is the table itself named? What do your plugin settings look like?

For the second, just out of curiosity - does it work if you rename first declaration of $query variable to something else, but leave $query = match name variable name unchanged? Or vice versa

Ahmed-Elrayes commented 1 year ago

CompetitorUser has $table in it yes. and the table name is competitors_users the valriable $query can be renamed and still have the same issue, actually this issue is in the whole project. since you mentioned plugin settings, it seems that this issue occurred only to this project, all my other projects are working fine, and it's weird because i'm pretty sure i did not change any setting, it just happened once i updated the plugin. to be more specific: this was the project i had open when i updated the plugin. and here is the settings for it image

ekvedaras commented 1 year ago

If you temporarily unselect Filter data sources ? Is it for sure correct dabase selected? Is it refreshed and up to date in Databases toolbar view?

Ahmed-Elrayes commented 1 year ago

the issue still persists if i unselect filter data sources. the database is for sure selected yeah i even deleted the datasource in Database toolbar and added it again and still persists.

Ahmed-Elrayes commented 1 year ago

Managed to fix it finally, had to delete the laravel-query-settings.xml file from .idea folder

There must be something happened to the settings file when i updated the plugin image

Ahmed-Elrayes commented 1 year ago

here is how it did look inside

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="LaravelQuerySettings">
    <option name="filterDataSources" value="true" />
    <option name="filteredDataSources">
      <set>
        <option value="30eca40e-d219-4cd8-bf22-f78372aabbbd&lt;-/lq/-&gt;linda" />
      </set>
    </option>
    <option name="tablePrefix" value=" " />
  </component>
</project>

i believe the issue was in this line

<option name="tablePrefix" value=" " />
ekvedaras commented 1 year ago

Most likely. Should probably trim this value before saving. Don't think in any database spaces are allowed in table names 🤔

Ahmed-Elrayes commented 1 year ago

i actually don't do any table prefixes, so i'm not sure why it was added

ekvedaras commented 1 year ago

Most likely by accident

Ahmed-Elrayes commented 1 year ago

i see, thanks a lot. i hope at least you can make something for this in the future to trim any spaces before saving. i will close this issue.

cAstraea commented 1 year ago

Had the same issue. Deleting the .xml fixed it. Thx Ahmed-Elrayes

Ahmed-Elrayes commented 1 year ago

You are welcome, glad that it helped you.