snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
11.08k stars 3.18k forks source link

500 (Internal Server Error) using SQLite DB while searching Assets and Users because of the CONCAT function #10948

Open ahmetshen-us opened 2 years ago

ahmetshen-us commented 2 years ago

Debug mode

Describe the bug

Searching for any term on Users or Assets would not return anything and Console shows 500 (Internal Server Error)

http://snipeit.dev/api/v1/hardware?status=&order_number=&company_id=&status_id=&search=h&offset=0&limit=20 500 (Internal Server Error)

Also logs would show "SQLSTATE[HY000]: General error: 1 no such function: CONCAT..."

Reproduction steps

  1. Search for any term on Users or Assets while using SQLite DB

Expected behavior

Return searched Users and Assets

Screenshots

No response

Snipe-IT Version

v5.4.1

Operating System

Ubuntu 20.04.4 LTS

Web Server

Apache

PHP Version

7.4.3

Operating System

Ubuntu

Browser

All

Version

No response

Device

No response

Operating System

No response

Browser

No response

Version

No response

Error messages

No response

Additional context

There are already issues mentioning same errors but they did not specify if they were using SQLite DB. I am already working on a solution in my dev environment. I will be submitting a PR soon. @snipe This will be my first contribution to Snipe-IT and to open source in general, excited to fix this.

m1k1o solved a same issue for blog project.

https://github.com/m1k1o/blog/commit/386707c1040a47530de3522e2d49699beeaa089d

welcome[bot] commented 2 years ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

ahmetshen-us commented 2 years ago

Only these 2 lines uses CONCAT. https://github.com/snipe/snipe-it/blob/master/app/Models/User.php#L621 https://github.com/snipe/snipe-it/blob/master/app/Models/User.php#L637

GitHub
snipe-it/User.php at master · snipe/snipe-it
A free open source IT asset/license management system - snipe-it/User.php at master · snipe/snipe-it
GitHub
snipe-it/User.php at master · snipe/snipe-it
A free open source IT asset/license management system - snipe-it/User.php at master · snipe/snipe-it
ahmetshen-us commented 2 years ago

Looks like I can not create new fork: "No more forks can be created. View existing forks."

https://stackoverflow.com/questions/14821583/pull-request-without-forking

Do I need a branch then? @snipe

Stack Overflow
Pull request without forking?
Here are steps of code contribution from the topic "How do I contribute to other's code in GitHub?" Fork the project Make one or more well commented and clean commits to the repository. You ca...
snipe commented 2 years ago

We don't officially support SQLite, per the requirements. If you have a fix that will work around this, we can try it, but it's not officially a DB we support.

snipe commented 2 years ago

(Also I have legit never heard of the "No more forks can be created." error - I have no idea what to do there. There are projects waaaay bigger than ours that I don't think have this problem? I'll try to dig around a little.)

snipe commented 2 years ago

Oh! It's because you already have a fork. https://github.com/ahmetshen-us/snipe-it

You'd just want to pull from upstream (us) to make sure you have the latest of our changes, and then create a feature branch, then open a PR from your feature branch to us.

That is terribly confusing language though - I'll see if I can get GH to update that to be clearer.

GitHub
GitHub - ahmetshen-us/snipe-it: A free open source IT asset/license management system
A free open source IT asset/license management system - GitHub - ahmetshen-us/snipe-it: A free open source IT asset/license management system
snipe commented 2 years ago

(Alternatively, you can delete your original fork of Snipe-IT and create a new one to make sure you have all of our latest changes.)

ahmetshen-us commented 2 years ago

All sounds good.

I totally forgot about that fork 🤦🏻 I should have contributed earlier 😁

SQLite is so easy for small projects with Docker. Only one docker image/container suffice. Made the changes in my dev inventory and works very well.

I remember searches did not work a while back 2 years ago with the MYSQL too.

Quick question though. If we create a function to be used in User.php and Asset.php in which file should we have it?