diff --git a/backend/lib/Controller/EntityController.php b/backend/lib/Controller/EntityController.php index 1f23e15..46aadc8 100644 --- a/backend/lib/Controller/EntityController.php +++ b/backend/lib/Controller/EntityController.php @@ -160,7 +160,7 @@ class EntityController extends Controller { case 'boolean': $value = ($value) ? 1 : 0; } - $sqlWhere[] = 'EXISTS (SELECT p' . $i . ' FROM \Volkszaehler\Model\Property p' . $i . ' WHERE p' . $i . '.key = \'' . $property . '\' AND p' . $i . '.value = ' . $value . ' AND p' . $i . '.entity = a)'; + $sqlWhere[] = 'EXISTS (SELECT p' . $i . ' FROM \Volkszaehler\Model\Property p' . $i . ' WHERE p' . $i . '.name = \'' . $property . '\' AND p' . $i . '.value = ' . $value . ' AND p' . $i . '.entity = a)'; $i++; } diff --git a/backend/lib/Model/Entity.php b/backend/lib/Model/Entity.php index 37b3b6e..c868160 100644 --- a/backend/lib/Model/Entity.php +++ b/backend/lib/Model/Entity.php @@ -67,7 +67,7 @@ abstract class Entity { /** * @OneToMany(targetEntity="Property", mappedBy="entity", cascade={"remove", "persist"}) - * @OrderBy({"name" = "ASC"}) + * @OrderBy({"key" = "ASC"}) */ protected $properties = NULL; diff --git a/backend/lib/Model/Property.php b/backend/lib/Model/Property.php index bc021ed..f9681fb 100644 --- a/backend/lib/Model/Property.php +++ b/backend/lib/Model/Property.php @@ -38,7 +38,7 @@ use Volkszaehler\Model; * @Table( * name="properties", * uniqueConstraints={ - * @UniqueConstraint(name="unique_keys", columns={"entity_id", "name"}) + * @UniqueConstraint(name="unique_keys", columns={"entity_id", "pkey"}) * } * ) * @HasLifecycleCallbacks @@ -53,7 +53,10 @@ class Property { */ protected $id; - /** @Column(name="name", type="string", nullable=false) */ + /** + * @Column(name="pkey", type="string", nullable=false) + * HINT: column name "key" is reserved by mysql + */ protected $key; /** @Column(type="string", nullable=false) */