sequelize: ER_SP_DOES_NOT_EXIST: FUNCTION users.AsText does not exist

mysql> select `users`.AsText(`location`) from users;
FUNCTION users.AsText does not exist
mysql> select AsText(`location`) from users;
+--------------------+
| AsText(`location`) |
+--------------------+
| POINT(10 10)       |
| POINT(10 10)       |
| POINT(10 10)       |
+--------------------+
3 rows in set (0.05 sec)

could i not use users default ?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

The issue is more complex than the solution the proposed patch gives. This occurs on models that have a GEOMETRY column when used in conjunction with an include option. The abstract query writer for tries to prefix column names with table names for include to work properly but the GEOMETRY type uses selectGeometry() which in mysql uses a function call (AsText(column)).

Things are even worse if the table with the GEOMETRY column is not the primary table. Then geometrySelect() is not called at all, returning the blob as column value.

Currently GEOMETRY type is broken for the inlcude option. A proper solution requires checking for GEOMETRY columns in more places in selectQuery and passing the mainTableAs as an option to geometrySelect so it can prefix column names appropriately.

Also a more general solution would require a refactor to handle function calling attributes in more gracefully instead of filling the code up with if (isGeometrySelect(attr)) { ... because every function-calling custom column will require special treatment.