You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ER_SP_DOES_NOT_EXIST: FUNCTION users.AsText does not exist #4715
Please include the full query called that errors and it would be helpfull to have a SSCCE.
You can check out the test/ folder for ways to write test cases, specifically look for the geometry tests.
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.
@janmeier I browsed through the tests for mysql query-generator but there is nothing that tests the include option. (Although it influences the behavior of selectQuery substancially) Is there some place else I should add tests? Having tests for include only for GEOMETRY columns is pointless. I could provide examples of failing combinations of define('Foo', {blah..}) and Foo.findAll({where: {blah...}, include{blah...}) if that's what you mean. Otherwise I'll need some guidance for writing the appropriate tests
@janmeier there seems to exist such a function that it's docstring says it handles function attributes called query(). But the code doesn't handle the {fn:'foo'} case. I could start from there for a patch.
I found dialects/abstract/QueryGenerator.quote(). As i look through the code, I see that quoting of attributes is inconsistent. At some places names are quoted properly with backticks but some cases the names are joined by . without quoting the parts. I am trying to add the fn case to solve the geometry issue by returning an {fn: 'asText', cols: ['foo']} object from selectGeometry().
Activity
zhfish commentedon Oct 23, 2015
is right
janmeier commentedon Oct 23, 2015
Can you please show the actual sequelize code that produces the issue?
zhfish commentedon Oct 23, 2015
janmeier commentedon Oct 23, 2015
And the model definitons, and some actual data?
zhfish commentedon Oct 23, 2015
model
data
mickhansen commentedon Oct 23, 2015
@zhfish Please add the entire find call. (The
AsTextfunction call in particular)zhfish commentedon Oct 23, 2015
i won't call asText directly,
geometry for mysql do it
zhfish commentedon Oct 24, 2015
i try to fix it
i'm sorry ,i don't understand how to write unit test
mickhansen commentedon Oct 25, 2015
Please include the full query called that errors and it would be helpfull to have a SSCCE.
You can check out the test/ folder for ways to write test cases, specifically look for the geometry tests.
alxarch commentedon Nov 6, 2015
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
includeoption. The abstract query writer for tries to prefix column names with table names forincludeto work properly but the GEOMETRY type usesselectGeometry()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
inlcudeoption. A proper solution requires checking for GEOMETRY columns in more places inselectQueryand passing themainTableAsas an option togeometrySelectso 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.janmeier commentedon Nov 6, 2015
@alxarch Agreed, thats why the proposed PR has not been merged yet - the solution is too simple, and it includes no tests :(
It would be a great help if you could provide those test cases :)
alxarch commentedon Nov 6, 2015
@janmeier I browsed through the tests for mysql query-generator but there is nothing that tests the
includeoption. (Although it influences the behavior ofselectQuerysubstancially) Is there some place else I should add tests? Having tests forincludeonly for GEOMETRY columns is pointless. I could provide examples of failing combinations ofdefine('Foo', {blah..})andFoo.findAll({where: {blah...}, include{blah...})if that's what you mean. Otherwise I'll need some guidance for writing the appropriate testsalxarch commentedon Nov 6, 2015
@janmeier there seems to exist such a function that it's docstring says it handles function attributes called
query(). But the code doesn't handle the {fn:'foo'} case. I could start from there for a patch.janmeier commentedon Nov 6, 2015
Those tests are old - we are hoping to migrate them at some point. Unit tests for include sql are here https://github.com/sequelize/sequelize/blob/master/test/unit/sql/select.test.js
Which function are you referring to?
alxarch commentedon Nov 6, 2015
I found
dialects/abstract/QueryGenerator.quote(). As i look through the code, I see that quoting of attributes is inconsistent. At some places names are quoted properly with backticks but some cases the names are joined by.without quoting the parts. I am trying to add thefncase to solve the geometry issue by returning an {fn: 'asText', cols: ['foo']} object fromselectGeometry().alxarch commentedon Nov 7, 2015
@janmeier I added a working solution that passes two simple inclusion tests (primary and secondary table).
janmeier commentedon Dec 4, 2015
We no longer use
axTextwhen selecting geometry