rinvex / laravel-attributes

⚠️ [ABANDONED] Rinvex Attributable is a robust, intelligent, and integrated Entity-Attribute-Value model (EAV) implementation for Laravel Eloquent, with powerful underlying for managing entity attributes implicitly as relations with ease. It utilizes the power of Laravel Eloquent, with smooth and seamless integration.
MIT License
434 stars 104 forks source link

getEntityAttributes Error #67

Closed mohammad-y closed 3 years ago

mohammad-y commented 6 years ago

hello When using the package, I get the following error

rinvex\attributes\src\Traits\Attributable.php on line 178

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '>'$."$en"' asc' at line 1 (SQL: select * from attributes where 0 = 1 order by sort_order asc, name->'$."$en"' asc)

IsraelOrtuno commented 6 years ago

What version of MariaDB are you using? Make sure it supports JSON data types

joaolisboa commented 6 years ago

@IsraelOrtuno I also had this issue and the problem in our case was not the JSON data type because MariaDB already supported it, kind of, just as an alias for LONG TEXT if I'm not mistaken. The issue is the syntax for searching in the json fields of the column name which I don't think MariaDB supports. I'm running version 10.1.35, so maybe 10.2 or 10.3 have fixed this. I know 10.2 brought support for JSON functions like JSON_EXTRACT but I'm not sure about this specific syntax. I have yet to try it out.

mschlachter commented 5 years ago

I seem to be running into this same issue using MariaDB 10.2.22:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL 
    syntax; check the manual that corresponds to your MariaDB server version for the 
    right syntax to use near '>'$."$en"' asc' at line 1 (SQL: select * from `attributes` 
    where 0 = 1 order by `sort_order` asc, `name`->'$."$en"' asc)
[STACK] Line 624 in Connection.php
[STACK] Line 333 in Connection.php
[STACK] Line 1963 in Builder.php
[STACK] Line 1951 in Builder.php
[STACK] Line 2435 in Builder.php
joaolisboa commented 5 years ago

@mschlachter You need to use MySQL or fork and change the code which is what I did. MariaDB versions that support JSON data types still doesn't work with the function used here, at least back when I had this issue.

Omranic commented 3 years ago

I'm not sure if this issue is still valid. If you believe the JSON behavior with MariaDB is still buggy, feel free to re-open this issue with more details on how to reproduce it.