PHP, SQL Server and fields using geography functions not working in 1.7.4
PHP, SQL Server and fields using geography functions not working in 1.7.4
Since moving from 1.6.x to 1.7.4 we have been unable to fix an issue with using a geography data type in SQL Server. The field is defined as the following:
$field = Field::inst('geography.STAsText()', 'geography');
$ed->fields($field);
In 1.6.5 the portion of the SQL query for selecting this field was editorTestTable.geography.STAsText() as 'editorTestTable.geography.STAsText()'
but after updating to 1.7.4 we are unable to find the right combination of $name and $dbField in the field constructor to create this same query and display the results of the function. In 1.7.4 this portion of the query is simply showing as editorTestTable.geography.STAsText()
and does not include a column name.
Are there any recommendations for the correct configuration to return our geography column data?
P.S. I was able to get this to work in a simplified example on 1.7.3 but not any other version of 1.7.x.
This question has an accepted answers - jump to answer
Answers
Hi,
You'll need to forgive me I'm afraid, but I'm not familiar with that SQL function, so I'm not clear on what it should look like. You say it doesn't include a column name - should a parameter be getting passed into it? Is
geography
the schema andSTAsText()
a function in it? Or is that some built in function that is chained onto a column?Thanks,
Allan
It is the latter case. We are using the geography spaital data type in a column named geography and have created a field type plugin for handling the data client side. When selected, the geography data type is returned as a binary value. We make use of the data type's STAsText method to return the WKT representation as varchar to work with in our field type plugin. The method does not have any parameters and just acts on the geography column. I apologize for the lack of background information in the original post.
Hi,
Sorry I wasn't able to get back to you about this yesterday. In the
Database/Query.php
file you'll find a_build_field
private method. Could you replace it with:That will resolve the issue.
Thanks,
Allan
I have tried to replace the method as you recommended, but this has caused an error with the initial count query from the _ssp_query method. Here is the response I'm receiving now.
Please advise if I've applied this incorrectly. Thanks!
I didn't check this with server-side processing actually. Let me check into this and get back to you!
Allan
Small change - give this one a whirl:
Allan
Thanks, that did the trick! Will this fix be incorporated into an upcoming release as well?
Yes indeed. We'll give it a good testing and it should be included. v1.8 is likely to be the next version of Editor at this time.
Allan