ArcPy functionality using and detecting Query Layers is very limited.
- Identification - In the arcpy.mapping module there is no proper way to identify a query layer. There should be a method or property to identify the layer in question is a query layer.
- Update Query - In the arcpy.mapping module there is no ability to modify the query portion of the query layer.
- repathDataSource - This method does not work properly for Query Layers especially if the database name has changed. Using SQL Server the database name is part of the query and this method does not update the database inside the query layer properties. This could be dealt with if updating the query was possible but currently it is not so repathing a map document using query layers with differing databases is not an easy task or nearly impossible.