evoWeb / store_finder

Store finder extension for TYPO3
GNU General Public License v2.0
2 stars 9 forks source link

Unknown column 'distance' in 'field list' #7

Closed zenobio93 closed 5 years ago

zenobio93 commented 5 years ago

When adding a new location with LocationRepository, an error occured on persistsAll():

Unknown column 'distance' in 'field list'

It depends on changes made in https://github.com/evoWeb/store_finder/commit/0aaba3d45586d872a573e054f3927078af7a5ba6

garbast commented 5 years ago

This would lead to problems with the findByConstraints query. In this all fields are fetched with l.* and in addition the destination is calculated via

               (acos(
                   sin(' . $constraint->getLatitude() * M_PI . ' / 180) *
                   sin(latitude * ' . M_PI . ' / 180) +
                   cos(' . $constraint->getLatitude() * M_PI . ' / 180) *
                   cos(latitude * ' . M_PI . ' / 180) *
                   cos((' . $constraint->getLongitude() . ' - longitude) * ' . M_PI . ' / 180)
               ) * 6370) as `distance`

In combination this will lead to having two distance values in the result and errors in some database configurations.

Replacing l.* with a full list of fields is no solution because that would conflict with extendable models.